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

/* Variables and functions */
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ dispatch_new_thread(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void call_accept(int fd, short event, void *arg) {
  fputs("a socket has come\n", stdout);
  struct sockaddr_in cliaddr;
  socklen_t clilen;
  int connfd;
  connfd = accept(fd, (struct sockaddr *)&cliaddr, &clilen);
  dispatch_new_thread(connfd);
}


x86 assembly (clang, -O0):
<call_accept>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %edi,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
lea    0xeaa(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <accept@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <dispatch_new_thread@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_accept>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1030 <fputs@plt>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1050 <accept@plt>
mov    %eax,%edi
call   1040 <dispatch_new_thread@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"a socket has come\0A\00"
@stdout = global i32 0
define void @call_accept(i32 %0, i16 signext %1, i8* %2) {
%4 = alloca i32
%5 = alloca i16
%6 = alloca i8*
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%10 = load i32, i32* @stdout
%11 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %4
%13 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%14 = call i32 @accept(i32 %12, %struct.sockaddr* %13, i32* %8)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = call i32 @dispatch_new_thread(i32 %15)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"a socket has come\0A\00"
@stdout = global i32 0
define void @call_accept(i32 %0, i16 signext %1, i8* nocapture readnone %2) {
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = load i32, i32* @stdout
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%11 = call i32 @accept(i32 %0, %struct.sockaddr* %10, i32* %5)
%12 = call i32 @dispatch_new_thread(i32 %11)
ret void
}