#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 getopt(int, char **, char *);
scalar_t__ malloc(int);
char *optarg;
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int parse_opt(int argc, char **argv, char **fileName) {
  int c;
  char *fflag;
  while ((c = getopt(argc, argv, ":hf:")) != -1) {
    switch (c) {
    case 'f':
      fflag = optarg;
      *fileName = (char *)malloc(30 * sizeof(char));
      strcpy(*fileName, fflag);
      break;
    case 'h':
      print_usage(argv[0]);
      print_help();
      return 0;
    case ':':
      print_usage(argv[0]);
      return 0;
    case '?':
    default:
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8f(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     124d <parse_opt+0xfd>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x3a,%eax
je     121f <parse_opt+0xcf>
jmp    1196 <parse_opt+0x46>
mov    -0x2c(%rbp),%eax
sub    $0x3f,%eax
je     1237 <parse_opt+0xe7>
jmp    11a7 <parse_opt+0x57>
mov    -0x2c(%rbp),%eax
sub    $0x66,%eax
je     11c9 <parse_opt+0x79>
jmp    11b8 <parse_opt+0x68>
mov    -0x2c(%rbp),%eax
sub    $0x68,%eax
je     1200 <parse_opt+0xb0>
jmp    123c <parse_opt+0xec>
mov    0x2e28(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1248 <parse_opt+0xf8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    $0x0,%al
call   1060 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    1254 <parse_opt+0x104>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1254 <parse_opt+0x104>
jmp    123c <parse_opt+0xec>
movl   $0x0,-0x4(%rbp)
jmp    1254 <parse_opt+0x104>
jmp    1163 <parse_opt+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe96(%rip),%r15
mov    0x2e87(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
cmp    $0x66,%eax
jne    11b1 <parse_opt+0x61>
mov    0x0(%r13),%rbx
mov    $0x1e,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1180 <parse_opt+0x30>
cmp    $0xffffffff,%eax
je     11d3 <parse_opt+0x83>
cmp    $0x3a,%eax
je     11da <parse_opt+0x8a>
cmp    $0x68,%eax
jne    11e2 <parse_opt+0x92>
mov    (%r14),%rdi
call   1070 <print_usage@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <print_help@plt>
jmp    11e4 <parse_opt+0x94>
mov    $0x1,%ebx
jmp    11e4 <parse_opt+0x94>
mov    (%r14),%rdi
call   1070 <print_usage@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c":hf:\00"
@optarg = global i8* null
define i32 @parse_opt(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
br label %10
10: ; preds = %39, %3
%11 = load i32, i32* %5
%12 = load i8**, i8*** %6
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %8
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %40
15: ; preds = %10
%16 = load i32, i32* %8
switch i32 %16, label %38 [
i32 102, label %17
i32 104, label %26
i32 58, label %32
i32 63, label %37
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %9
%19 = call i64 @malloc(i32 30)
%20 = inttoptr i64 %19 to i8*
%21 = load i8**, i8*** %7
store i8* %20, i8** %21
%22 = load i8**, i8*** %7
%23 = load i8*, i8** %22
%24 = load i8*, i8** %9
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %39
26: ; preds = %15
%27 = load i8**, i8*** %6
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @print_usage(i8* %29)
%31 = call i32 (...) @print_help()
store i32 0, i32* %4
br label %41
32: ; preds = %15
%33 = load i8**, i8*** %6
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 @print_usage(i8* %35)
store i32 0, i32* %4
br label %41
37: ; preds = %15
br label %38
38: ; preds = %15, %37
store i32 0, i32* %4
br label %41
39: ; preds = %17
br label %10
40: ; preds = %10
store i32 1, i32* %4
br label %41
41: ; preds = %40, %38, %32, %26
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [5 x i8] c":hf:\00"
@optarg = global i8* null
define i32 @parse_opt(i32 %0, i8** %1, i8** nocapture writeonly %2) {
br label %4
4: ; preds = %6, %3
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %18 [
i32 -1, label %19
i32 102, label %6
i32 104, label %11
i32 58, label %15
]
6: ; preds = %4
%7 = load i8*, i8** @optarg
%8 = tail call i64 @malloc(i32 30)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %2
%10 = tail call i32 @strcpy(i8* %9, i8* %7)
br label %4
11: ; preds = %4
%12 = load i8*, i8** %1
%13 = tail call i32 @print_usage(i8* %12)
%14 = tail call i32 (...) @print_help()
br label %19
15: ; preds = %4
%16 = load i8*, i8** %1
%17 = tail call i32 @print_usage(i8* %16)
br label %19
18: ; preds = %4
br label %19
19: ; preds = %4, %18, %15, %11
%20 = phi i32 [ 0, %15 ], [ 0, %11 ], [ 0, %18 ], [ 1, %4 ]
ret i32 %20
}