#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
char getopt(int, char **, char *);
int master_loop(char *, int);
char *optarg;
int /*<<< orphan*/ printf(char *, scalar_t__, ...);
scalar_t__ setsid();
int /*<<< orphan*/ srv_init();
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int srv_loop_ret;
  char c;
  char *addr = NULL;
  int port = -1;
  pid_t pid, sid;
  printf("Start $ man bomber server version %d.%d\n", 0, 1);
  while ((c = getopt(argc, argv, "b:p:")) != -1) {
    switch (c) {
    case 'b':
      addr = optarg;
      break;
    case 'p':
      port = atoi(optarg);
      break;
    case '?':
      usage();
      return 1;
    default:
      abort();
    }
  }
  pid = fork();
  if (pid == 0) {
    umask(0);
    srv_init();
    sid = setsid();
    srv_loop_ret = master_loop(addr, port);
    exit(srv_loop_ret);
  } else {
    printf("Server started as pid: %d\n", pid);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
lea    0xe24(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe2f(%rip),%rdx
call   1090 <getopt@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     128d <main+0xdd>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     126f <main+0xbf>
jmp    1223 <main+0x73>
mov    -0x3c(%rbp),%eax
sub    $0x62,%eax
je     1245 <main+0x95>
jmp    1234 <main+0x84>
mov    -0x3c(%rbp),%eax
sub    $0x70,%eax
je     1258 <main+0xa8>
jmp    1281 <main+0xd1>
mov    0x2dac(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <main+0xd8>
mov    0x2d99(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1288 <main+0xd8>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11ec <main+0x3c>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12d3 <main+0x123>
xor    %edi,%edi
call   1070 <umask@plt>
mov    $0x0,%al
call   10d0 <srv_init@plt>
mov    $0x0,%al
call   1060 <setsid@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <master_loop@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%rsi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe39(%rip),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1090 <getopt@plt>
mov    $0xffffffff,%r15d
cmp    $0xff,%al
je     1260 <main+0xb0>
xor    %r14d,%r14d
mov    0x2dfb(%rip),%r13
lea    0xe25(%rip),%r12
jmp    1225 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
cmp    $0xff,%al
je     1260 <main+0xb0>
movsbl %al,%eax
cmp    $0x62,%eax
je     1210 <main+0x60>
cmp    $0x70,%eax
jne    1240 <main+0x90>
mov    0x0(%r13),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r15d
jmp    1214 <main+0x64>
cmp    $0x3f,%eax
jne    1293 <main+0xe3>
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
jne    129a <main+0xea>
xor    %edi,%edi
call   1070 <umask@plt>
xor    %eax,%eax
call   10d0 <srv_init@plt>
xor    %eax,%eax
call   1060 <setsid@plt>
mov    %r14,%rdi
mov    %r15d,%esi
call   1050 <master_loop@plt>
mov    %eax,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xd8d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Start $ man bomber server version %d.%d\0A\00"
@.str.1 = [5 x i8] c"b:p:\00"
@optarg = global i8* null
@.str.2 = [27 x i8] c"Server started as pid: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
store i32 -1, i32* %9
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 0, i32 1)
br label %13
13: ; preds = %31, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call signext i8 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 %16, i8* %7
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %32
19: ; preds = %13
%20 = load i8, i8* %7
%21 = sext i8 %20 to i32
switch i32 %21, label %29 [
i32 98, label %22
i32 112, label %24
i32 63, label %27
]
22: ; preds = %19
%23 = load i8*, i8** @optarg
store i8* %23, i8** %8
br label %31
24: ; preds = %19
%25 = load i8*, i8** @optarg
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %9
br label %31
27: ; preds = %19
%28 = call i32 (...) @usage()
ret i32 1
29: ; preds = %19
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %24, %22
br label %13
32: ; preds = %13
%33 = call i64 (...) @fork()
store i64 %33, i64* %10
%34 = load i64, i64* %10
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = call i32 @umask(i32 0)
%38 = call i32 (...) @srv_init()
%39 = call i64 (...) @setsid()
store i64 %39, i64* %11
%40 = load i8*, i8** %8
%41 = load i32, i32* %9
%42 = call i32 @master_loop(i8* %40, i32 %41)
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %32
%46 = load i64, i64* %10
%47 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %46)
%48 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [41 x i8] c"Start $ man bomber server version %d.%d\0A\00"
@.str.1 = [5 x i8] c"b:p:\00"
@optarg = global i8* null
@.str.2 = [27 x i8] c"Server started as pid: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i64 0, i32 1)
%4 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8 %4, -1
br i1 %5, label %25, label %6
6: ; preds = %2, %20
%7 = phi i8 [ %23, %20 ], [ %4, %2 ]
%8 = phi i8* [ %22, %20 ], [ null, %2 ]
%9 = phi i32 [ %21, %20 ], [ -1, %2 ]
%10 = sext i8 %7 to i32
switch i32 %10, label %18 [
i32 98, label %11
i32 112, label %13
i32 63, label %16
]
11: ; preds = %6
%12 = load i8*, i8** @optarg
br label %20
13: ; preds = %6
%14 = load i8*, i8** @optarg
%15 = tail call i32 @atoi(i8* %14)
br label %20
16: ; preds = %6
%17 = tail call i32 (...) @usage()
ret i32 1
18: ; preds = %6
%19 = tail call i32 (...) @abort()
unreachable
20: ; preds = %13, %11
%21 = phi i32 [ %15, %13 ], [ %9, %11 ]
%22 = phi i8* [ %8, %13 ], [ %12, %11 ]
%23 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i8 %23, -1
br i1 %24, label %25, label %6
25: ; preds = %20, %2
%26 = phi i32 [ -1, %2 ], [ %21, %20 ]
%27 = phi i8* [ null, %2 ], [ %22, %20 ]
%28 = tail call i64 (...) @fork()
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = tail call i32 @umask(i32 0)
%32 = tail call i32 (...) @srv_init()
%33 = tail call i64 (...) @setsid()
%34 = tail call i32 @master_loop(i8* %27, i32 %26)
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %25
%37 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %28)
%38 = tail call i32 @exit(i32 0)
unreachable
}