#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 *name;
  char val;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int E2BIG;
int EINVAL;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_help(char *);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strerror(int);
int main(int argc, char *argv[]) {
  struct option lopts[] = {{.name = "help", .val = 'h'}, {0}};
  int opt;
  while ((opt = getopt_long(argc, argv, "h", lopts, NULL)) != -1) {
    switch (opt) {
    case 'h':
      print_help(argc > 0 ? argv[0] : "perror");
      return 0;
    case '?':
      return EINVAL;
    }
  }
  if (argc != 2) {
    fputs("Expected just one argument, see -h / --help\n", stderr);
    return argc > 2 ? E2BIG : EINVAL;
  }
  int input_number;
  if (sscanf(argv[1], "%i", &input_number) != 1) {
    fputs("Expected integer argument, see -h / --help\n", stderr);
    return EINVAL;
  }
  puts(strerror(input_number));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c63(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c60(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c5d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c5a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rcx
lea    0xe51(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1244 <main+0xe4>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     122e <main+0xce>
jmp    11de <main+0x7e>
mov    -0x3c(%rbp),%eax
sub    $0x68,%eax
jne    123f <main+0xdf>
jmp    11ef <main+0x8f>
cmpl   $0x0,-0x8(%rbp)
jle    1209 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    1219 <main+0xb9>
lea    0xdf7(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    1219 <main+0xb9>
mov    -0x48(%rbp),%rdi
call   1070 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <main+0x192>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f2 <main+0x192>
jmp    11a2 <main+0x42>
cmpl   $0x2,-0x8(%rbp)
je     1295 <main+0x135>
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
lea    0xdb0(%rip),%rdi
call   1050 <fputs@plt>
cmpl   $0x2,-0x8(%rbp)
jle    127e <main+0x11e>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    128a <main+0x12a>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f2 <main+0x192>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd97(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     12dc <main+0x17c>
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
lea    0xd78(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f2 <main+0x192>
mov    -0x38(%rbp),%edi
call   1080 <strerror@plt>
mov    %eax,%edi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movaps 0x2c7a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c5e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe77(%rip),%r14
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     11cf <main+0x6f>
cmp    $0x3f,%eax
je     1248 <main+0xe8>
cmp    $0x68,%eax
jne    11a0 <main+0x40>
test   %ebp,%ebp
jle    1223 <main+0xc3>
mov    (%rbx),%rdi
jmp    122a <main+0xca>
cmp    $0x2,%ebp
jne    1200 <main+0xa0>
mov    0x8(%rbx),%rdi
lea    0xe5c(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    1233 <main+0xd3>
mov    0xc(%rsp),%edi
call   1080 <strerror@plt>
mov    %eax,%edi
call   1030 <puts@plt>
jmp    122f <main+0xcf>
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
lea    0xdfe(%rip),%rdi
call   1050 <fputs@plt>
cmp    $0x3,%ebp
jl     1248 <main+0xe8>
mov    0x2dbf(%rip),%rax
jmp    124f <main+0xef>
lea    0xddd(%rip),%rdi
call   1070 <print_help@plt>
xor    %eax,%eax
jmp    1251 <main+0xf1>
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
lea    0xdfb(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32 }
@.str = [5 x i8] c"help\00"
@__const.main.lopts = [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 104, i32 0 }, %struct.option zeroinitializer]
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [7 x i8] c"perror\00"
@EINVAL = global i32 0
@.str.3 = [45 x i8] c"Expected just one argument, see -h / --help\0A\00"
@stderr = global i32 0
@E2BIG = global i32 0
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [44 x i8] c"Expected integer argument, see -h / --help\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x %struct.option]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [2 x %struct.option]* %6 to i8*
br label %10
10: ; preds = %31, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %6, i64 0, i64 0
%14 = call i32 @getopt_long(i32 %11, i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* %13, i32* null)
store i32 %14, i32* %7
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %32
16: ; preds = %10
%17 = load i32, i32* %7
switch i32 %17, label %31 [
i32 104, label %18
i32 63, label %29
]
18: ; preds = %16
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
br label %26
25: ; preds = %18
br label %26
26: ; preds = %25, %21
%27 = phi i8* [ %24, %21 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %25 ]
%28 = call i32 @print_help(i8* %27)
store i32 0, i32* %3
br label %60
29: ; preds = %16
%30 = load i32, i32* @EINVAL
store i32 %30, i32* %3
br label %60
31: ; preds = %16
br label %10
32: ; preds = %10
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 2
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 @fputs(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 2
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load i32, i32* @E2BIG
br label %44
42: ; preds = %35
%43 = load i32, i32* @EINVAL
br label %44
44: ; preds = %42, %40
%45 = phi i32 [ %41, %40 ], [ %43, %42 ]
store i32 %45, i32* %3
br label %60
46: ; preds = %32
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%51 = icmp ne i32 %50, 1
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i32, i32* @stderr
%54 = call i32 @fputs(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i32, i32* @EINVAL
store i32 %55, i32* %3
br label %60
56: ; preds = %46
%57 = load i32, i32* %8
%58 = call i32 @strerror(i32 %57)
%59 = call i32 @puts(i32 %58)
store i32 0, i32* %3
br label %60
60: ; preds = %56, %52, %44, %29, %26
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32 }
@.str = [5 x i8] c"help\00"
@__const.main.lopts = [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 104, i32 0 }, %struct.option zeroinitializer]
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [7 x i8] c"perror\00"
@EINVAL = global i32 0
@.str.3 = [45 x i8] c"Expected just one argument, see -h / --help\0A\00"
@stderr = global i32 0
@E2BIG = global i32 0
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [44 x i8] c"Expected integer argument, see -h / --help\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x %struct.option]
%4 = alloca i32
%5 = bitcast [2 x %struct.option]* %3 to i8*
%6 = getelementptr inbounds [2 x %struct.option], [2 x %struct.option]* %3, i64 0, i64 0
br label %7
7: ; preds = %7, %2
%8 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* %6, i32* null)
switch i32 %8, label %7 [
i32 -1, label %18
i32 104, label %9
i32 63, label %16
]
9: ; preds = %7
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = load i8*, i8** %1
br label %13
13: ; preds = %9, %11
%14 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %9 ]
%15 = call i32 @print_help(i8* %14)
br label %43
16: ; preds = %7
%17 = load i32, i32* @EINVAL
br label %43
18: ; preds = %7
%19 = icmp eq i32 %0, 2
br i1 %19, label %27, label %20
20: ; preds = %18
%21 = load i32, i32* @stderr
%22 = call i32 @fputs(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = icmp sgt i32 %0, 2
%24 = load i32, i32* @E2BIG
%25 = load i32, i32* @EINVAL
%26 = select i1 %23, i32 %24, i32 %25
br label %43
27: ; preds = %18
%28 = bitcast i32* %4 to i8*
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%32 = icmp eq i32 %31, 1
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = call i32 @fputs(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @EINVAL
br label %41
37: ; preds = %27
%38 = load i32, i32* %4
%39 = call i32 @strerror(i32 %38)
%40 = call i32 @puts(i32 %39)
br label %41
41: ; preds = %37, %33
%42 = phi i32 [ %36, %33 ], [ 0, %37 ]
br label %43
43: ; preds = %41, %20, %16, %13
%44 = phi i32 [ %17, %16 ], [ 0, %13 ], [ %26, %20 ], [ %42, %41 ]
ret i32 %44
}