#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 sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ datasize;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int htons(int);
int /*<<< orphan*/ inet_aton(char *, int /*<<< orphan*/ *);
char *inet_ntoa(int /*<<< orphan*/);
int listen(int, int);
int ntohs(int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  char *ip_address = argv[1];
  int port = atoi(argv[2]);
  int sock;
  struct sockaddr_in server_addr;
  printf("Starting alrien simple key value store...\n");
  printf("IP ADDRESS: %s\n", ip_address);
  printf("PORT: %d\n", port);
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock == -1) {
    printf("Error opening socket: -1\n");
    exit(1);
  }
  server_addr.sin_port = htons(port);
  inet_aton(ip_address, &server_addr.sin_addr);
  server_addr.sin_family = AF_INET;
  if (bind(sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) {
    printf("Error binding socket to port & ip_address: %d, %s\n", port,
           ip_address);
    exit(1);
  }
  if (listen(sock, 50) == -1) {
    printf("Error listing on port & ip_address: %d, %s\n", port, ip_address);
  }
  while (1) {
    printf("Checking if connections are coming in ...\n");
    int session, datasize, r, w;
    char buffer[7];
    struct sockaddr_in client_addr;
    socklen_t client_addr_size;
    bzero(buffer, 7);
    client_addr_size = sizeof(struct sockaddr_in);
    session = accept(sock, (struct sockaddr *)&client_addr, &client_addr_size);
    if (session == -1) {
      printf("Connection failed or no connections!");
      continue;
    }
    printf("Accepting connection from %s:%d\n", inet_ntoa(client_addr.sin_addr),
           ntohs(client_addr.sin_port));
    read(session, &datasize, sizeof(datasize));
    r = read(session, buffer, 7);
    if (r < 0) {
      printf("Failed to read from socket!");
      continue;
    }
    printf("Here is the message: %s, %d\n", buffer, ntohs(datasize));
    w = write(session, "I got your message", 18);
    if (w < 0) {
      printf("Failed to write to socket!");
      continue;
    }
    close(session);
  }
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1291 <main+0xa1>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
call   1090 <inet_aton@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12f2 <main+0x102>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x20(%rbp),%edi
mov    $0x32,%esi
call   10a0 <listen@plt>
cmp    $0xffffffff,%eax
jne    131d <main+0x12d>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1322 <main+0x132>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x47(%rbp),%rdi
mov    $0x7,%esi
call   10d0 <bzero@plt>
movl   $0xc,-0x5c(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x58(%rbp),%rsi
lea    -0x5c(%rbp),%rdx
call   10e0 <accept@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1375 <main+0x185>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1322 <main+0x132>
mov    -0x54(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    -0x34(%rbp),%edi
lea    -0x47(%rbp),%rsi
mov    $0x7,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    13e3 <main+0x1f3>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1322 <main+0x132>
lea    -0x47(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%edi
call   10b0 <ntohs@plt>
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%edi
lea    0xd57(%rip),%rsi
mov    $0x12,%edx
call   1030 <write@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    143b <main+0x24b>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1322 <main+0x132>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
jmp    1322 <main+0x132>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebx
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xdd0(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d97(%rip),%r15
mov    (%r15),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
je     13d8 <main+0x1d8>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   10a0 <inet_aton@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
je     13ee <main+0x1ee>
mov    %ebp,%edi
mov    $0x32,%esi
call   10b0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12cc <main+0xcc>
lea    0xd8d(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x31(%rsp),%rbx
lea    0x20(%rsp),%r15
lea    0x8(%rsp),%r12
jmp    12ee <main+0xee>
nopl   (%rax)
lea    0xd92(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   10e0 <bzero@plt>
movl   $0xc,0x8(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   10f0 <accept@plt>
cmp    $0xffffffff,%eax
je     12e0 <main+0xe0>
mov    %eax,%r13d
mov    0x24(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r14
mov    0x20(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xd5e(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x4,%edx
mov    %r13d,%edi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1090 <read@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x7,%edx
xor    %eax,%eax
call   1090 <read@plt>
test   %eax,%eax
js     13c0 <main+0x1c0>
mov    0xc(%rsp),%edi
call   10c0 <ntohs@plt>
lea    0xd55(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
lea    0xd5c(%rip),%rsi
mov    $0x12,%edx
call   1040 <write@plt>
test   %eax,%eax
js     13cc <main+0x1cc>
mov    %r13d,%edi
call   1080 <close@plt>
jmp    12ee <main+0xee>
nopw   0x0(%rax,%rax,1)
lea    0xcf8(%rip),%rdi
jmp    12e7 <main+0xe7>
lea    0xd38(%rip),%rdi
jmp    12e7 <main+0xe7>
lea    0xd9b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xc25(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [43 x i8] c"Starting alrien simple key value store...\0A\00"
@.str.1 = [16 x i8] c"IP ADDRESS: %s\0A\00"
@.str.2 = [10 x i8] c"PORT: %d\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [26 x i8] c"Error opening socket: -1\0A\00"
@.str.4 = [51 x i8] c"Error binding socket to port & ip_address: %d, %s\0A\00"
@.str.5 = [44 x i8] c"Error listing on port & ip_address: %d, %s\0A\00"
@.str.6 = [43 x i8] c"Checking if connections are coming in ...\0A\00"
@.str.7 = [37 x i8] c"Connection failed or no connections!\00"
@.str.8 = [33 x i8] c"Accepting connection from %s:%d\0A\00"
@.str.9 = [28 x i8] c"Failed to read from socket!\00"
@.str.10 = [29 x i8] c"Here is the message: %s, %d\0A\00"
@.str.11 = [19 x i8] c"I got your message\00"
@.str.12 = [27 x i8] c"Failed to write to socket!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [7 x i8]
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @AF_INET
%30 = load i32, i32* @SOCK_STREAM
%31 = call i32 @socket(i32 %29, i32 %30, i32 0)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
%38 = load i32, i32* %7
%39 = call i32 @htons(i32 %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %39, i32* %40
%41 = load i8*, i8** %6
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%43 = call i32 @inet_aton(i8* %41, i32* %42)
%44 = load i32, i32* @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %44, i32* %45
%46 = load i32, i32* %8
%47 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%48 = call i32 @bind(i32 %46, %struct.sockaddr* %47, i32 12)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %55
50: ; preds = %37
%51 = load i32, i32* %7
%52 = load i8*, i8** %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %51, i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %37
%56 = load i32, i32* %8
%57 = call i32 @listen(i32 %56, i32 50)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* %7
%61 = load i8*, i8** %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %60, i8* %61)
br label %63
63: ; preds = %59, %55
br label %64
64: ; preds = %63, %73, %90, %101, %103
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%66 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 0
%67 = call i32 @bzero(i8* %66, i32 7)
store i32 12, i32* %16
%68 = load i32, i32* %8
%69 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%70 = call i32 @accept(i32 %68, %struct.sockaddr* %69, i32* %16)
store i32 %70, i32* %10
%71 = load i32, i32* %10
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %64
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %64
75: ; preds = %64
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%77 = load i32, i32* %76
%78 = call i8* @inet_ntoa(i32 %77)
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%80 = load i32, i32* %79
%81 = call i32 @ntohs(i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %78, i32 %81)
%83 = load i32, i32* %10
%84 = call i32 (i32, ...) @read(i32 %83, i32* %11, i64 4)
%85 = load i32, i32* %10
%86 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 0
%87 = call i32 (i32, ...) @read(i32 %85, i8* %86, i32 7)
store i32 %87, i32* %12
%88 = load i32, i32* %12
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %75
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %64
92: ; preds = %75
%93 = getelementptr inbounds [7 x i8], [7 x i8]* %14, i64 0, i64 0
%94 = load i32, i32* %11
%95 = call i32 @ntohs(i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %93, i32 %95)
%97 = load i32, i32* %10
%98 = call i32 @write(i32 %97, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32 18)
store i32 %98, i32* %13
%99 = load i32, i32* %13
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %92
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
br label %64
103: ; preds = %92
%104 = load i32, i32* %10
%105 = call i32 @close(i32 %104)
br label %64
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str.1 = [16 x i8] c"IP ADDRESS: %s\0A\00"
@.str.2 = [10 x i8] c"PORT: %d\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [51 x i8] c"Error binding socket to port & ip_address: %d, %s\0A\00"
@.str.5 = [44 x i8] c"Error listing on port & ip_address: %d, %s\0A\00"
@.str.7 = [37 x i8] c"Connection failed or no connections!\00"
@.str.8 = [33 x i8] c"Accepting connection from %s:%d\0A\00"
@.str.9 = [28 x i8] c"Failed to read from socket!\00"
@.str.10 = [29 x i8] c"Here is the message: %s, %d\0A\00"
@.str.11 = [19 x i8] c"I got your message\00"
@.str.12 = [27 x i8] c"Failed to write to socket!\00"
@str = [42 x i8] c"Starting alrien simple key value store...\00"
@str.13 = [42 x i8] c"Checking if connections are coming in ...\00"
@str.14 = [25 x i8] c"Error opening socket: -1\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [7 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = bitcast %struct.sockaddr_in* %3 to i8*
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.14, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = tail call i32 @htons(i32 %12)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%28 = call i32 @inet_aton(i8* %9, i32* %27)
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %29, i32* %30
%31 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%32 = call i32 @bind(i32 %19, %struct.sockaddr* %31, i32 12)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %24
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %12, i8* %9)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %24
%38 = call i32 @listen(i32 %19, i32 50)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %12, i8* %9)
br label %42
42: ; preds = %40, %37
%43 = bitcast i32* %4 to i8*
%44 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%45 = bitcast %struct.sockaddr_in* %6 to i8*
%46 = bitcast i32* %7 to i8*
%47 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
br label %50
50: ; preds = %78, %42
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.13, i64 0, i64 0))
%52 = call i32 @bzero(i8* %44, i32 7)
store i32 12, i32* %7
%53 = call i32 @accept(i32 %19, %struct.sockaddr* %47, i32* %7)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %78
57: ; preds = %50
%58 = load i32, i32* %48
%59 = call i8* @inet_ntoa(i32 %58)
%60 = load i32, i32* %49
%61 = call i32 @ntohs(i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %59, i32 %61)
%63 = call i32 (i32, ...) @read(i32 %53, i32* %4, i64 4)
%64 = call i32 (i32, ...) @read(i32 %53, i8* %44, i32 7)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %57
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %78
68: ; preds = %57
%69 = load i32, i32* %4
%70 = call i32 @ntohs(i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %44, i32 %70)
%72 = call i32 @write(i32 %53, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32 18)
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %68
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
br label %78
76: ; preds = %68
%77 = call i32 @close(i32 %53)
br label %78
78: ; preds = %76, %74, %66, %55
br label %50
}