#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 /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ member_0;
};
struct sockaddr {
  int dummy;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int EXIT_FAILURE;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ forward_data(int, int);
int getopt_long(int, char **, char *, struct option *, int *);
char *inet_ntoa(int /*<<< orphan*/);
int init_network_connection(int);
int /*<<< orphan*/ no_argument;
int open(char *, int);
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ required_argument;
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int main(int argc, char **argv) {
  opterr = 0;
  int option_index;
  int chr;
  char serial_node[30] = "\0";
  int network_port;
  int show_help = 0;
  int modem_fd = 0, socket_fd = 0;
  struct option opts[] = {
      {"node", required_argument, 0, 'n'},
      {"port", required_argument, 0, 'p'},
      {"help", no_argument, 0, 'h'},
  };
  while (1) {
    option_index = 0;
    chr = getopt_long(argc, argv, "n:p:h", opts, &option_index);
    if (chr == -1)
      break;
    switch (chr) {
    case 'h':
      show_help = 1;
      break;
    case 'n':
      snprintf(serial_node, 30, "%s", optarg);
      break;
    case 'p':
      network_port = atoi(optarg);
      break;
    default:
      break;
    }
  }
  if (show_help || network_port == 0 || serial_node[0] == 0) {
    printf("usage: samsung_ipc_forward -n <device node> -p <network port>\n");
    exit(1);
  }
  socket_fd = init_network_connection(network_port);
  if (socket_fd < 0)
    return EXIT_FAILURE;
  modem_fd = open(serial_node, O_RDWR | O_NOCTTY | O_NONBLOCK);
  int connection_fd = -1;
  struct sockaddr_in addr = {
      0,
  };
  socklen_t length = sizeof(addr);
  while ((connection_fd =
              accept(socket_fd, (struct sockaddr *)&addr, &length)) >= 0) {
    printf("New connection from: '%s'\n", inet_ntoa(addr.sin_addr));
    forward_data(modem_fd, connection_fd);
    close(connection_fd);
  }
  close(modem_fd);
  close(socket_fd);
  return 0;
socket_init_failed:
  close(socket_fd);
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc8(%rip),%rax
movq   $0x0,(%rax)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1070 <memset@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
lea    0xded(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x98(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x6e,-0x90(%rbp)
lea    0xdc1(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x80(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x70,-0x78(%rbp)
lea    0xd9e(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x68,-0x60(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0xa0(%rbp),%rcx
lea    0xd69(%rip),%rdx
lea    -0x14(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    12c1 <main+0x101>
jmp    1351 <main+0x191>
mov    -0x18(%rbp),%eax
mov    %eax,-0xb8(%rbp)
sub    $0x68,%eax
je     1300 <main+0x140>
jmp    12d8 <main+0x118>
mov    -0xb8(%rbp),%eax
sub    $0x6e,%eax
je     130c <main+0x14c>
jmp    12ec <main+0x12c>
mov    -0xb8(%rbp),%eax
sub    $0x70,%eax
je     1330 <main+0x170>
jmp    1347 <main+0x187>
movl   $0x1,-0x48(%rbp)
jmp    134c <main+0x18c>
lea    -0x40(%rbp),%rdi
mov    0x2ce1(%rip),%rax
mov    (%rax),%rcx
mov    $0x1e,%esi
lea    0xcef(%rip),%rdx
call   1060 <snprintf@plt>
jmp    134c <main+0x18c>
mov    0x2cc1(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x44(%rbp)
jmp    134c <main+0x18c>
jmp    134c <main+0x18c>
jmp    128a <main+0xca>
cmpl   $0x0,-0x48(%rbp)
jne    1372 <main+0x1b2>
cmpl   $0x0,-0x44(%rbp)
je     1372 <main+0x1b2>
movsbl -0x40(%rbp),%eax
cmp    $0x0,%eax
jne    138a <main+0x1ca>
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x44(%rbp),%edi
call   1090 <init_network_connection@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    13b0 <main+0x1f0>
mov    0x2c0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <main+0x2b4>
lea    -0x40(%rbp),%rdi
mov    0x2c25(%rip),%rax
mov    (%rax),%esi
mov    0x2bfc(%rip),%rax
or     (%rax),%esi
mov    0x2c0b(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x4c(%rbp)
movl   $0xffffffff,-0xa4(%rbp)
ff ff ff
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
movl   $0x8,-0xb4(%rbp)
mov    -0x50(%rbp),%edi
lea    -0xb0(%rbp),%rsi
lea    -0xb4(%rbp),%rdx
call   10b0 <accept@plt>
mov    %eax,-0xa4(%rbp)
cmp    $0x0,%eax
jl     145d <main+0x29d>
mov    -0xb0(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4c(%rbp),%edi
mov    -0xa4(%rbp),%esi
call   10e0 <forward_data@plt>
mov    -0xa4(%rbp),%edi
call   1080 <close@plt>
jmp    13fe <main+0x23e>
mov    -0x4c(%rbp),%edi
call   1080 <close@plt>
mov    -0x50(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2dcb(%rip),%rax
movq   $0x0,(%rax)
xorps  %xmm0,%xmm0
movups %xmm0,0x2e(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xe08(%rip),%rax
mov    %rax,0x40(%rsp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%al
mov    %al,0x48(%rsp)
movabs $0x6e00000000,%rcx
mov    %rcx,0x4c(%rsp)
lea    0xde5(%rip),%rcx
mov    %rcx,0x58(%rsp)
mov    %al,0x60(%rsp)
movabs $0x7000000000,%rax
mov    %rax,0x64(%rsp)
lea    0xdcb(%rip),%rax
mov    %rax,0x70(%rsp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%al
mov    %al,0x78(%rsp)
movabs $0x6800000000,%rax
mov    %rax,0x7c(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xda0(%rip),%r15
lea    0x40(%rsp),%r12
lea    0x1c(%rsp),%r13
lea    0x20(%rsp),%r14
jmp    129e <main+0xde>
mov    0x2d71(%rip),%rax
mov    (%rax),%rcx
mov    %r14,%rdi
mov    $0x1e,%esi
lea    0xd7c(%rip),%rdx
call   1070 <snprintf@plt>
movl   $0x0,0x1c(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <getopt_long@plt>
cmp    $0x6d,%eax
jle    12e0 <main+0x120>
cmp    $0x6e,%eax
je     1280 <main+0xc0>
cmp    $0x70,%eax
jne    129e <main+0xde>
mov    0x2d29(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,0x18(%rsp)
jmp    129e <main+0xde>
nopl   (%rax)
cmp    $0xffffffff,%eax
je     12f4 <main+0x134>
cmp    $0x68,%eax
jne    129e <main+0xde>
movl   $0x1,0x8(%rsp)
jmp    129e <main+0xde>
cmpl   $0x0,0x8(%rsp)
mov    0x18(%rsp),%edi
jne    13f8 <main+0x238>
test   %edi,%edi
je     13f8 <main+0x238>
cmpb   $0x0,0x20(%rsp)
je     13f8 <main+0x238>
call   1090 <init_network_connection@plt>
test   %eax,%eax
js     13dd <main+0x21d>
mov    %eax,%r13d
mov    0x2cb3(%rip),%rax
mov    0x2c8c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2c99(%rip),%rax
or     (%rax),%esi
lea    0x20(%rsp),%rdi
call   10a0 <open@plt>
mov    %eax,%ebp
movq   $0x0,0x10(%rsp)
movl   $0x8,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r13d,%edi
call   10b0 <accept@plt>
test   %eax,%eax
js     13ca <main+0x20a>
mov    %eax,%ebx
lea    0xc9b(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   10e0 <forward_data@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   10b0 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1390 <main+0x1d0>
mov    %ebp,%edi
call   1080 <close@plt>
mov    %r13d,%edi
call   1080 <close@plt>
xor    %eax,%eax
jmp    13e6 <main+0x226>
mov    0x2bcc(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc34(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@opterr = global i64 0
@.str = [5 x i8] c"node\00"
@required_argument = global i32 0
@.str.1 = [5 x i8] c"port\00"
@.str.2 = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.3 = [6 x i8] c"n:p:h\00"
@.str.4 = [3 x i8] c"%s\00"
@optarg = global i8* null
@.str.5 = [63 x i8] c"usage: samsung_ipc_forward -n <device node> -p <network port>\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.6 = [27 x i8] c"New connection from: '%s'\0A\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 [30 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [3 x %struct.option]
%14 = alloca i32
%15 = alloca %struct.sockaddr_in
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* @opterr
%17 = bitcast [30 x i8]* %8 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%18 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %13, i64 0, i64 0
%19 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 1
%21 = load i32, i32* @required_argument
%22 = trunc i32 %21 to i8
store i8 %22, i8* %20
%23 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 2
store i32 0, i32* %23
%24 = getelementptr inbounds %struct.option, %struct.option* %18, i32 0, i32 3
store i32 110, i32* %24
%25 = getelementptr inbounds %struct.option, %struct.option* %18, i64 1
%26 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 1
%28 = load i32, i32* @required_argument
%29 = trunc i32 %28 to i8
store i8 %29, i8* %27
%30 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 2
store i32 0, i32* %30
%31 = getelementptr inbounds %struct.option, %struct.option* %25, i32 0, i32 3
store i32 112, i32* %31
%32 = getelementptr inbounds %struct.option, %struct.option* %25, i64 1
%33 = getelementptr inbounds %struct.option, %struct.option* %32, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %33
%34 = getelementptr inbounds %struct.option, %struct.option* %32, i32 0, i32 1
%35 = load i32, i32* @no_argument
%36 = trunc i32 %35 to i8
store i8 %36, i8* %34
%37 = getelementptr inbounds %struct.option, %struct.option* %32, i32 0, i32 2
store i32 0, i32* %37
%38 = getelementptr inbounds %struct.option, %struct.option* %32, i32 0, i32 3
store i32 104, i32* %38
br label %39
39: ; preds = %2, %58
store i32 0, i32* %6
%40 = load i32, i32* %4
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %13, i64 0, i64 0
%43 = call i32 @getopt_long(i32 %40, i8** %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %42, i32* %6)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %47
46: ; preds = %39
br label %59
47: ; preds = %39
%48 = load i32, i32* %7
switch i32 %48, label %57 [
i32 104, label %49
i32 110, label %50
i32 112, label %54
]
49: ; preds = %47
store i32 1, i32* %10
br label %58
50: ; preds = %47
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%52 = load i8*, i8** @optarg
%53 = call i32 @snprintf(i8* %51, i32 30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %58
54: ; preds = %47
%55 = load i8*, i8** @optarg
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %9
br label %58
57: ; preds = %47
br label %58
58: ; preds = %57, %54, %50, %49
br label %39
59: ; preds = %46
%60 = load i32, i32* %10
%61 = icmp ne i32 %60, 0
br i1 %61, label %70, label %62
62: ; preds = %59
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %62
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %65, %62, %59
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %65
%74 = load i32, i32* %9
%75 = call i32 @init_network_connection(i32 %74)
store i32 %75, i32* %12
%76 = load i32, i32* %12
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = load i32, i32* @EXIT_FAILURE
store i32 %79, i32* %3
br label %113
80: ; preds = %73
%81 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%82 = load i32, i32* @O_RDWR
%83 = load i32, i32* @O_NOCTTY
%84 = or i32 %82, %83
%85 = load i32, i32* @O_NONBLOCK
%86 = or i32 %84, %85
%87 = call i32 @open(i8* %81, i32 %86)
store i32 %87, i32* %11
store i32 -1, i32* %14
%88 = bitcast %struct.sockaddr_in* %15 to i8*
store i32 8, i32* %16
br label %89
89: ; preds = %94, %80
%90 = load i32, i32* %12
%91 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%92 = call i32 @accept(i32 %90, %struct.sockaddr* %91, i32* %16)
store i32 %92, i32* %14
%93 = icmp sge i32 %92, 0
br i1 %93, label %94, label %104
94: ; preds = %89
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%96 = load i32, i32* %95
%97 = call i8* @inet_ntoa(i32 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %97)
%99 = load i32, i32* %11
%100 = load i32, i32* %14
%101 = call i32 @forward_data(i32 %99, i32 %100)
%102 = load i32, i32* %14
%103 = call i32 @close(i32 %102)
br label %89
104: ; preds = %89
%105 = load i32, i32* %11
%106 = call i32 @close(i32 %105)
%107 = load i32, i32* %12
%108 = call i32 @close(i32 %107)
store i32 0, i32* %3
br label %113
109: ; No predecessors!
%110 = load i32, i32* %12
%111 = call i32 @close(i32 %110)
%112 = load i32, i32* @EXIT_FAILURE
store i32 %112, i32* %3
br label %113
113: ; preds = %109, %104, %78
%114 = load i32, i32* %3
ret i32 %114
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.sockaddr = type { i32 }
@opterr = global i64 0
@.str = [5 x i8] c"node\00"
@required_argument = global i32 0
@.str.1 = [5 x i8] c"port\00"
@.str.2 = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.3 = [6 x i8] c"n:p:h\00"
@.str.4 = [3 x i8] c"%s\00"
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.6 = [27 x i8] c"New connection from: '%s'\0A\00"
@str = [62 x i8] c"usage: samsung_ipc_forward -n <device node> -p <network port>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [30 x i8]
%5 = alloca [3 x %struct.option]
%6 = alloca i64
%7 = alloca i32
store i64 0, i64* @opterr
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%10 = bitcast [3 x %struct.option]* %5 to i8*
%11 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 0
%12 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 0, i32 1
%14 = load i32, i32* @required_argument
%15 = trunc i32 %14 to i8
store i8 %15, i8* %13
%16 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 0, i32 2
store i32 0, i32* %16
%17 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 0, i32 3
store i32 110, i32* %17
%18 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 1, i32 1
store i8 %15, i8* %19
%20 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 1, i32 2
store i32 0, i32* %20
%21 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 1, i32 3
store i32 112, i32* %21
%22 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 2, i32 1
%24 = load i32, i32* @no_argument
%25 = trunc i32 %24 to i8
store i8 %25, i8* %23
%26 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 2, i32 2
store i32 0, i32* %26
%27 = getelementptr inbounds [3 x %struct.option], [3 x %struct.option]* %5, i64 0, i64 2, i32 3
store i32 104, i32* %27
br label %28
28: ; preds = %39, %2
%29 = phi i32 [ %41, %39 ], [ undef, %2 ]
%30 = phi i32 [ %32, %39 ], [ 0, %2 ]
br label %31
31: ; preds = %33, %28
%32 = phi i32 [ %30, %28 ], [ 1, %33 ]
br label %33
33: ; preds = %35, %31
store i32 0, i32* %3
%34 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %11, i32* %3)
switch i32 %34, label %35 [
i32 -1, label %42
i32 104, label %31
i32 110, label %36
i32 112, label %39
]
35: ; preds = %33, %36
br label %33
36: ; preds = %33
%37 = load i8*, i8** @optarg
%38 = call i32 @snprintf(i8* %9, i32 30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %35
39: ; preds = %33
%40 = load i8*, i8** @optarg
%41 = call i32 @atoi(i8* %40)
br label %28
42: ; preds = %33
%43 = icmp ne i32 %32, 0
%44 = icmp eq i32 %29, 0
%45 = select i1 %43, i1 true, i1 %44
%46 = load i8, i8* %9
%47 = icmp eq i8 %46, 0
%48 = select i1 %45, i1 true, i1 %47
br i1 %48, label %49, label %52
49: ; preds = %42
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %42
%53 = call i32 @init_network_connection(i32 %29)
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = load i32, i32* @EXIT_FAILURE
br label %83
57: ; preds = %52
%58 = load i32, i32* @O_RDWR
%59 = load i32, i32* @O_NOCTTY
%60 = or i32 %59, %58
%61 = load i32, i32* @O_NONBLOCK
%62 = or i32 %60, %61
%63 = call i32 @open(i8* %9, i32 %62)
%64 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%65 = bitcast i32* %7 to i8*
store i32 8, i32* %7
%66 = bitcast i64* %6 to %struct.sockaddr*
%67 = call i32 @accept(i32 %53, %struct.sockaddr* %66, i32* %7)
%68 = icmp sgt i32 %67, -1
br i1 %68, label %69, label %80
69: ; preds = %57
%70 = bitcast i64* %6 to i32*
br label %71
71: ; preds = %69, %71
%72 = phi i32 [ %67, %69 ], [ %78, %71 ]
%73 = load i32, i32* %70
%74 = call i8* @inet_ntoa(i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %74)
%76 = call i32 @forward_data(i32 %63, i32 %72)
%77 = call i32 @close(i32 %72)
%78 = call i32 @accept(i32 %53, %struct.sockaddr* %66, i32* %7)
%79 = icmp sgt i32 %78, -1
br i1 %79, label %71, label %80
80: ; preds = %71, %57
%81 = call i32 @close(i32 %63)
%82 = call i32 @close(i32 %53)
br label %83
83: ; preds = %80, %55
%84 = phi i32 [ %56, %55 ], [ 0, %80 ]
ret i32 %84
}