#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 {
  int dummy;
};
typedef int /*<<< orphan*/ isa;

/* Variables and functions */
int accept(int, struct sockaddr *, size_t *);
int /*<<< orphan*/ nonblock(int);
int /*<<< orphan*/ perror(char *);
int new_connection(int s) {
  struct sockaddr isa;
  size_t i;
  int t;
  char buf[100];
  i = sizeof(isa);
  if ((t = accept(s, &isa, &i)) < 0) {
    perror("Accept");
    return (-1);
  }
  nonblock(t);
  return (t);
}


x86 assembly (clang, -O0):
<new_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
movq   $0x4,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    117a <new_connection+0x4a>
lea    0xe97(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <new_connection+0x58>
mov    -0x1c(%rbp),%edi
call   1030 <nonblock@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_connection>:
push   %rbx
sub    $0x10,%rsp
movq   $0x4,(%rsp)
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <accept@plt>
test   %eax,%eax
js     115f <new_connection+0x2f>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <nonblock@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe9a(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%ebx
jmp    1157 <new_connection+0x27>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"Accept\00"
define i32 @new_connection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr
%5 = alloca i64
%6 = alloca i32
%7 = alloca [100 x i8]
store i32 %0, i32* %3
store i64 4, i64* %5
%8 = load i32, i32* %3
%9 = call i32 @accept(i32 %8, %struct.sockaddr* %4, i64* %5)
store i32 %9, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %17
13: ; preds = %1
%14 = load i32, i32* %6
%15 = call i32 @nonblock(i32 %14)
%16 = load i32, i32* %6
store i32 %16, i32* %2
br label %17
17: ; preds = %13, %11
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"Accept\00"
define i32 @new_connection(i32 %0) {
%2 = alloca %struct.sockaddr
%3 = alloca i64
%4 = bitcast %struct.sockaddr* %2 to i8*
%5 = bitcast i64* %3 to i8*
store i64 4, i64* %3
%6 = call i32 @accept(i32 %0, %struct.sockaddr* %2, i64* %3)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = call i32 @nonblock(i32 %6)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ -1, %8 ], [ %6, %10 ]
ret i32 %13
}