#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*/ btk_help_commands();
int /*<<< orphan*/ btk_help_node();
int /*<<< orphan*/ btk_help_privkey();
int /*<<< orphan*/ btk_help_pubkey();
int /*<<< orphan*/ btk_help_vanity();
int /*<<< orphan*/ btk_help_version();
int /*<<< orphan*/ error_log(char *, ...);
scalar_t__ strcmp(char *, char *);
int btk_help_main(int argc, char *argv[]) {
  if (argc <= 2) {
    btk_help_commands();
    return 1;
  }
  if (strcmp(argv[2], "privkey") == 0) {
    btk_help_privkey();
  } else if (strcmp(argv[2], "pubkey") == 0) {
    btk_help_pubkey();
  } else if (strcmp(argv[2], "node") == 0) {
    btk_help_node();
  } else if (strcmp(argv[2], "vanity") == 0) {
    btk_help_vanity();
  } else if (strcmp(argv[2], "version") == 0) {
    btk_help_version();
  } else {
    error_log("See 'btk help' to read about available commands.");
    error_log("'%s' is not a valid command.", argv[2]);
    return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<btk_help_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     11ac <btk_help_main+0x2c>
mov    $0x0,%al
call   1060 <btk_help_commands@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c9 <btk_help_main+0x149>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d6 <btk_help_main+0x56>
mov    $0x0,%al
call   1090 <btk_help_privkey@plt>
jmp    12c2 <btk_help_main+0x142>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1200 <btk_help_main+0x80>
mov    $0x0,%al
call   10a0 <btk_help_pubkey@plt>
jmp    12bd <btk_help_main+0x13d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe00(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <btk_help_main+0xaa>
mov    $0x0,%al
call   1050 <btk_help_node@plt>
jmp    12b8 <btk_help_main+0x138>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1254 <btk_help_main+0xd4>
mov    $0x0,%al
call   1080 <btk_help_vanity@plt>
jmp    12b3 <btk_help_main+0x133>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <btk_help_main+0xfe>
mov    $0x0,%al
call   1030 <btk_help_version@plt>
jmp    12ae <btk_help_main+0x12e>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1070 <error_log@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1070 <error_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c9 <btk_help_main+0x149>
jmp    12b3 <btk_help_main+0x133>
jmp    12b8 <btk_help_main+0x138>
jmp    12bd <btk_help_main+0x13d>
jmp    12c2 <btk_help_main+0x142>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btk_help_main>:
push   %rbx
cmp    $0x2,%edi
jg     1192 <btk_help_main+0x12>
xor    %eax,%eax
call   1060 <btk_help_commands@plt>
jmp    1250 <btk_help_main+0xd0>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe60(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1225 <btk_help_main+0xa5>
mov    0x10(%rbx),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     122e <btk_help_main+0xae>
mov    0x10(%rbx),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1237 <btk_help_main+0xb7>
mov    0x10(%rbx),%rdi
lea    0xe35(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1240 <btk_help_main+0xc0>
mov    0x10(%rbx),%rdi
lea    0xe27(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1249 <btk_help_main+0xc9>
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1070 <error_log@plt>
mov    0x10(%rbx),%rsi
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1070 <error_log@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1090 <btk_help_privkey@plt>
jmp    1250 <btk_help_main+0xd0>
xor    %eax,%eax
call   10a0 <btk_help_pubkey@plt>
jmp    1250 <btk_help_main+0xd0>
xor    %eax,%eax
call   1050 <btk_help_node@plt>
jmp    1250 <btk_help_main+0xd0>
xor    %eax,%eax
call   1080 <btk_help_vanity@plt>
jmp    1250 <btk_help_main+0xd0>
xor    %eax,%eax
call   1030 <btk_help_version@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"privkey\00"
@.str.1 = [7 x i8] c"pubkey\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [7 x i8] c"vanity\00"
@.str.4 = [8 x i8] c"version\00"
@.str.5 = [49 x i8] c"See 'btk help' to read about available commands.\00"
@.str.6 = [29 x i8] c"'%s' is not a valid command.\00"
define i32 @btk_help_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @btk_help_commands()
store i32 1, i32* %3
br label %61
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (...) @btk_help_privkey()
br label %60
18: ; preds = %10
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 (...) @btk_help_pubkey()
br label %59
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (...) @btk_help_node()
br label %58
34: ; preds = %26
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = call i32 (...) @btk_help_vanity()
br label %57
42: ; preds = %34
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 (...) @btk_help_version()
br label %56
50: ; preds = %42
%51 = call i32 (i8*, ...) @error_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @error_log(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %54)
store i32 -1, i32* %3
br label %61
56: ; preds = %48
br label %57
57: ; preds = %56, %40
br label %58
58: ; preds = %57, %32
br label %59
59: ; preds = %58, %24
br label %60
60: ; preds = %59, %16
store i32 1, i32* %3
br label %61
61: ; preds = %60, %50, %8
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [8 x i8] c"privkey\00"
@.str.1 = [7 x i8] c"pubkey\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [7 x i8] c"vanity\00"
@.str.4 = [8 x i8] c"version\00"
@.str.5 = [49 x i8] c"See 'btk help' to read about available commands.\00"
@.str.6 = [29 x i8] c"'%s' is not a valid command.\00"
define i32 @btk_help_main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @btk_help_commands()
br label %41
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (...) @btk_help_privkey()
br label %41
13: ; preds = %6
%14 = load i8*, i8** %7
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 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 (...) @btk_help_pubkey()
br label %41
19: ; preds = %13
%20 = load i8*, i8** %7
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 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 (...) @btk_help_node()
br label %41
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 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 (...) @btk_help_vanity()
br label %41
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 (...) @btk_help_version()
br label %41
37: ; preds = %31
%38 = tail call i32 (i8*, ...) @error_log(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%39 = load i8*, i8** %7
%40 = tail call i32 (i8*, ...) @error_log(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %11, %23, %35, %29, %17, %37, %4
%42 = phi i32 [ 1, %4 ], [ -1, %37 ], [ 1, %17 ], [ 1, %29 ], [ 1, %35 ], [ 1, %23 ], [ 1, %11 ]
ret i32 %42
}