#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int option_char;
  int portno = 8888;
  char *filename = "bar.txt";
  while ((option_char = getopt(argc, argv, "p:f:h")) != -1) {
    switch (option_char) {
    case 'p':
      portno = atoi(optarg);
      break;
    case 'f':
      filename = optarg;
      break;
    case 'h':
      fprintf(stdout, "%s",
              "usage:\n"
              "  transferserver [options]\n"
              "options:\n"
              "  -p                  Port (Default: 8888)\n"
              "  -f                  Filename (Default: bar.txt)\n"
              "  -h                  Show this help message\n");
      exit(0);
      break;
    default:
      fprintf(stderr, "%s",
              "usage:\n"
              "  transferserver [options]\n"
              "options:\n"
              "  -p                  Port (Default: 8888)\n"
              "  -f                  Filename (Default: bar.txt)\n"
              "  -h                  Show this help message\n");
      exit(1);
    }
  }
}


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   $0x22b8,-0x18(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe92(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1235 <main+0xf5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x66,%eax
je     11d4 <main+0x94>
jmp    119b <main+0x5b>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     11e7 <main+0xa7>
jmp    11ac <main+0x6c>
mov    -0x24(%rbp),%eax
sub    $0x70,%eax
jne    120a <main+0xca>
jmp    11bd <main+0x7d>
mov    0x2e34(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    1230 <main+0xf0>
mov    0x2e1d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1230 <main+0xf0>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
lea    0xe13(%rip),%rdx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
lea    0xdf0(%rip),%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1168 <main+0x28>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec0(%rip),%r14
jmp    1155 <main+0x25>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x70,%eax
jne    1178 <main+0x48>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
cmp    $0x67,%eax
jg     1150 <main+0x20>
cmp    $0x66,%eax
je     1155 <main+0x25>
cmp    $0xffffffff,%eax
jne    11a0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
cmp    $0x68,%eax
jne    11a0 <main+0x70>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
lea    0xe75(%rip),%rdx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
lea    0xe52(%rip),%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"bar.txt\00"
@.str.1 = [6 x i8] c"p:f:h\00"
@optarg = global i8* null
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [182 x i8] c"usage:\0A transferserver [options]\0Aoptions:\0A -p Port (Default: 8888)\0A -f Filename (Default: bar.txt)\0A -h Show this help message\0A\00"
@stderr = global i32 0
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 8888, i32* %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %8
br label %9
9: ; preds = %29, %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.1, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %30
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %25 [
i32 112, label %16
i32 102, label %19
i32 104, label %21
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
br label %29
19: ; preds = %14
%20 = load i8*, i8** @optarg
store i8* %20, i8** %8
br label %29
21: ; preds = %14
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %14
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19, %16
br label %9
30: ; preds = %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"p:f:h\00"
@optarg = global i8* null
@stdout = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [182 x i8] c"usage:\0A transferserver [options]\0Aoptions:\0A -p Port (Default: 8888)\0A -f Filename (Default: bar.txt)\0A -h Show this help message\0A\00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
switch i32 %4, label %10 [
i32 -1, label %14
i32 112, label %5
i32 102, label %5
i32 104, label %6
]
5: ; preds = %3, %3
br label %3
6: ; preds = %3
%7 = load i32, i32* @stdout
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %3
ret i32 0
}