#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sqlite3;
typedef int socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ SIGCHLD;
scalar_t__ SIG_ERR;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int SQLITE_OK;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ atoi(char const *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ do_client(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char const *);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
char *sqlite3_errmsg(int /*<<< orphan*/ *);
int sqlite3_open(char *, int /*<<< orphan*/ **);
int /*<<< orphan*/ stderr;
int main(int argc, const char *argv[]) {
  int ret = 0;
  int len = 0;
  int sockfd;
  int clientfd;
  struct sockaddr_in server_addr;
  struct sockaddr_in peer_addr;
  socklen_t addrlen = sizeof(struct sockaddr_in);
  pid_t pid;
  sqlite3 *db;
  if (argc < 3) {
    printf("Usage: %s <ip> <port>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
    perror("Fail to signal");
    exit(EXIT_FAILURE);
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (-1 == sockfd) {
    perror("Fail to socket.");
    exit(EXIT_FAILURE);
  }
  bzero(&server_addr, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_port = htons(atoi(argv[2]));
  server_addr.sin_addr.s_addr = inet_addr(argv[1]);
  ret = bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr));
  if (-1 == ret) {
    perror("Fail to bind.");
    exit(EXIT_FAILURE);
  }
  ret = listen(sockfd, 10);
  if (-1 == ret) {
    perror("Fail to listen.");
    exit(EXIT_FAILURE);
  }
  ret = sqlite3_open("dict.db", &db);
  if (ret != SQLITE_OK) {
    fprintf(stderr, "Fail to sqlite3_get_table : %s\n", sqlite3_errmsg(db));
    ret = EXIT_FAILURE;
    goto exit;
  }
  while (1) {
    clientfd = accept(sockfd, (struct sockaddr *)&peer_addr, &addrlen);
    if (-1 == clientfd) {
      perror("Fail to accept.");
      ret = EXIT_FAILURE;
      break;
    }
    pid = fork();
    if (pid < 0) {
      ret = EXIT_FAILURE;
      break;
    }
    if (0 == pid) {
      do_client(clientfd, db);
    }
  }
exit:
  sqlite3_close(db);
  close(sockfd);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xc,-0x44(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1286 <main+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd8d(%rip),%rdi
call   1060 <printf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x2d3a(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2d0c(%rip),%rcx
cmp    (%rcx),%rax
jne    12c7 <main+0x97>
lea    0xd63(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x1c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x1c(%rbp),%eax
jne    130b <main+0xdb>
lea    0xd2e(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1388 <main+0x158>
lea    0xcc1(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    13c0 <main+0x190>
lea    0xc97(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xc8d(%rip),%rdi
lea    -0x58(%rbp),%rsi
call   1040 <sqlite3_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2c03(%rip),%rcx
cmp    (%rcx),%eax
je     141d <main+0x1ed>
mov    0x2bd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%rdi
call   1080 <sqlite3_errmsg@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xc55(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2b95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    14a9 <main+0x279>
jmp    1422 <main+0x1f2>
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x20(%rbp)
mov    $0xffffffff,%eax
cmp    -0x20(%rbp),%eax
jne    1460 <main+0x230>
lea    0xc32(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    14a4 <main+0x274>
mov    $0x0,%al
call   1140 <fork@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jge    1487 <main+0x257>
mov    0x2b2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    14a4 <main+0x274>
xor    %eax,%eax
cmp    -0x50(%rbp),%rax
jne    149f <main+0x26f>
mov    -0x20(%rbp),%edi
mov    -0x58(%rbp),%rsi
call   1030 <do_client@plt>
jmp    1422 <main+0x1f2>
jmp    14a9 <main+0x279>
mov    -0x58(%rbp),%rdi
call   10c0 <sqlite3_close@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
movl   $0xc,0xc(%rsp)
cmp    $0x2,%edi
jle    13db <main+0x1ab>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2d44(%rip),%rcx
cmp    (%rcx),%rax
je     13ec <main+0x1bc>
mov    0x2d6c(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
cmp    $0xffffffff,%eax
je     13f5 <main+0x1c5>
mov    %eax,%r15d
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x20(%rsp)
mov    0x10(%r14),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,0x1c(%rsp)
mov    0x8(%r14),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x18(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
je     13fe <main+0x1ce>
mov    %r15d,%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
je     1407 <main+0x1d7>
lea    0xd49(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <sqlite3_open@plt>
mov    0x2cc4(%rip),%rcx
cmp    (%rcx),%eax
jne    1381 <main+0x151>
lea    0x28(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r15d,%edi
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
je     13cd <main+0x19d>
mov    %eax,%ebx
lea    0x28(%rsp),%r14
lea    0xc(%rsp),%rbp
jmp    1365 <main+0x135>
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1110 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     13cd <main+0x19d>
xor    %eax,%eax
call   1140 <fork@plt>
test   %rax,%rax
js     13a5 <main+0x175>
jne    1350 <main+0x120>
mov    0x10(%rsp),%rsi
mov    %ebx,%edi
call   1030 <do_client@plt>
jmp    1350 <main+0x120>
mov    0x2c38(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   1080 <sqlite3_errmsg@plt>
lea    0xcc1(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10b0 <fprintf@plt>
mov    0x2bfc(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rsp),%rdi
call   10c0 <sqlite3_close@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca8(%rip),%rdi
call   10f0 <perror@plt>
jmp    13a5 <main+0x175>
mov    (%r14),%rsi
lea    0xc1b(%rip),%rdi
call   1060 <printf@plt>
jmp    1413 <main+0x1e3>
lea    0xc24(%rip),%rdi
jmp    140e <main+0x1de>
lea    0xc2a(%rip),%rdi
jmp    140e <main+0x1de>
lea    0xc31(%rip),%rdi
jmp    140e <main+0x1de>
lea    0xc36(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s <ip> <port>\0A\00"
@EXIT_FAILURE = global i32 0
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
@.str.1 = [15 x i8] c"Fail to signal\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [16 x i8] c"Fail to socket.\00"
@.str.3 = [14 x i8] c"Fail to bind.\00"
@.str.4 = [16 x i8] c"Fail to listen.\00"
@.str.5 = [8 x i8] c"dict.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.6 = [32 x i8] c"Fail to sqlite3_get_table : %s\0A\00"
@.str.7 = [16 x i8] c"Fail to accept.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 12, i32* %12
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = load i32, i32* @SIGCHLD
%26 = load i32, i32* @SIG_IGN
%27 = call i64 @signal(i32 %25, i32 %26)
%28 = load i64, i64* @SIG_ERR
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %24
%35 = load i32, i32* @AF_INET
%36 = load i32, i32* @SOCK_STREAM
%37 = call i32 @socket(i32 %35, i32 %36, i32 0)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp eq i32 -1, %38
br i1 %39, label %40, label %44
40: ; preds = %34
%41 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %34
%45 = call i32 @bzero(%struct.sockaddr_in* %10, i32 12)
%46 = load i32, i32* @AF_INET
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %46, i32* %47
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
%52 = call i32 @htons(i32 %51)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %52, i32* %53
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @inet_addr(i8* %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
store i32 %57, i32* %59
%60 = load i32, i32* %8
%61 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%62 = call i32 @bind(i32 %60, %struct.sockaddr* %61, i32 12)
store i32 %62, i32* %6
%63 = load i32, i32* %6
%64 = icmp eq i32 -1, %63
br i1 %64, label %65, label %69
65: ; preds = %44
%66 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %44
%70 = load i32, i32* %8
%71 = call i32 @listen(i32 %70, i32 10)
store i32 %71, i32* %6
%72 = load i32, i32* %6
%73 = icmp eq i32 -1, %72
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %69
%79 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32** %14)
store i32 %79, i32* %6
%80 = load i32, i32* %6
%81 = load i32, i32* @SQLITE_OK
%82 = icmp ne i32 %80, %81
br i1 %82, label %83, label %89
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = load i32*, i32** %14
%86 = call i8* @sqlite3_errmsg(i32* %85)
%87 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %86)
%88 = load i32, i32* @EXIT_FAILURE
store i32 %88, i32* %6
br label %114
89: ; preds = %78
br label %90
90: ; preds = %89, %112
%91 = load i32, i32* %8
%92 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%93 = call i32 @accept(i32 %91, %struct.sockaddr* %92, i32* %12)
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = icmp eq i32 -1, %94
br i1 %95, label %96, label %99
96: ; preds = %90
%97 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%98 = load i32, i32* @EXIT_FAILURE
store i32 %98, i32* %6
br label %113
99: ; preds = %90
%100 = call i64 (...) @fork()
store i64 %100, i64* %13
%101 = load i64, i64* %13
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %99
%104 = load i32, i32* @EXIT_FAILURE
store i32 %104, i32* %6
br label %113
105: ; preds = %99
%106 = load i64, i64* %13
%107 = icmp eq i64 0, %106
br i1 %107, label %108, label %112
108: ; preds = %105
%109 = load i32, i32* %9
%110 = load i32*, i32** %14
%111 = call i32 @do_client(i32 %109, i32* %110)
br label %112
112: ; preds = %108, %105
br label %90
113: ; preds = %103, %96
br label %114
114: ; preds = %113, %83
%115 = load i32*, i32** %14
%116 = call i32 @sqlite3_close(i32* %115)
%117 = load i32, i32* %8
%118 = call i32 @close(i32 %117)
%119 = load i32, i32* %6
ret i32 %119
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s <ip> <port>\0A\00"
@EXIT_FAILURE = global i32 0
@SIGCHLD = global i32 0
@SIG_IGN = global i32 0
@SIG_ERR = global i64 0
@.str.1 = [15 x i8] c"Fail to signal\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [16 x i8] c"Fail to socket.\00"
@.str.3 = [14 x i8] c"Fail to bind.\00"
@.str.4 = [16 x i8] c"Fail to listen.\00"
@.str.5 = [8 x i8] c"dict.db\00"
@SQLITE_OK = global i32 0
@stderr = global i32 0
@.str.6 = [32 x i8] c"Fail to sqlite3_get_table : %s\0A\00"
@.str.7 = [16 x i8] c"Fail to accept.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32*
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
store i32 12, i32* %5
%10 = bitcast i32** %6 to i8*
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* @SIGCHLD
%19 = load i32, i32* @SIG_IGN
%20 = tail call i64 @signal(i32 %18, i32 %19)
%21 = load i64, i64* @SIG_ERR
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = tail call i32 @exit(i32 %25)
unreachable
27: ; preds = %17
%28 = load i32, i32* @AF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = tail call i32 @socket(i32 %28, i32 %29, i32 0)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %27
%37 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %38, i32* %39
%40 = getelementptr inbounds i8*, i8** %1, i64 2
%41 = load i8*, i8** %40
%42 = tail call i32 @atoi(i8* %41)
%43 = tail call i32 @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %43, i32* %44
%45 = getelementptr inbounds i8*, i8** %1, i64 1
%46 = load i8*, i8** %45
%47 = tail call i32 @inet_addr(i8* %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %47, i32* %48
%49 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%50 = call i32 @bind(i32 %30, %struct.sockaddr* %49, i32 12)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %56
52: ; preds = %36
%53 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %36
%57 = call i32 @listen(i32 %30, i32 10)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %63
59: ; preds = %56
%60 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %56
%64 = call i32 @sqlite3_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32** %6)
%65 = load i32, i32* @SQLITE_OK
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%69 = call i32 @accept(i32 %30, %struct.sockaddr* %68, i32* %5)
%70 = icmp eq i32 %69, -1
br i1 %70, label %76, label %78
71: ; preds = %63
%72 = load i32, i32* @stderr
%73 = load i32*, i32** %6
%74 = call i8* @sqlite3_errmsg(i32* %73)
%75 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %74)
br label %90
76: ; preds = %87, %67
%77 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %90
78: ; preds = %67, %87
%79 = phi i32 [ %88, %87 ], [ %69, %67 ]
%80 = call i64 (...) @fork()
%81 = icmp slt i64 %80, 0
br i1 %81, label %90, label %82
82: ; preds = %78
%83 = icmp eq i64 %80, 0
br i1 %83, label %84, label %87
84: ; preds = %82
%85 = load i32*, i32** %6
%86 = call i32 @do_client(i32 %79, i32* %85)
br label %87
87: ; preds = %84, %82
%88 = call i32 @accept(i32 %30, %struct.sockaddr* %68, i32* %5)
%89 = icmp eq i32 %88, -1
br i1 %89, label %76, label %78
90: ; preds = %78, %76, %71
%91 = load i32, i32* @EXIT_FAILURE
%92 = load i32*, i32** %6
%93 = call i32 @sqlite3_close(i32* %92)
%94 = call i32 @close(i32 %30)
ret i32 %91
}