#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 *);
int getopt(int, char **, char *);
char *optarg;
int server(int, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int opt;
  int port = 5001;
  char *path = "./";
  while ((opt = getopt(argc, argv, "l:s:")) != -1) {
    switch (opt) {
    case 'l':
      port = atoi(optarg);
      break;
    case 's':
      path = optarg;
      break;
    default:
      fprintf(stderr, "Usage: %s [-l port] [-s path]\n", argv[0]);
      return 1;
    }
  }
  return server(port, path);
}


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   $0x1389,-0x18(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1203 <main+0xc3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x6c,%eax
je     11ac <main+0x6c>
jmp    119b <main+0x5b>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
je     11c3 <main+0x83>
jmp    11d6 <main+0x96>
mov    0x2e45(%rip),%rax
mov    (%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11fe <main+0xbe>
mov    0x2e2e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11fe <main+0xbe>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe1b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1212 <main+0xd2>
jmp    1168 <main+0x28>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <server@plt>
mov    %eax,-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,%rbx
mov    %edi,%ebp
lea    0xea9(%rip),%r14
mov    $0x1389,%r12d
lea    0xe9f(%rip),%r15
mov    0x2e8d(%rip),%r13
jmp    1174 <main+0x34>
nopl   (%rax)
mov    0x0(%r13),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x73,%eax
je     1170 <main+0x30>
cmp    $0xffffffff,%eax
je     119e <main+0x5e>
cmp    $0x6c,%eax
jne    11b7 <main+0x77>
mov    0x0(%r13),%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
jmp    1174 <main+0x34>
mov    %r12d,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <server@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"./\00"
@.str.1 = [5 x i8] c"l:s:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [31 x i8] c"Usage: %s [-l port] [-s path]\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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5001, i32* %7
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %28
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %21 [
i32 108, label %16
i32 115, label %19
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
br label %27
19: ; preds = %14
%20 = load i8*, i8** @optarg
store i8* %20, i8** %8
br label %27
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %32
27: ; preds = %19, %16
br label %9
28: ; preds = %9
%29 = load i32, i32* %7
%30 = load i8*, i8** %8
%31 = call i32 @server(i32 %29, i8* %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %21
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
@.str.1 = [5 x i8] c"l:s:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [31 x i8] c"Usage: %s [-l port] [-s path]\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %9, %2
%4 = phi i32 [ %11, %9 ], [ 5001, %2 ]
%5 = phi i8* [ %7, %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
br label %6
6: ; preds = %3, %12
%7 = phi i8* [ %13, %12 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
switch i32 %8, label %14 [
i32 -1, label %18
i32 108, label %9
i32 115, label %12
]
9: ; preds = %6
%10 = load i8*, i8** @optarg
%11 = tail call i32 @atoi(i8* %10)
br label %3
12: ; preds = %6
%13 = load i8*, i8** @optarg
br label %6
14: ; preds = %6
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %20
18: ; preds = %6
%19 = tail call i32 @server(i32 %4, i8* %7)
br label %20
20: ; preds = %18, %14
%21 = phi i32 [ 1, %14 ], [ %19, %18 ]
ret i32 %21
}