#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 EXIT_FAILURE;
int /*<<< orphan*/ check_args(int, char const *const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const,
                           char const *const);
int h_echo(char const *const);
int h_exit_failure();
int h_exit_signal();
int h_exit_success();
int h_stdout_stderr(char const *const);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *const, char *);
int main(int argc, const char *const argv[]) {
  int exitcode;
  check_args(argc, argv, 2);
  if (strcmp(argv[1], "echo") == 0) {
    check_args(argc, argv, 3);
    exitcode = h_echo(argv[2]);
  } else if (strcmp(argv[1], "exit-failure") == 0)
    exitcode = h_exit_failure();
  else if (strcmp(argv[1], "exit-signal") == 0)
    exitcode = h_exit_signal();
  else if (strcmp(argv[1], "exit-success") == 0)
    exitcode = h_exit_success();
  else if (strcmp(argv[1], "stdout-stderr") == 0) {
    check_args(argc, argv, 3);
    exitcode = h_stdout_stderr(argv[2]);
  } else {
    fprintf(stderr, "%s: Unknown helper %s\n", argv[0], argv[1]);
    exitcode = EXIT_FAILURE;
  }
  return exitcode;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1060 <check_args@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <main+0x6b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1060 <check_args@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <h_echo@plt>
mov    %eax,-0x14(%rbp)
jmp    12fa <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1218 <main+0x98>
mov    $0x0,%al
call   1030 <h_exit_failure@plt>
mov    %eax,-0x14(%rbp)
jmp    12f5 <main+0x175>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdeb(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <main+0xc5>
mov    $0x0,%al
call   10a0 <h_exit_signal@plt>
mov    %eax,-0x14(%rbp)
jmp    12f0 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdca(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1272 <main+0xf2>
mov    $0x0,%al
call   1050 <h_exit_success@plt>
mov    %eax,-0x14(%rbp)
jmp    12eb <main+0x16b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12b6 <main+0x136>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1060 <check_args@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <h_stdout_stderr@plt>
mov    %eax,-0x14(%rbp)
jmp    12e6 <main+0x166>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd64(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12eb <main+0x16b>
jmp    12f0 <main+0x170>
jmp    12f5 <main+0x175>
jmp    12fa <main+0x17a>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x2,%edx
call   1060 <check_args@plt>
mov    0x8(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1233 <main+0xb3>
mov    0x8(%rbx),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1251 <main+0xd1>
mov    0x8(%rbx),%rdi
lea    0xe43(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     125e <main+0xde>
mov    0x8(%rbx),%rdi
lea    0xe36(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126b <main+0xeb>
mov    0x8(%rbx),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1278 <main+0xf8>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xe1b(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <check_args@plt>
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <h_echo@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <h_exit_failure@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10a0 <h_exit_signal@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <h_exit_success@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <check_args@plt>
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <h_stdout_stderr@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"echo\00"
@.str.1 = [13 x i8] c"exit-failure\00"
@.str.2 = [12 x i8] c"exit-signal\00"
@.str.3 = [13 x i8] c"exit-success\00"
@.str.4 = [14 x i8] c"stdout-stderr\00"
@stderr = global i32 0
@.str.5 = [23 x i8] c"%s: Unknown helper %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @check_args(i32 %7, i8** %8, i32 2)
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @check_args(i32 %16, i8** %17, i32 3)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @h_echo(i8* %21)
store i32 %22, i32* %6
br label %75
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 (...) @h_exit_failure()
store i32 %30, i32* %6
br label %74
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 (...) @h_exit_signal()
store i32 %38, i32* %6
br label %73
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (...) @h_exit_success()
store i32 %46, i32* %6
br label %72
47: ; preds = %39
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %47
%54 = load i32, i32* %4
%55 = load i8**, i8*** %5
%56 = call i32 @check_args(i32 %54, i8** %55, i32 3)
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @h_stdout_stderr(i8* %59)
store i32 %60, i32* %6
br label %71
61: ; preds = %47
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %65, i8* %68)
%70 = load i32, i32* @EXIT_FAILURE
store i32 %70, i32* %6
br label %71
71: ; preds = %61, %53
br label %72
72: ; preds = %71, %45
br label %73
73: ; preds = %72, %37
br label %74
74: ; preds = %73, %29
br label %75
75: ; preds = %74, %15
%76 = load i32, i32* %6
ret i32 %76
}

LLVM IR (-O2):
@.str = [5 x i8] c"echo\00"
@.str.1 = [13 x i8] c"exit-failure\00"
@.str.2 = [12 x i8] c"exit-signal\00"
@.str.3 = [13 x i8] c"exit-success\00"
@.str.4 = [14 x i8] c"stdout-stderr\00"
@stderr = global i32 0
@.str.5 = [23 x i8] c"%s: Unknown helper %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @check_args(i32 %0, i8** %1, i32 2)
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = tail call i32 @check_args(i32 %0, i8** %1, i32 3)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @h_echo(i8* %11)
br label %46
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 (...) @h_exit_failure()
br label %46
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = tail call i32 (...) @h_exit_signal()
br label %46
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 (...) @h_exit_success()
br label %46
31: ; preds = %25
%32 = load i8*, i8** %4
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = tail call i32 @check_args(i32 %0, i8** %1, i32 3)
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = tail call i32 @h_stdout_stderr(i8* %38)
br label %46
40: ; preds = %31
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = load i8*, i8** %4
%44 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %42, i8* %43)
%45 = load i32, i32* @EXIT_FAILURE
br label %46
46: ; preds = %17, %29, %40, %35, %23, %8
%47 = phi i32 [ %12, %8 ], [ %18, %17 ], [ %24, %23 ], [ %30, %29 ], [ %39, %35 ], [ %45, %40 ]
ret i32 %47
}