#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char const *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ setup(int, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  static const char *help = "[-dhp]";
  int port;
  char *path;
  int ch;
  port = 8080;
  path = "/var/www";
  while ((ch = getopt(argc, argv, "d:hp:")) != -1) {
    switch (ch) {
    case 'd':
      path = optarg;
      break;
    case 'h':
      fprintf(stderr, "%s: %s\n", argv[0], help);
      return 0;
    case 'p':
      port = atoi(optarg);
      break;
    default:
      break;
    }
    if (ch == '?')
      return 1;
  }
  setup(port, path);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1f90,-0x14(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1236 <main+0xf6>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x64,%eax
je     11bd <main+0x7d>
jmp    119b <main+0x5b>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
je     11d0 <main+0x90>
jmp    11ac <main+0x6c>
mov    -0x28(%rbp),%eax
sub    $0x70,%eax
je     11ff <main+0xbf>
jmp    1216 <main+0xd6>
mov    0x2e34(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    121b <main+0xdb>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2e59(%rip),%rcx
lea    0xe28(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1249 <main+0x109>
mov    0x2df2(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    121b <main+0xdb>
jmp    121b <main+0xdb>
cmpl   $0x3f,-0x24(%rbp)
jne    1231 <main+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1249 <main+0x109>
jmp    1168 <main+0x28>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <setup@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xeb0(%rip),%r14
mov    $0x1f90,%r12d
lea    0xeac(%rip),%r15
jmp    118c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x70,%ebx
jne    11b1 <main+0x71>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
cmp    $0x3f,%ebx
je     11ca <main+0x8a>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <getopt@plt>
mov    %eax,%ebx
cmp    $0x67,%eax
jg     1170 <main+0x30>
cmp    $0x64,%ebx
jne    11b8 <main+0x78>
mov    0x2e4c(%rip),%rax
mov    (%rax),%r14
jmp    1187 <main+0x47>
cmp    $0x68,%ebx
jne    1187 <main+0x47>
jmp    11d1 <main+0x91>
cmp    $0xffffffff,%ebx
jne    1187 <main+0x47>
mov    %r12d,%edi
mov    %r14,%rsi
call   1060 <setup@plt>
jmp    11f1 <main+0xb1>
mov    $0x1,%eax
jmp    11f3 <main+0xb3>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xe31(%rip),%rsi
lea    0xe14(%rip),%rcx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.help = internal global i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0)
@.str = [7 x i8] c"[-dhp]\00"
@.str.1 = [9 x i8] c"/var/www\00"
@.str.2 = [6 x i8] c"d:hp:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.3 = [8 x i8] c"%s: %s\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8080, i32* %6
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 %12, i32* %8
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load i32, i32* %8
switch i32 %15, label %28 [
i32 100, label %16
i32 104, label %18
i32 112, label %25
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %7
br label %29
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = load i8*, i8** @main.help
%24 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %23)
store i32 0, i32* %3
br label %38
25: ; preds = %14
%26 = load i8*, i8** @optarg
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %6
br label %29
28: ; preds = %14
br label %29
29: ; preds = %28, %25, %16
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 63
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 1, i32* %3
br label %38
33: ; preds = %29
br label %9
34: ; preds = %9
%35 = load i32, i32* %6
%36 = load i8*, i8** %7
%37 = call i32 @setup(i32 %35, i8* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %34, %32, %18
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [7 x i8] c"[-dhp]\00"
@.str.1 = [9 x i8] c"/var/www\00"
@.str.2 = [6 x i8] c"d:hp:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.3 = [8 x i8] c"%s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %16, %2
%4 = phi i32 [ 8080, %2 ], [ %17, %16 ]
%5 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ], [ %18, %16 ]
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
switch i32 %6, label %16 [
i32 -1, label %20
i32 100, label %7
i32 104, label %9
i32 112, label %13
]
7: ; preds = %3
%8 = load i8*, i8** @optarg
br label %16
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %22
13: ; preds = %3
%14 = load i8*, i8** @optarg
%15 = tail call i32 @atoi(i8* %14)
br label %16
16: ; preds = %3, %13, %7
%17 = phi i32 [ %15, %13 ], [ %4, %7 ], [ %4, %3 ]
%18 = phi i8* [ %5, %13 ], [ %8, %7 ], [ %5, %3 ]
%19 = icmp eq i32 %6, 63
br i1 %19, label %22, label %3
20: ; preds = %3
%21 = tail call i32 @setup(i32 %4, i8* %5)
br label %22
22: ; preds = %16, %20, %9
%23 = phi i32 [ 0, %9 ], [ 0, %20 ], [ 1, %16 ]
ret i32 %23
}