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

/* Variables and functions */
scalar_t__ EINTR;
int accept(int, struct sockaddr *, int *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int accept_one_connection(int list_sock) {
  int gotit, new_sock;
  struct sockaddr_in from;
  socklen_t len;
  len = sizeof(from);
  gotit = 0;
  while (!gotit) {
    new_sock = accept(list_sock, (struct sockaddr *)&from, &len);
    if (new_sock == -1) {
      if (errno == EINTR)
        continue;
      else {
        ;
        exit(-1);
      }
    } else
      gotit = 1;
  }
  return new_sock;
}


x86 assembly (clang, -O0):
<accept_one_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    114f <accept_one_connection+0x2f>
jmp    11a1 <accept_one_connection+0x81>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <accept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1195 <accept_one_connection+0x75>
mov    0x2e6d(%rip),%rax
mov    (%rax),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
jne    118b <accept_one_connection+0x6b>
jmp    1139 <accept_one_connection+0x19>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
movl   $0x1,-0x8(%rbp)
jmp    1139 <accept_one_connection+0x19>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_one_connection>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x4,0x4(%rsp)
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%r15
mov    0x2e98(%rip),%r12
mov    0x2e89(%rip),%r13
nop
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <accept@plt>
cmp    $0xffffffff,%eax
jne    1176 <accept_one_connection+0x56>
mov    (%r12),%rax
cmp    0x0(%r13),%rax
je     1150 <accept_one_connection+0x30>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @accept_one_connection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %6
store i32 0, i32* %3
br label %7
7: ; preds = %25, %21, %1
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %26
11: ; preds = %7
%12 = load i32, i32* %2
%13 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%14 = call i32 @accept(i32 %12, %struct.sockaddr* %13, i32* %6)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i64, i64* @errno
%19 = load i64, i64* @EINTR
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
br label %7
22: ; preds = %17
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %11
store i32 1, i32* %3
br label %25
25: ; preds = %24
br label %7
26: ; preds = %7
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
define i32 @accept_one_connection(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%6 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
br label %7
7: ; preds = %10, %1
%8 = call i32 @accept(i32 %0, %struct.sockaddr* %6, i32* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i64, i64* @errno
%12 = load i64, i64* @EINTR
%13 = icmp eq i64 %11, %12
br i1 %13, label %7, label %14
14: ; preds = %10
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %7
ret i32 %8
}