#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 /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
int /*<<< orphan*/ help();
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ printf(char *, int);
int show(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *cfg_mgmt_path = "/debug/cfg_mgmt";
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "hd:")) != -1) {
    switch (c) {
    case 'd':
      cfg_mgmt_path = optarg;
      break;
    case 'h':
      help();
    case '?':
      if (optopt == 'd') {
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
        cfg_mgmt_path = NULL;
      } else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  }
  if (cfg_mgmt_path == NULL) {
    return -2;
  }
  int ret = show(cfg_mgmt_path);
  if (ret)
    printf("show returned %d\n", ret);
}


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)
lea    0xe73(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e30(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe63(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     12c5 <main+0x155>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     120e <main+0x9e>
jmp    11d2 <main+0x62>
mov    -0x24(%rbp),%eax
sub    $0x64,%eax
je     11f4 <main+0x84>
jmp    11e3 <main+0x73>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     1207 <main+0x97>
jmp    12b9 <main+0x149>
mov    0x2dfd(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    12c0 <main+0x150>
mov    $0x0,%al
call   1090 <help@plt>
mov    0x2dcb(%rip),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    124d <main+0xdd>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    0x2da8(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
movq   $0x0,-0x18(%rbp)
jmp    12ad <main+0x13d>
mov    0x2d8c(%rip),%rax
movsbl (%rax),%edi
call   1070 <isprint@plt>
cmp    $0x0,%eax
je     1289 <main+0x119>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    0x2d64(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    12a8 <main+0x138>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
mov    0x2d40(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    12ad <main+0x13d>
movl   $0x1,-0x4(%rbp)
jmp    1301 <main+0x191>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    119f <main+0x2f>
cmpq   $0x0,-0x18(%rbp)
jne    12dc <main+0x16c>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1301 <main+0x191>
mov    -0x18(%rbp),%rdi
call   1050 <show@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1301 <main+0x191>
mov    -0x20(%rbp),%esi
lea    0xd73(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e44(%rip),%rax
movq   $0x0,(%rax)
lea    0xe6e(%rip),%r14
lea    0xe77(%rip),%r15
mov    0x2e58(%rip),%r12
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <getopt@plt>
cmp    $0x64,%eax
jne    11b8 <main+0x48>
mov    (%r12),%r14
jmp    11a0 <main+0x30>
cmp    $0xffffffff,%eax
je     11f6 <main+0x86>
cmp    $0x3f,%eax
je     11d2 <main+0x62>
cmp    $0x68,%eax
jne    125f <main+0xef>
xor    %eax,%eax
call   1090 <help@plt>
mov    0x2e07(%rip),%rbx
mov    (%rbx),%al
cmp    $0x64,%al
jne    1219 <main+0xa9>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    $0x64,%edx
jmp    124a <main+0xda>
test   %r14,%r14
je     123c <main+0xcc>
mov    %r14,%rdi
call   1050 <show@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1254 <main+0xe4>
lea    0xe5f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1254 <main+0xe4>
movsbl %al,%edi
call   1070 <isprint@plt>
mov    0x2da8(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     1243 <main+0xd3>
lea    0xdfc(%rip),%rsi
jmp    124a <main+0xda>
mov    $0xfffffffe,%ebx
jmp    1254 <main+0xe4>
lea    0xe03(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"/debug/cfg_mgmt\00"
@opterr = global i64 0
@.str.1 = [4 x i8] c"hd:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.5 = [18 x i8] c"show returned %d\0A\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %6
store i64 0, i64* @opterr
br label %9
9: ; preds = %44, %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* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %45
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %42 [
i32 100, label %16
i32 104, label %18
i32 63, label %20
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %6
br label %44
18: ; preds = %14
%19 = call i32 (...) @help()
br label %20
20: ; preds = %14, %18
%21 = load i8, i8* @optopt
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 100
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i8, i8* @optopt
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext %26)
store i8* null, i8** %6
br label %41
28: ; preds = %20
%29 = load i8, i8* @optopt
%30 = call i32 @isprint(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = load i8, i8* @optopt
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8 signext %34)
br label %40
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i8, i8* @optopt
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8 signext %38)
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %24
store i32 1, i32* %3
br label %57
42: ; preds = %14
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %16
br label %9
45: ; preds = %9
%46 = load i8*, i8** %6
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %45
store i32 -2, i32* %3
br label %57
49: ; preds = %45
%50 = load i8*, i8** %6
%51 = call i32 @show(i8* %50)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* %8
%56 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %41, %48, %54, %49
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [16 x i8] c"/debug/cfg_mgmt\00"
@opterr = global i64 0
@.str.1 = [4 x i8] c"hd:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.5 = [18 x i8] c"show returned %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), %2 ], [ %7, %6 ]
%5 = 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 %5, label %25 [
i32 -1, label %27
i32 100, label %6
i32 104, label %8
i32 63, label %10
]
6: ; preds = %3
%7 = load i8*, i8** @optarg
br label %3
8: ; preds = %3
%9 = tail call i32 (...) @help()
br label %10
10: ; preds = %3, %8
%11 = load i8, i8* @optopt
%12 = icmp eq i8 %11, 100
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8 signext 100)
br label %34
16: ; preds = %10
%17 = tail call i32 @isprint(i8 signext %11)
%18 = icmp eq i32 %17, 0
%19 = load i32, i32* @stderr
%20 = load i8, i8* @optopt
br i1 %18, label %23, label %21
21: ; preds = %16
%22 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8 signext %20)
br label %34
23: ; preds = %16
%24 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8 signext %20)
br label %34
25: ; preds = %3
%26 = tail call i32 (...) @abort()
unreachable
27: ; preds = %3
%28 = icmp eq i8* %4, null
br i1 %28, label %34, label %29
29: ; preds = %27
%30 = tail call i32 @show(i8* %4)
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %34
34: ; preds = %29, %32, %27, %13, %23, %21
%35 = phi i32 [ 1, %21 ], [ 1, %23 ], [ 1, %13 ], [ -2, %27 ], [ 0, %32 ], [ 0, %29 ]
ret i32 %35
}