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

/* Variables and functions */
int create_server_proc(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ handle_client_proc(int);
scalar_t__ server_init();
int /*<<< orphan*/ server_uninit();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int srvfd;
  if (server_init() < 0) {
    return -1;
  }
  srvfd = create_server_proc("127.0.0.1", 8787);
  if (srvfd < 0) {
    fprintf(stderr, "socket create or bind fail.\n");
    goto ERR;
  }
  handle_client_proc(srvfd);
  server_uninit();
  return 0;
ERR:
  server_uninit();
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <server_init@plt>
cmp    $0x0,%rax
jge    1183 <main+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <main+0x94>
lea    0xe76(%rip),%rdi
mov    $0x2253,%esi
call   1070 <create_server_proc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11bb <main+0x6b>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d6 <main+0x86>
mov    -0x14(%rbp),%edi
call   1030 <handle_client_proc@plt>
mov    $0x0,%al
call   1040 <server_uninit@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <main+0x94>
mov    $0x0,%al
call   1040 <server_uninit@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <server_init@plt>
test   %rax,%rax
js     117d <main+0x2d>
lea    0xe9c(%rip),%rdi
mov    $0x2253,%esi
call   1070 <create_server_proc@plt>
test   %eax,%eax
js     1184 <main+0x34>
mov    %eax,%edi
call   1030 <handle_client_proc@plt>
xor    %ebx,%ebx
jmp    119e <main+0x4e>
mov    $0xffffffff,%ebx
jmp    11a5 <main+0x55>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   1040 <server_uninit@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"socket create or bind fail.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 (...) @server_init()
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %23
10: ; preds = %2
%11 = call i32 @create_server_proc(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8787)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = load i32, i32* %6
%19 = call i32 @handle_client_proc(i32 %18)
%20 = call i32 (...) @server_uninit()
store i32 0, i32* %3
br label %23
21: ; preds = %14
%22 = call i32 (...) @server_uninit()
store i32 -1, i32* %3
br label %23
23: ; preds = %21, %17, %9
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"socket create or bind fail.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @server_init()
%4 = icmp slt i64 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = tail call i32 @create_server_proc(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8787)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %5
%12 = tail call i32 @handle_client_proc(i32 %6)
br label %13
13: ; preds = %11, %8
%14 = phi i32 [ 0, %11 ], [ -1, %8 ]
%15 = tail call i32 (...) @server_uninit()
br label %16
16: ; preds = %13, %2
%17 = phi i32 [ -1, %2 ], [ %14, %13 ]
ret i32 %17
}