#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 *);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int opt;
  int flag = 0;
  char *key = "";
  while ((opt = getopt(argc, argv, "fk:")) != -1) {
    switch (opt) {
    case 'f':
      flag = 1;
      break;
    case 'k':
      key = optarg;
      break;
    default:
      usage(argv[0]);
      return 1;
    }
  }
  printf("flag = %i\n", flag);
  printf(" key = '%s'\n", key);
  return 0;
}


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   $0x0,-0x18(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9a(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11d8 <main+0xa8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x66,%eax
je     119c <main+0x6c>
jmp    118b <main+0x5b>
mov    -0x24(%rbp),%eax
sub    $0x6b,%eax
je     11a8 <main+0x78>
jmp    11bb <main+0x8b>
movl   $0x1,-0x18(%rbp)
jmp    11d3 <main+0xa3>
mov    0x2e49(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11d3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1202 <main+0xd2>
jmp    1158 <main+0x28>
mov    -0x18(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-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    0xed4(%rip),%r14
xor    %r15d,%r15d
lea    0xeaf(%rip),%r12
mov    0x2ea0(%rip),%r13
jmp    1164 <main+0x34>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0x6b,%eax
je     1160 <main+0x30>
cmp    $0xffffffff,%eax
je     1188 <main+0x58>
cmp    $0x66,%eax
jne    11ae <main+0x7e>
mov    $0x1,%r15d
jmp    1164 <main+0x34>
lea    0xe75(%rip),%rdi
xor    %ebx,%ebx
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bb <main+0x8b>
mov    (%rbx),%rdi
call   1040 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"fk:\00"
@optarg = global i8* null
@.str.2 = [11 x i8] c"flag = %i\0A\00"
@.str.3 = [13 x i8] c" key = '%s'\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 0, i32* %7
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([4 x i8], [4 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 %25
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %19 [
i32 102, label %16
i32 107, label %17
]
16: ; preds = %14
store i32 1, i32* %7
br label %24
17: ; preds = %14
%18 = load i8*, i8** @optarg
store i8* %18, i8** %8
br label %24
19: ; preds = %14
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usage(i8* %22)
store i32 1, i32* %3
br label %30
24: ; preds = %17, %16
br label %9
25: ; preds = %9
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i8*, i8** %8
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %28)
store i32 0, i32* %3
br label %30
30: ; preds = %25, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"fk:\00"
@optarg = global i8* null
@.str.2 = [11 x i8] c"flag = %i\0A\00"
@.str.3 = [13 x i8] c" key = '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i32 [ 0, %2 ], [ 1, %6 ]
%5 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ %7, %6 ]
br label %6
6: ; preds = %3, %9
%7 = phi i8* [ %10, %9 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
switch i32 %8, label %11 [
i32 -1, label %14
i32 102, label %3
i32 107, label %9
]
9: ; preds = %6
%10 = load i8*, i8** @optarg
br label %6
11: ; preds = %6
%12 = load i8*, i8** %1
%13 = tail call i32 @usage(i8* %12)
br label %17
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %17
17: ; preds = %14, %11
%18 = phi i32 [ 1, %11 ], [ 0, %14 ]
ret i32 %18
}