#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ memcpy(char *, void *, size_t);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int uds_client_connect(char *);
void handler(int sock, void *data, size_t size) {
  char buffer[256];
  int udssock;
  ssize_t len;
  memcpy(buffer, data, size);
  udssock = uds_client_connect(buffer);
  while ((len = recv(sock, buffer, sizeof(buffer), 0)) >= 0) {
    send(udssock, buffer, len, 0);
  }
  close(udssock);
}


x86 assembly (clang, -O0):
<handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <memcpy@plt>
lea    -0x120(%rbp),%rdi
call   1040 <uds_client_connect@plt>
mov    %eax,-0x124(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x128(%rbp)
cmp    $0x0,%eax
jl     11d0 <handler+0x80>
mov    -0x124(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x128(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    118c <handler+0x3c>
mov    -0x124(%rbp),%edi
call   1060 <close@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handler>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edi,%r14d
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <memcpy@plt>
mov    %rbx,%rdi
call   1040 <uds_client_connect@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
js     11b4 <handler+0x64>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jns    1190 <handler+0x40>
mov    %ebp,%edi
call   1060 <close@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @handler(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = call i32 @memcpy(i8* %10, i8* %11, i64 %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = call i32 @uds_client_connect(i8* %14)
store i32 %15, i32* %8
br label %16
16: ; preds = %21, %3
%17 = load i32, i32* %4
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = call i32 @recv(i32 %17, i8* %18, i32 256, i32 0)
store i32 %19, i32* %9
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i32, i32* %8
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* %9
%25 = call i32 @send(i32 %22, i8* %23, i32 %24, i32 0)
br label %16
26: ; preds = %16
%27 = load i32, i32* %8
%28 = call i32 @close(i32 %27)
ret void
}

LLVM IR (-O2):
define void @handler(i32 %0, i8* %1, i64 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @memcpy(i8* %5, i8* %1, i64 %2)
%7 = call i32 @uds_client_connect(i8* %5)
%8 = call i32 @recv(i32 %0, i8* %5, i32 256, i32 0)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %3, %10
%11 = phi i32 [ %13, %10 ], [ %8, %3 ]
%12 = call i32 @send(i32 %7, i8* %5, i32 %11, i32 0)
%13 = call i32 @recv(i32 %0, i8* %5, i32 256, i32 0)
%14 = icmp sgt i32 %13, -1
br i1 %14, label %10, label %15
15: ; preds = %10, %3
%16 = call i32 @close(i32 %7)
ret void
}