#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ no_argument;
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ required_argument;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  char *input = NULL;
  int opt_i;
  int c;
  struct option opt[] = {{"help", no_argument, 0, 'h'},
                         {"version", no_argument, 0, 'v'},
                         {"print", required_argument, 0, 'p'},
                         {0, 0, 0, 0}};
  while ((c = getopt_long(argc, argv, "h:v:p", opt, &opt_i)) != -1) {
    switch (c) {
    case 'h':
      break;
    case 'v':
      break;
    case 'p':
      input = optarg;
      break;
    default:
      usage(argv[0]);
      return -1;
    }
  }
  if (!input)
    goto out;
  if (strcmp(input, "kset"))
    goto error;
  printf("The input is %s\n", input);
  printf("The end");
out:
  return 0;
error:
  usage(argv[0]);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe84(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x68,-0x70(%rbp)
add    $0x18,%rdi
lea    0xe60(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x60(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x76,-0x58(%rbp)
add    $0x18,%rdi
lea    0xe3f(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %al,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x70,-0x40(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    0xe05(%rip),%rdx
lea    -0x1c(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
je     129c <main+0x14c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x84(%rbp)
sub    $0x68,%eax
je     1262 <main+0x112>
jmp    123a <main+0xea>
mov    -0x84(%rbp),%eax
sub    $0x70,%eax
je     126c <main+0x11c>
jmp    124e <main+0xfe>
mov    -0x84(%rbp),%eax
sub    $0x76,%eax
je     1267 <main+0x117>
jmp    127f <main+0x12f>
jmp    1297 <main+0x147>
jmp    1297 <main+0x147>
mov    0x2d85(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1297 <main+0x147>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    130a <main+0x1ba>
jmp    11fc <main+0xac>
cmpq   $0x0,-0x18(%rbp)
jne    12ac <main+0x15c>
jmp    12eb <main+0x19b>
mov    -0x18(%rbp),%rdi
lea    0xd62(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12cb <main+0x17b>
jmp    12f7 <main+0x1a7>
mov    -0x18(%rbp),%rsi
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130a <main+0x1ba>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea6(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%al
mov    %al,0x18(%rsp)
movabs $0x6800000000,%rcx
mov    %rcx,0x1c(%rsp)
lea    0xe83(%rip),%rcx
mov    %rcx,0x28(%rsp)
mov    %al,0x30(%rsp)
movabs $0x7600000000,%rax
mov    %rax,0x34(%rsp)
lea    0xe6c(%rip),%rax
mov    %rax,0x40(%rsp)
mov    0x2e33(%rip),%rax
mov    (%rax),%al
mov    %al,0x48(%rsp)
movabs $0x7000000000,%rax
mov    %rax,0x4c(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x58(%rsp)
movq   $0x0,0x68(%rsp)
xor    %r14d,%r14d
lea    0xe36(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
jmp    11f5 <main+0xb5>
nopl   0x0(%rax)
cmp    $0x76,%eax
jne    1214 <main+0xd4>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <getopt_long@plt>
cmp    $0x6f,%eax
jg     11f0 <main+0xb0>
cmp    $0x68,%eax
je     11f5 <main+0xb5>
jmp    1225 <main+0xe5>
cmp    $0x70,%eax
jne    1243 <main+0x103>
mov    0x2dd8(%rip),%rax
mov    (%rax),%r14
jmp    11f5 <main+0xb5>
cmp    $0xffffffff,%eax
jne    1243 <main+0x103>
test   %r14,%r14
je     1252 <main+0x112>
lea    0xde3(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1256 <main+0x116>
mov    (%rbx),%rdi
call   1060 <usage@plt>
mov    $0xffffffff,%ebx
jmp    1277 <main+0x137>
xor    %ebx,%ebx
jmp    1277 <main+0x137>
lea    0xdc1(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [6 x i8] c"print\00"
@required_argument = global i32 0
@.str.3 = [6 x i8] c"h:v:p\00"
@optarg = global i8* null
@.str.4 = [5 x i8] c"kset\00"
@.str.5 = [17 x i8] c"The input is %s\0A\00"
@.str.6 = [8 x i8] c"The end\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%10 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %9, i64 0, i64 0
%11 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 1
%13 = load i32, i32* @no_argument
%14 = trunc i32 %13 to i8
store i8 %14, i8* %12
%15 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 2
store i32 0, i32* %15
%16 = getelementptr inbounds %struct.option, %struct.option* %10, i32 0, i32 3
store i32 104, i32* %16
%17 = getelementptr inbounds %struct.option, %struct.option* %10, i64 1
%18 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 1
%20 = load i32, i32* @no_argument
%21 = trunc i32 %20 to i8
store i8 %21, i8* %19
%22 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 2
store i32 0, i32* %22
%23 = getelementptr inbounds %struct.option, %struct.option* %17, i32 0, i32 3
store i32 118, i32* %23
%24 = getelementptr inbounds %struct.option, %struct.option* %17, i64 1
%25 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 1
%27 = load i32, i32* @required_argument
%28 = trunc i32 %27 to i8
store i8 %28, i8* %26
%29 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 2
store i32 0, i32* %29
%30 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 3
store i32 112, i32* %30
%31 = getelementptr inbounds %struct.option, %struct.option* %24, i64 1
%32 = bitcast %struct.option* %31 to i8*
br label %33
33: ; preds = %50, %2
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %9, i64 0, i64 0
%37 = call i32 @getopt_long(i32 %34, i8** %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %36, i32* %7)
store i32 %37, i32* %8
%38 = icmp ne i32 %37, -1
br i1 %38, label %39, label %51
39: ; preds = %33
%40 = load i32, i32* %8
switch i32 %40, label %45 [
i32 104, label %41
i32 118, label %42
i32 112, label %43
]
41: ; preds = %39
br label %50
42: ; preds = %39
br label %50
43: ; preds = %39
%44 = load i8*, i8** @optarg
store i8* %44, i8** %6
br label %50
45: ; preds = %39
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 @usage(i8* %48)
store i32 -1, i32* %3
br label %70
50: ; preds = %43, %42, %41
br label %33
51: ; preds = %33
%52 = load i8*, i8** %6
%53 = icmp ne i8* %52, null
br i1 %53, label %55, label %54
54: ; preds = %51
br label %64
55: ; preds = %51
%56 = load i8*, i8** %6
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %55
br label %65
60: ; preds = %55
%61 = load i8*, i8** %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %64
64: ; preds = %60, %54
store i32 0, i32* %3
br label %70
65: ; preds = %59
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = call i32 @usage(i8* %68)
store i32 -1, i32* %3
br label %70
70: ; preds = %65, %64, %45
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@.str = [5 x i8] c"help\00"
@no_argument = global i32 0
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [6 x i8] c"print\00"
@required_argument = global i32 0
@.str.3 = [6 x i8] c"h:v:p\00"
@optarg = global i8* null
@.str.4 = [5 x i8] c"kset\00"
@.str.5 = [17 x i8] c"The input is %s\0A\00"
@.str.6 = [8 x i8] c"The end\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [4 x %struct.option]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [4 x %struct.option]* %4 to i8*
%7 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0
%8 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 1
%10 = load i32, i32* @no_argument
%11 = trunc i32 %10 to i8
store i8 %11, i8* %9
%12 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 2
store i32 0, i32* %12
%13 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 0, i32 3
store i32 104, i32* %13
%14 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 1
store i8 %11, i8* %15
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 2
store i32 0, i32* %16
%17 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 1, i32 3
store i32 118, i32* %17
%18 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 1
%20 = load i32, i32* @required_argument
%21 = trunc i32 %20 to i8
store i8 %21, i8* %19
%22 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 2
store i32 0, i32* %22
%23 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 2, i32 3
store i32 112, i32* %23
%24 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %4, i64 0, i64 3
%25 = bitcast %struct.option* %24 to i8*
br label %26
26: ; preds = %31, %2
%27 = phi i8* [ %32, %31 ], [ null, %2 ]
br label %28
28: ; preds = %30, %26
%29 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %struct.option* %7, i32* %3)
switch i32 %29, label %33 [
i32 -1, label %36
i32 104, label %30
i32 118, label %30
i32 112, label %31
]
30: ; preds = %28, %28
br label %28
31: ; preds = %28
%32 = load i8*, i8** @optarg
br label %26
33: ; preds = %28
%34 = load i8*, i8** %1
%35 = call i32 @usage(i8* %34)
br label %47
36: ; preds = %28
%37 = icmp eq i8* %27, null
br i1 %37, label %47, label %38
38: ; preds = %36
%39 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %47
44: ; preds = %38
%45 = load i8*, i8** %1
%46 = call i32 @usage(i8* %45)
br label %47
47: ; preds = %41, %36, %44, %33
%48 = phi i32 [ -1, %33 ], [ -1, %44 ], [ 0, %36 ], [ 0, %41 ]
ret i32 %48
}