#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 */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ cliAddr;

/* Variables and functions */
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ memset(struct sockaddr_storage *, int /*<<< orphan*/, int);
int /*<<< orphan*/ serverStream(int);
int /*<<< orphan*/ sysError(char *);
int acceptClient(int servSock) {
  for (;;) {
    struct sockaddr_storage cliAddr;
    socklen_t cliLen = sizeof(cliAddr);
    memset(&cliAddr, 0, cliLen);
    int cliSock = accept(servSock, (struct sockaddr *)&cliAddr, &cliLen);
    if (cliSock < 0)
      sysError("failed to accept new connection");
    serverStream(cliSock);
  }
}


x86 assembly (clang, -O0):
<acceptClient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <accept@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1189 <acceptClient+0x49>
lea    0xe7c(%rip),%rdi
call   1030 <sysError@plt>
mov    -0x10(%rbp),%edi
call   1060 <serverStream@plt>
jmp    114b <acceptClient+0xb>

x86 assembly (clang, -O2):
<acceptClient>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r12d
lea    0x8(%rsp),%rbx
lea    0x4(%rsp),%r14
lea    0xea0(%rip),%r15
jmp    1177 <acceptClient+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1060 <serverStream@plt>
movl   $0x4,0x4(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1170 <acceptClient+0x30>
mov    %r15,%rdi
call   1030 <sysError@plt>
jmp    1170 <acceptClient+0x30>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [32 x i8] c"failed to accept new connection\00"
define i32 @acceptClient(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_storage
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
br label %6
6: ; preds = %16, %1
store i32 4, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @memset(%struct.sockaddr_storage* %3, i32 0, i32 %7)
%9 = load i32, i32* %2
%10 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%11 = call i32 @accept(i32 %9, %struct.sockaddr* %10, i32* %4)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @sysError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %6
%17 = load i32, i32* %5
%18 = call i32 @serverStream(i32 %17)
br label %6
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [32 x i8] c"failed to accept new connection\00"
define i32 @acceptClient(i32 %0) {
%2 = alloca %struct.sockaddr_storage
%3 = alloca i32
%4 = bitcast %struct.sockaddr_storage* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.sockaddr_storage* %2 to %struct.sockaddr*
br label %7
7: ; preds = %13, %1
store i32 4, i32* %3
%8 = call i32 @memset(%struct.sockaddr_storage* %2, i32 0, i32 4)
%9 = call i32 @accept(i32 %0, %struct.sockaddr* %6, i32* %3)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @sysError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = call i32 @serverStream(i32 %9)
br label %7
}