#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 /*<<< orphan*/ local;

/* Variables and functions */
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ perror(char *);
int accept_connect(int listen_sock) {
  int addr_len, conn_sock;
  struct sockaddr_in local;
  addr_len = sizeof(local);
  bzero(&local, addr_len);
  conn_sock = accept(listen_sock, (struct sockaddr *)&local, &addr_len);
  if (conn_sock == -1) {
    perror("accept: conn_sock");
  }
  return conn_sock;
}


x86 assembly (clang, -O0):
<accept_connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1040 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <accept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1177 <accept_connect+0x47>
lea    0xe8e(%rip),%rdi
call   1030 <perror@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_connect>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
movl   $0x4,0xc(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%esi
call   1040 <bzero@plt>
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1173 <accept_connect+0x43>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe86(%rip),%rdi
call   1030 <perror@plt>
jmp    1169 <accept_connect+0x39>

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

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