#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sa;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ addrstr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
scalar_t__ bind(int, struct sockaddr *, int);
scalar_t__ close(int);
int /*<<< orphan*/ execv(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, TYPE_1__ *, char *, int);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, scalar_t__);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  char buf[100];
  char addrstr[INET_ADDRSTRLEN];
  int sd, newsd;
  pid_t p;
  socklen_t len;
  struct sockaddr_in sa;
  p = fork();
  if (p < 0) {
    perror("fork");
    exit(1);
  }
  if (p == 0)
    execv("riddle", NULL);
  signal(SIGPIPE, SIG_IGN);
  if ((sd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    exit(1);
  }
  fprintf(stderr, "Created TCP socket\n");
  memset(&sa, 0, sizeof(sa));
  sa.sin_family = AF_INET;
  sa.sin_port = htons(49842);
  sa.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(sd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
    perror("bind");
    exit(1);
  }
  fprintf(stderr, "Bound TCP socket to port %d\n", 49842);
  if (listen(sd, 5) < 0) {
    perror("listen");
    exit(1);
  }
  for (;;) {
    fprintf(stderr, "Waiting for an incoming connection...\n");
    len = sizeof(struct sockaddr_in);
    if ((newsd = accept(sd, (struct sockaddr *)&sa, &len)) < 0) {
      perror("accept");
      exit(1);
    }
    if (!inet_ntop(AF_INET, &sa.sin_addr, addrstr, sizeof(addrstr))) {
      perror("could not format IP address");
      exit(1);
    }
    fprintf(stderr, "Incoming connection from %s:%d\n", addrstr,
            ntohs(sa.sin_port));
    p++;
    snprintf(buf, 100, "%d", p);
    write(newsd, buf, 100);
    if (close(newsd) < 0)
      perror("close");
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xb0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x80(%rbp)
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
jge    129a <main+0x7a>
lea    0xd75(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpq   $0x0,-0x90(%rbp)
jne    12b8 <main+0x98>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1120 <execv@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x84(%rbp)
cmp    $0x0,%eax
jge    130d <main+0xed>
lea    0xd0e(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    $0xc2b2,%edi
call   1050 <htons@plt>
mov    %eax,-0xa0(%rbp)
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x9c(%rbp)
mov    -0x84(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    13a1 <main+0x181>
lea    0xc95(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
lea    0xc7b(%rip),%rsi
mov    $0xc2b2,%edx
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x84(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
jge    13ed <main+0x1cd>
lea    0xc6b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    13f2 <main+0x1d2>
mov    0x2bcf(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0xc,-0x94(%rbp)
mov    -0x84(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0x94(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x88(%rbp)
cmp    $0x0,%eax
jge    1451 <main+0x231>
lea    0xc35(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0xa8(%rbp),%rdx
mov    -0xb0(%rbp),%rax
mov    0x2b82(%rip),%rcx
mov    (%rcx),%edi
lea    -0xa0(%rbp),%rsi
add    $0x4,%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%eax
jne    1499 <main+0x279>
lea    0xbf4(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2b28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xa0(%rbp),%edi
call   10d0 <ntohs@plt>
mov    -0xb4(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    %eax,%ecx
lea    0xbd1(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x90(%rbp),%rcx
mov    $0x64,%esi
lea    0xbc1(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x88(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1040 <write@plt>
mov    -0x88(%rbp),%edi
call   1090 <close@plt>
cmp    $0x0,%rax
jge    1533 <main+0x313>
lea    0xb8f(%rip),%rdi
call   10f0 <perror@plt>
jmp    13f2 <main+0x1d2>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0x2d75(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r15
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
xor    %eax,%eax
call   1130 <fork@plt>
test   %rax,%rax
jns    1266 <main+0x46>
lea    0xd9f(%rip),%rdi
jmp    149d <main+0x27d>
mov    %rax,%r14
jne    1279 <main+0x59>
lea    0xd93(%rip),%rdi
xor    %esi,%esi
call   1120 <execv@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    0x2d4f(%rip),%rax
mov    (%rax),%esi
call   10a0 <signal@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
test   %eax,%eax
jns    12b9 <main+0x99>
lea    0xd58(%rip),%rdi
jmp    149d <main+0x27d>
mov    %eax,%r13d
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
lea    0xd47(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    -0x38(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    $0xc2b2,%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x34(%rbp)
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
jns    1331 <main+0x111>
lea    0xcfb(%rip),%rdi
jmp    149d <main+0x27d>
mov    0x2c90(%rip),%r12
mov    (%r12),%edi
lea    0xce9(%rip),%rsi
mov    $0xc2b2,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r13d,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
test   %rax,%rax
jns    136d <main+0x14d>
lea    0xce1(%rip),%rdi
jmp    149d <main+0x27d>
mov    (%r12),%edi
lea    0xcd8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movl   $0xc,-0x2c(%rbp)
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    %r13d,-0x3c(%rbp)
mov    %r13d,%edi
call   1100 <accept@plt>
test   %eax,%eax
jns    13aa <main+0x18a>
lea    0xcd2(%rip),%rdi
jmp    149d <main+0x27d>
mov    %eax,%r13d
add    $0x1,%r14
mov    %rbx,-0x48(%rbp)
jmp    1400 <main+0x1e0>
nopw   0x0(%rax,%rax,1)
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
lea    0xc80(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movl   $0xc,-0x2c(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,%r13d
add    $0x1,%r14
test   %eax,%eax
mov    -0x48(%rbp),%rbx
mov    %r12,%r15
js     139e <main+0x17e>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    -0x34(%rbp),%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1030 <inet_ntop@plt>
test   %eax,%eax
je     1496 <main+0x276>
mov    0x2ba6(%rip),%rax
mov    (%rax),%r12d
mov    -0x38(%rbp),%edi
call   10d0 <ntohs@plt>
mov    %r12d,%edi
lea    0xc63(%rip),%rsi
mov    %r15,%r12
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    -0xb0(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
lea    0xc5e(%rip),%rdx
mov    %r14,%rcx
call   1060 <snprintf@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1040 <write@plt>
mov    %r13d,%edi
call   1090 <close@plt>
test   %rax,%rax
jns    13c0 <main+0x1a0>
lea    0xc31(%rip),%rdi
call   10f0 <perror@plt>
jmp    13c0 <main+0x1a0>
lea    0xbe1(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str = [5 x i8] c"fork\00"
@.str.1 = [7 x i8] c"riddle\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"Created TCP socket\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [29 x i8] c"Bound TCP socket to port %d\0A\00"
@.str.6 = [7 x i8] c"listen\00"
@.str.7 = [39 x i8] c"Waiting for an incoming connection...\0A\00"
@.str.8 = [7 x i8] c"accept\00"
@.str.9 = [28 x i8] c"could not format IP address\00"
@.str.10 = [32 x i8] c"Incoming connection from %s:%d\0A\00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [6 x i8] c"close\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
store i32 0, i32* %1
%10 = load i32, i32* @INET_ADDRSTRLEN
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca i8, i64 %11
store i64 %11, i64* %4
%14 = call i64 (...) @fork()
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %0
%21 = load i64, i64* %7
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @execv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %25
25: ; preds = %23, %20
%26 = load i32, i32* @SIGPIPE
%27 = load i32, i32* @SIG_IGN
%28 = call i32 @signal(i32 %26, i32 %27)
%29 = load i32, i32* @PF_INET
%30 = load i32, i32* @SOCK_STREAM
%31 = call i32 @socket(i32 %29, i32 %30, i32 0)
store i32 %31, i32* %5
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %40, i32* %41
%42 = call i32 @htons(i32 49842)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %42, i32* %43
%44 = load i32, i32* @INADDR_ANY
%45 = call i32 @htonl(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 0
store i32 %45, i32* %47
%48 = load i32, i32* %5
%49 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%50 = call i64 @bind(i32 %48, %struct.sockaddr* %49, i32 12)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %36
%53 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %36
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 49842)
%58 = load i32, i32* %5
%59 = call i64 @listen(i32 %58, i32 5)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %55
br label %65
65: ; preds = %103, %64
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
store i32 12, i32* %8
%68 = load i32, i32* %5
%69 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%70 = call i32 @accept(i32 %68, %struct.sockaddr* %69, i32* %8)
store i32 %70, i32* %6
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %65
%76 = load i32, i32* @AF_INET
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%78 = trunc i64 %11 to i32
%79 = call i32 @inet_ntop(i32 %76, %struct.TYPE_2__* %77, i8* %13, i32 %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %84, label %81
81: ; preds = %75
%82 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %75
%85 = load i32, i32* @stderr
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%87 = load i32, i32* %86
%88 = call i32 @ntohs(i32 %87)
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %13, i32 %88)
%90 = load i64, i64* %7
%91 = add nsw i64 %90, 1
store i64 %91, i64* %7
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%93 = load i64, i64* %7
%94 = call i32 @snprintf(i8* %92, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 %93)
%95 = load i32, i32* %6
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%97 = call i32 @write(i32 %95, i8* %96, i32 100)
%98 = load i32, i32* %6
%99 = call i64 @close(i32 %98)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %84
%102 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %103
103: ; preds = %101, %84
br label %65
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str = [5 x i8] c"fork\00"
@.str.1 = [7 x i8] c"riddle\00"
@SIGPIPE = global i32 0
@SIG_IGN = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"Created TCP socket\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [29 x i8] c"Bound TCP socket to port %d\0A\00"
@.str.6 = [7 x i8] c"listen\00"
@.str.7 = [39 x i8] c"Waiting for an incoming connection...\0A\00"
@.str.8 = [7 x i8] c"accept\00"
@.str.9 = [28 x i8] c"could not format IP address\00"
@.str.10 = [32 x i8] c"Incoming connection from %s:%d\0A\00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [6 x i8] c"close\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @INET_ADDRSTRLEN
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i32* %2 to i8*
%9 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = tail call i64 (...) @fork()
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = icmp eq i64 %10, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @execv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* @SIGPIPE
%21 = load i32, i32* @SIG_IGN
%22 = tail call i32 @signal(i32 %20, i32 %21)
%23 = load i32, i32* @PF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = tail call i32 @socket(i32 %23, i32 %24, i32 0)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %34, i32* %35
%36 = call i32 @htons(i32 49842)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %36, i32* %37
%38 = load i32, i32* @INADDR_ANY
%39 = call i32 @htonl(i32 %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %40, i64 0, i32 0
store i32 %39, i32* %41
%42 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%43 = call i64 @bind(i32 %25, %struct.sockaddr* %42, i32 12)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %30
%46 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %30
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 49842)
%51 = call i64 @listen(i32 %25, i32 5)
%52 = icmp slt i64 %51, 0
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
store i32 12, i32* %2
%56 = call i32 @accept(i32 %25, %struct.sockaddr* %42, i32* %2)
%57 = icmp slt i32 %56, 0
br i1 %57, label %61, label %64
58: ; preds = %48
%59 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %85, %53
%62 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %53, %85
%65 = phi i32 [ %88, %85 ], [ %56, %53 ]
%66 = phi i64 [ %78, %85 ], [ %10, %53 ]
%67 = load i32, i32* @AF_INET
%68 = call i32 @inet_ntop(i32 %67, %struct.TYPE_2__* %40, i8* %7, i32 %5)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %64
%71 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %64
%74 = load i32, i32* @stderr
%75 = load i32, i32* %37
%76 = call i32 @ntohs(i32 %75)
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %7, i32 %76)
%78 = add nsw i64 %66, 1
%79 = call i32 @snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 %78)
%80 = call i32 @write(i32 %65, i8* %4, i32 100)
%81 = call i64 @close(i32 %65)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %73
%84 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %85
85: ; preds = %83, %73
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
store i32 12, i32* %2
%88 = call i32 @accept(i32 %25, %struct.sockaddr* %42, i32* %2)
%89 = icmp slt i32 %88, 0
br i1 %89, label %61, label %64
}