#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 **host, char **port) {
  if (argc < 5) {
    printf("Usage: %s -p [Port] -h [Host]\n", args[0]);
    return EXIT_FAILURE;
  }
  int opt;
  while ((opt = getopt(argc, args, "p:h:")) != -1) {
    switch (opt) {
    case 'p':
      *port = optarg;
      break;
    case 'h':
      *host = 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    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1175 <parseArguments+0x45>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <parseArguments+0xf4>
jmp    117a <parseArguments+0x4a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1218 <parseArguments+0xe8>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x68,%eax
je     11d4 <parseArguments+0xa4>
jmp    11ad <parseArguments+0x7d>
mov    -0x28(%rbp),%eax
sub    $0x70,%eax
jne    11ea <parseArguments+0xba>
jmp    11be <parseArguments+0x8e>
mov    0x2e33(%rip),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1213 <parseArguments+0xe3>
mov    0x2e1d(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1213 <parseArguments+0xe3>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <parseArguments+0xf4>
jmp    117a <parseArguments+0x4a>
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseArguments>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x5,%edi
jge    1154 <parseArguments+0x24>
mov    (%rbx),%rsi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <parseArguments+0x89>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %edi,%ebp
lea    0xebc(%rip),%r12
mov    0x2e8e(%rip),%r13
jmp    1177 <parseArguments+0x47>
nopl   0x0(%rax)
mov    0x0(%r13),%rax
mov    %rax,(%rcx)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
mov    %r15,%rcx
cmp    $0x68,%eax
je     1170 <parseArguments+0x40>
mov    %r14,%rcx
cmp    $0x70,%eax
je     1170 <parseArguments+0x40>
cmp    $0xffffffff,%eax
jne    11a2 <parseArguments+0x72>
mov    0x2e28(%rip),%rax
jmp    11c0 <parseArguments+0x90>
mov    0x2e2f(%rip),%rcx
mov    (%rcx),%edi
lea    0xe72(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: %s -p [Port] -h [Host]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"p:h:\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, i8** nocapture writeonly %3) {
%5 = icmp slt i32 %0, 5
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %18
9: ; preds = %4, %15
%10 = 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 %10, label %12 [
i32 -1, label %18
i32 112, label %15
i32 104, label %11
]
11: ; preds = %9
br label %15
12: ; preds = %9
%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 %10)
br label %18
15: ; preds = %9, %11
%16 = phi i8** [ %2, %11 ], [ %3, %9 ]
%17 = load i8*, i8** @optarg
store i8* %17, i8** %16
br label %9
18: ; preds = %9, %12, %6
%19 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %9 ]
%20 = load i32, i32* %19
ret i32 %20
}