#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int parseArguments(int argc, char **args, char **port) {
  if (argc < 3) {
    printf("Usage: %s -p Port\n", args[0]);
    return EXIT_FAILURE;
  }
  int opt;
  while ((opt = getopt(argc, args, "p:")) != -1) {
    switch (opt) {
    case 'p':
      *port = optarg;
      break;
    default:
      fprintf(stderr, "Unknown paramater %c", opt);
      return EXIT_FAILURE;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<parseArguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1171 <parseArguments+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f6 <parseArguments+0xc6>
jmp    1176 <parseArguments+0x46>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8f(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11ea <parseArguments+0xba>
mov    -0x1c(%rbp),%eax
sub    $0x70,%eax
jne    11bc <parseArguments+0x8c>
jmp    11a6 <parseArguments+0x76>
mov    0x2e4b(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11e5 <parseArguments+0xb5>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe47(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11f6 <parseArguments+0xc6>
jmp    1176 <parseArguments+0x46>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseArguments>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jge    1151 <parseArguments+0x21>
mov    (%rbx),%rsi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <parseArguments+0x80>
mov    %rdx,%r14
mov    %edi,%ebp
lea    0xeb6(%rip),%r15
mov    0x2e94(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x70,%eax
jne    118b <parseArguments+0x5b>
mov    (%r12),%rax
mov    %rax,(%r14)
jmp    1170 <parseArguments+0x40>
cmp    $0xffffffff,%eax
jne    1199 <parseArguments+0x69>
mov    0x2e31(%rip),%rax
jmp    11b7 <parseArguments+0x87>
mov    0x2e38(%rip),%rcx
mov    (%rcx),%edi
lea    0xe6d(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Usage: %s -p Port\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"p:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [21 x i8] c"Unknown paramater %c\00"
@EXIT_SUCCESS = global i32 0
define i32 @parseArguments(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8**, i8*** %6
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %4
br label %36
17: ; preds = %3
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %5
%20 = load i8**, i8*** %6
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %8
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %34
23: ; preds = %18
%24 = load i32, i32* %8
switch i32 %24, label %28 [
i32 112, label %25
]
25: ; preds = %23
%26 = load i8*, i8** @optarg
%27 = load i8**, i8*** %7
store i8* %26, i8** %27
br label %33
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i32, i32* %8
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %4
br label %36
33: ; preds = %25
br label %18
34: ; preds = %18
%35 = load i32, i32* @EXIT_SUCCESS
store i32 %35, i32* %4
br label %36
36: ; preds = %34, %28, %11
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage: %s -p Port\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"p:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [21 x i8] c"Unknown paramater %c\00"
@EXIT_SUCCESS = global i32 0
define i32 @parseArguments(i32 %0, i8** %1, i8** nocapture writeonly %2) {
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %15
8: ; preds = %3, %10
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
switch i32 %9, label %12 [
i32 -1, label %15
i32 112, label %10
]
10: ; preds = %8
%11 = load i8*, i8** @optarg
store i8* %11, i8** %2
br label %8
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %15
15: ; preds = %8, %12, %5
%16 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %8 ]
%17 = load i32, i32* %16
ret i32 %17
}