#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 s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_addr;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EADDRNOTAVAIL;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fork();
struct hostent *gethostbyname(char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ hexdump(char *, int);
int /*<<< orphan*/ htons(int);
int inet_addr(char *);
char *inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ memcpy(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
char *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void stub1();
int main(int argc, char **argv) {
  char *addr = "0.0.0.0";
  int port = 1234;
  int c, s;
  int debug = 0, verbose = 0;
  struct sockaddr_in sin;
  struct hostent *he;
  while ((c = getopt(argc, argv, "a:dp:v")) != -1) {
    switch (c) {
    case 'a':
      addr = optarg;
      break;
    case 'd':
      debug = 1;
      break;
    case 'p':
      port = atoi(optarg);
      break;
    case 'v':
      verbose = 1;
    }
  }
  if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket");
    exit(EXIT_FAILURE);
  }
  memset(&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_port = htons(port);
  if ((sin.sin_addr.s_addr = inet_addr(addr)) == -1) {
    if ((he = gethostbyname(addr)) == NULL) {
      errno = EADDRNOTAVAIL;
      perror("gethostbyname");
      exit(EXIT_FAILURE);
    }
    memcpy(&sin.sin_addr.s_addr, he->h_addr, 4);
  }
  if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
    perror("bind");
    exit(EXIT_FAILURE);
  }
  if (listen(s, 5) == -1) {
    perror("listen");
    exit(EXIT_FAILURE);
  }
  if (debug || verbose)
    printf("listening on %s:%d\n", addr, port);
  while (1) {
    int tmp;
    struct sockaddr_in sin;
    socklen_t sin_len = sizeof(sin);
    if ((tmp = accept(s, (struct sockaddr *)&sin, &sin_len)) == -1) {
      perror("accept");
      exit(EXIT_FAILURE);
    }
    if (debug || verbose)
      printf("accepted connection from %s:%d\n", inet_ntoa(sin.sin_addr),
             ntohs(sin.sin_port));
    if (!fork()) {
      int count;
      char buf[1024];
      count = recv(tmp, buf, sizeof(buf), 0);
      if (debug)
        hexdump(buf, count);
      if (debug || verbose)
        printf("%d bytes received\n", count);
      sleep(2);
      (*(void (*)())buf)();
      exit(EXIT_SUCCESS);
    }
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdf8(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4d2,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdd9(%rip),%rdx
call   1100 <getopt@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
je     1309 <main+0xc9>
mov    -0x20(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x468(%rbp)
sub    $0x15,%eax
ja     1304 <main+0xc4>
mov    -0x468(%rbp),%rax
lea    0xd42(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d2a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1304 <main+0xc4>
movl   $0x1,-0x28(%rbp)
jmp    1304 <main+0xc4>
mov    0x2d0b(%rip),%rax
mov    (%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1304 <main+0xc4>
movl   $0x1,-0x2c(%rbp)
jmp    1279 <main+0x39>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1348 <main+0x108>
lea    0xd32(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <inet_addr@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    13df <main+0x19f>
mov    -0x18(%rbp),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    13c7 <main+0x187>
mov    0x2c36(%rip),%rax
mov    (%rax),%ecx
mov    0x2c15(%rip),%rax
mov    %ecx,(%rax)
lea    0xcba(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    -0x38(%rbp),%rdi
add    $0x4,%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1413 <main+0x1d3>
lea    0xc7c(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    -0x24(%rbp),%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1443 <main+0x203>
lea    0xc51(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b7c(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1457 <main+0x217>
cmpl   $0x0,-0x2c(%rbp)
je     146c <main+0x22c>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1471 <main+0x231>
movl   $0xc,-0x54(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   1110 <accept@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
jne    14ae <main+0x26e>
lea    0xc01(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b11(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpl   $0x0,-0x28(%rbp)
jne    14c2 <main+0x282>
cmpl   $0x0,-0x2c(%rbp)
je     14f0 <main+0x2b0>
mov    -0x4c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x470(%rbp)
mov    -0x50(%rbp),%edi
call   10d0 <ntohs@plt>
mov    -0x470(%rbp),%rsi
mov    %eax,%edx
lea    0xbba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1150 <fork@plt>
cmp    $0x0,%eax
jne    157a <main+0x33a>
mov    -0x44(%rbp),%edi
lea    -0x460(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1532 <main+0x2f2>
lea    -0x460(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   10b0 <hexdump@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1546 <main+0x306>
cmpl   $0x0,-0x2c(%rbp)
je     1557 <main+0x317>
mov    -0x58(%rbp),%esi
lea    0xb73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   1140 <sleep@plt>
lea    -0x460(%rbp),%rcx
mov    $0x0,%al
call   *%rcx
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
jmp    1471 <main+0x231>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdfb(%rip),%rax
mov    %rax,0x28(%rsp)
mov    $0x4d2,%r13d
movl   $0x0,0x14(%rsp)
lea    0xde9(%rip),%r14
lea    0xd82(%rip),%r15
mov    0x2d73(%rip),%r12
movl   $0x0,0xc(%rsp)
jmp    1295 <main+0x55>
nop
cmp    $0xffffffff,%eax
je     12de <main+0x9e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1100 <getopt@plt>
lea    -0x61(%rax),%ecx
cmp    $0x15,%ecx
ja     1290 <main+0x50>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%rax
mov    %rax,0x28(%rsp)
jmp    1295 <main+0x55>
movl   $0x1,0xc(%rsp)
jmp    1295 <main+0x55>
mov    (%r12),%rdi
call   1120 <atoi@plt>
mov    %eax,%r13d
jmp    1295 <main+0x55>
mov    $0x1,%al
mov    %eax,0x14(%rsp)
jmp    1295 <main+0x55>
mov    0x2cfb(%rip),%rbx
mov    (%rbx),%edi
mov    0x2cda(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
cmp    $0xffffffff,%eax
jne    1308 <main+0xc8>
lea    0xd64(%rip),%rdi
jmp    147d <main+0x23d>
mov    %eax,%r15d
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x20(%rsp)
mov    %r13d,%edi
call   1050 <htons@plt>
mov    %eax,0x18(%rsp)
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <inet_addr@plt>
mov    %eax,0x1c(%rsp)
cmp    $0xffffffff,%eax
jne    1380 <main+0x140>
mov    %rbx,%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    136f <main+0x12f>
mov    0x2c80(%rip),%rax
mov    (%rax),%eax
mov    0x2c5f(%rip),%rcx
mov    %eax,(%rcx)
lea    0xd04(%rip),%rdi
jmp    147d <main+0x23d>
lea    0x1c(%rsp),%rdi
mov    (%rax),%esi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
lea    0x18(%rsp),%rsi
mov    %r15d,%ebp
mov    %r15d,%edi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    13a6 <main+0x166>
lea    0xcdb(%rip),%rdi
jmp    147d <main+0x23d>
mov    %ebp,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    13c3 <main+0x183>
lea    0xcc3(%rip),%rdi
jmp    147d <main+0x23d>
cmpl   $0x0,0xc(%rsp)
setne  %r14b
or     0x14(%rsp),%r14b
test   $0x1,%r14b
je     13eb <main+0x1ab>
lea    0xcaa(%rip),%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0xc,0x10(%rsp)
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r15d,%r13d
mov    %r15d,%edi
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
je     1476 <main+0x236>
mov    %eax,%ebx
lea    0x30(%rsp),%r12
lea    0x10(%rsp),%r15
nopl   0x0(%rax)
test   $0x1,%r14b
je     144e <main+0x20e>
mov    0x34(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rbp
mov    0x30(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xc61(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1150 <fork@plt>
test   %eax,%eax
je     1490 <main+0x250>
movl   $0xc,0x10(%rsp)
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1110 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1420 <main+0x1e0>
lea    0xc1f(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b2f(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0x40(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebx
cmpl   $0x0,0xc(%rsp)
je     14bb <main+0x27b>
lea    0x40(%rsp),%rdi
mov    %ebx,%esi
call   10b0 <hexdump@plt>
test   $0x1,%r14b
je     14d1 <main+0x291>
lea    0xbfb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%edi
call   1140 <sleep@plt>
xor    %eax,%eax
call   *%rbp
mov    0x2aca(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"0.0.0.0\00"
@.str.1 = [7 x i8] c"a:dp:v\00"
@optarg = global i8* null
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@EXIT_FAILURE = global i32 0
@EADDRNOTAVAIL = global i32 0
@errno = global i32 0
@.str.3 = [14 x i8] c"gethostbyname\00"
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [20 x i8] c"listening on %s:%d\0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [32 x i8] c"accepted connection from %s:%d\0A\00"
@.str.9 = [19 x i8] c"%d bytes received\0A\00"
@EXIT_SUCCESS = global i32 0
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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_in
%13 = alloca %struct.hostent*
%14 = alloca i32
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
%17 = alloca i32
%18 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 1234, i32* %7
store i32 0, i32* %10
store i32 0, i32* %11
br label %19
19: ; preds = %33, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %22, i32* %8
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i32, i32* %8
switch i32 %25, label %33 [
i32 97, label %26
i32 100, label %28
i32 112, label %29
i32 118, label %32
]
26: ; preds = %24
%27 = load i8*, i8** @optarg
store i8* %27, i8** %6
br label %33
28: ; preds = %24
store i32 1, i32* %10
br label %33
29: ; preds = %24
%30 = load i8*, i8** @optarg
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %7
br label %33
32: ; preds = %24
store i32 1, i32* %11
br label %33
33: ; preds = %32, %24, %29, %28, %26
br label %19
34: ; preds = %19
%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* %9
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %34
%44 = call i32 @memset(%struct.sockaddr_in* %12, i32 0, i32 12)
%45 = load i32, i32* @AF_INET
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %45, i32* %46
%47 = load i32, i32* %7
%48 = call i32 @htons(i32 %47)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i32 %48, i32* %49
%50 = load i8*, i8** %6
%51 = call i32 @inet_addr(i8* %50)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%53 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %52, i32 0, i32 0
store i32 %51, i32* %53
%54 = icmp eq i32 %51, -1
br i1 %54, label %55, label %71
55: ; preds = %43
%56 = load i8*, i8** %6
%57 = call %struct.hostent* @gethostbyname(i8* %56)
store %struct.hostent* %57, %struct.hostent** %13
%58 = icmp eq %struct.hostent* %57, null
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = load i32, i32* @EADDRNOTAVAIL
store i32 %60, i32* @errno
%61 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %55
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i32 0, i32 0
%67 = load %struct.hostent*, %struct.hostent** %13
%68 = getelementptr inbounds %struct.hostent, %struct.hostent* %67, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 @memcpy(i32* %66, i32 %69, i32 4)
br label %71
71: ; preds = %64, %43
%72 = load i32, i32* %9
%73 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%74 = call i32 @bind(i32 %72, %struct.sockaddr* %73, i32 12)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %71
%81 = load i32, i32* %9
%82 = call i32 @listen(i32 %81, i32 5)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %80
%89 = load i32, i32* %10
%90 = icmp ne i32 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %88
%92 = load i32, i32* %11
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %98
94: ; preds = %91, %88
%95 = load i8*, i8** %6
%96 = load i32, i32* %7
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %95, i32 %96)
br label %98
98: ; preds = %94, %91
br label %99
99: ; preds = %98, %151
store i32 12, i32* %16
%100 = load i32, i32* %9
%101 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%102 = call i32 @accept(i32 %100, %struct.sockaddr* %101, i32* %16)
store i32 %102, i32* %14
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %108
104: ; preds = %99
%105 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%106 = load i32, i32* @EXIT_FAILURE
%107 = call i32 @exit(i32 %106)
unreachable
108: ; preds = %99
%109 = load i32, i32* %10
%110 = icmp ne i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %108
%112 = load i32, i32* %11
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %123
114: ; preds = %111, %108
%115 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%116 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %115, i32 0, i32 0
%117 = load i32, i32* %116
%118 = call i8* @inet_ntoa(i32 %117)
%119 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%120 = load i32, i32* %119
%121 = call i32 @ntohs(i32 %120)
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %118, i32 %121)
br label %123
123: ; preds = %114, %111
%124 = call i32 (...) @fork()
%125 = icmp ne i32 %124, 0
br i1 %125, label %151, label %126
126: ; preds = %123
%127 = load i32, i32* %14
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%129 = call i32 @recv(i32 %127, i8* %128, i32 1024, i32 0)
store i32 %129, i32* %17
%130 = load i32, i32* %10
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %136
132: ; preds = %126
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%134 = load i32, i32* %17
%135 = call i32 @hexdump(i8* %133, i32 %134)
br label %136
136: ; preds = %132, %126
%137 = load i32, i32* %10
%138 = icmp ne i32 %137, 0
br i1 %138, label %142, label %139
139: ; preds = %136
%140 = load i32, i32* %11
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %145
142: ; preds = %139, %136
%143 = load i32, i32* %17
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %143)
br label %145
145: ; preds = %142, %139
%146 = call i32 @sleep(i32 2)
%147 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%148 = bitcast i8* %147 to void (...)*
%149 = load i32, i32* @EXIT_SUCCESS
%150 = call i32 @exit(i32 %149)
unreachable
151: ; preds = %123
br label %99
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"0.0.0.0\00"
@.str.1 = [7 x i8] c"a:dp:v\00"
@optarg = global i8* null
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@EXIT_FAILURE = global i32 0
@EADDRNOTAVAIL = global i32 0
@errno = global i32 0
@.str.3 = [14 x i8] c"gethostbyname\00"
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [20 x i8] c"listening on %s:%d\0A\00"
@.str.7 = [7 x i8] c"accept\00"
@.str.8 = [32 x i8] c"accepted connection from %s:%d\0A\00"
@.str.9 = [19 x i8] c"%d bytes received\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
br label %8
8: ; preds = %22, %2
%9 = phi i1 [ false, %2 ], [ true, %22 ]
%10 = phi i32 [ 0, %2 ], [ %14, %22 ]
%11 = phi i32 [ 1234, %2 ], [ %18, %22 ]
%12 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ], [ %21, %22 ]
br label %13
13: ; preds = %22, %8
%14 = phi i32 [ %10, %8 ], [ 1, %22 ]
%15 = phi i32 [ %11, %8 ], [ %18, %22 ]
%16 = phi i8* [ %12, %8 ], [ %21, %22 ]
br label %17
17: ; preds = %13, %26
%18 = phi i32 [ %15, %13 ], [ %28, %26 ]
%19 = phi i8* [ %16, %13 ], [ %21, %26 ]
br label %20
20: ; preds = %17, %24
%21 = phi i8* [ %19, %17 ], [ %25, %24 ]
br label %22
22: ; preds = %20, %22
%23 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
switch i32 %23, label %22 [
i32 -1, label %29
i32 97, label %24
i32 100, label %13
i32 112, label %26
i32 118, label %8
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
br label %20
26: ; preds = %22
%27 = load i8*, i8** @optarg
%28 = tail call i32 @atoi(i8* %27)
br label %17
29: ; preds = %22
%30 = load i32, i32* @AF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = tail call i32 @socket(i32 %30, i32 %31, i32 0)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %29
%39 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %40, i32* %41
%42 = call i32 @htons(i32 %18)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %42, i32* %43
%44 = call i32 @inet_addr(i8* %21)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %44, i32* %45
%46 = icmp eq i32 %44, -1
br i1 %46, label %47, label %59
47: ; preds = %38
%48 = call %struct.hostent* @gethostbyname(i8* %21)
%49 = icmp eq %struct.hostent* %48, null
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load i32, i32* @EADDRNOTAVAIL
store i32 %51, i32* @errno
%52 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %47
%56 = getelementptr inbounds %struct.hostent, %struct.hostent* %48, i64 0, i32 0
%57 = load i32, i32* %56
%58 = call i32 @memcpy(i32* %45, i32 %57, i32 4)
br label %59
59: ; preds = %55, %38
%60 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%61 = call i32 @bind(i32 %32, %struct.sockaddr* %60, i32 12)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %59
%68 = call i32 @listen(i32 %32, i32 5)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %67
%75 = icmp ne i32 %14, 0
%76 = or i1 %75, %9
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %21, i32 %18)
br label %79
79: ; preds = %74, %77
%80 = bitcast %struct.sockaddr_in* %4 to i8*
%81 = bitcast i32* %5 to i8*
%82 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 12, i32* %5
%83 = call i32 @accept(i32 %32, %struct.sockaddr* %82, i32* %5)
%84 = icmp eq i32 %83, -1
br i1 %84, label %88, label %85
85: ; preds = %79
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%87 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
br label %92
88: ; preds = %116, %79
%89 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %85, %116
%93 = phi i32 [ %83, %85 ], [ %117, %116 ]
br i1 %76, label %94, label %100
94: ; preds = %92
%95 = load i32, i32* %86
%96 = call i8* @inet_ntoa(i32 %95)
%97 = load i32, i32* %87
%98 = call i32 @ntohs(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %96, i32 %98)
br label %100
100: ; preds = %92, %94
%101 = call i32 (...) @fork()
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %116
103: ; preds = %100
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%105 = call i32 @recv(i32 %93, i8* %104, i32 1024, i32 0)
br i1 %75, label %106, label %108
106: ; preds = %103
%107 = call i32 @hexdump(i8* %104, i32 %105)
br label %108
108: ; preds = %106, %103
br i1 %76, label %109, label %111
109: ; preds = %108
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %105)
br label %111
111: ; preds = %108, %109
%112 = call i32 @sleep(i32 2)
%113 = bitcast [1024 x i8]* %6 to void (...)*
%114 = load i32, i32* @EXIT_SUCCESS
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %100
store i32 12, i32* %5
%117 = call i32 @accept(i32 %32, %struct.sockaddr* %82, i32* %5)
%118 = icmp eq i32 %117, -1
br i1 %118, label %88, label %92
}