#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  printf("argc:%d\n", argc);
  int num;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s {BIN|OCT|DEC|HEX|STR} {ARG}\n", argv[0]);
    return 1;
  }
  if (!strcmp(argv[1], "BIN")) {
    num = strtol(argv[2], NULL, 2);
    goto number_mode;
  } else if (!strcmp(argv[1], "OCT")) {
    num = strtol(argv[2], NULL, 8);
    goto number_mode;
  } else if (!strcmp(argv[1], "DEC")) {
    num = strtol(argv[2], NULL, 10);
    goto number_mode;
  } else if (!strcmp(argv[1], "HEX")) {
    num = strtol(argv[2], NULL, 16);
    goto number_mode;
  } else if (!strcmp(argv[1], "STR")) {
    printf("Called with string argument: '%s'\n", argv[2]);
  } else {
    printf("Called unsupported mode: '%s'\n", argv[1]);
  }
  if (0) {
  number_mode:
    printf("Called with numeric argument: %d\n", num);
  }
  return 0;
}


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),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     1199 <main+0x59>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1313 <main+0x1d3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe88(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11d4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    120f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    124a <main+0x10a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <main+0x145>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdac(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12bd <main+0x17d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x193>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x198>
jmp    12dd <main+0x19d>
jmp    12e2 <main+0x1a2>
jmp    12e7 <main+0x1a7>
xor    %eax,%eax
test   $0x1,%al
jne    12f6 <main+0x1b6>
jmp    130c <main+0x1cc>
jmp    12fb <main+0x1bb>
mov    -0x14(%rbp),%esi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%ebp
jne    11cf <main+0x8f>
mov    0x8(%rbx),%r14
lea    0xec7(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ee <main+0xae>
lea    0xeb8(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f5 <main+0xb5>
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11fc <main+0xbc>
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1203 <main+0xc3>
lea    0xe8b(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122c <main+0xec>
lea    0xe9f(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
jmp    1239 <main+0xf9>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe27(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
jmp    1225 <main+0xe5>
mov    $0x2,%edx
jmp    1208 <main+0xc8>
mov    $0x8,%edx
jmp    1208 <main+0xc8>
mov    $0xa,%edx
jmp    1208 <main+0xc8>
mov    $0x10,%edx
mov    0x10(%rbx),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <strtol@plt>
lea    0xe6a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x10(%rbx),%rsi
lea    0xe0d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1225 <main+0xe5>

LLVM IR (-O0):
@.str = [9 x i8] c"argc:%d\0A\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"Usage: %s {BIN|OCT|DEC|HEX|STR} {ARG}\0A\00"
@.str.2 = [4 x i8] c"BIN\00"
@.str.3 = [4 x i8] c"OCT\00"
@.str.4 = [4 x i8] c"DEC\00"
@.str.5 = [4 x i8] c"HEX\00"
@.str.6 = [4 x i8] c"STR\00"
@.str.7 = [35 x i8] c"Called with string argument: '%s'\0A\00"
@.str.8 = [31 x i8] c"Called unsupported mode: '%s'\0A\00"
@.str.9 = [34 x i8] c"Called with numeric argument: %d\0A\00"
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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %87
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strtol(i8* %26, i32* null, i32 2)
store i32 %27, i32* %6
br label %83
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @strtol(i8* %37, i32* null, i32 8)
store i32 %38, i32* %6
br label %83
39: ; preds = %28
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %50, label %45
45: ; preds = %39
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @strtol(i8* %48, i32* null, i32 10)
store i32 %49, i32* %6
br label %83
50: ; preds = %39
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %50
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @strtol(i8* %59, i32* null, i32 16)
store i32 %60, i32* %6
br label %83
61: ; preds = %50
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%66 = icmp ne i32 %65, 0
br i1 %66, label %72, label %67
67: ; preds = %61
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %70)
br label %77
72: ; preds = %61
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 1
%75 = load i8*, i8** %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %75)
br label %77
77: ; preds = %72, %67
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
br i1 false, label %82, label %86
82: ; preds = %81
br label %83
83: ; preds = %82, %56, %45, %34, %23
%84 = load i32, i32* %6
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %83, %81
store i32 0, i32* %3
br label %87
87: ; preds = %86, %11
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str = [9 x i8] c"argc:%d\0A\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"Usage: %s {BIN|OCT|DEC|HEX|STR} {ARG}\0A\00"
@.str.2 = [4 x i8] c"BIN\00"
@.str.3 = [4 x i8] c"OCT\00"
@.str.4 = [4 x i8] c"DEC\00"
@.str.5 = [4 x i8] c"HEX\00"
@.str.6 = [4 x i8] c"STR\00"
@.str.7 = [35 x i8] c"Called with string argument: '%s'\0A\00"
@.str.8 = [31 x i8] c"Called unsupported mode: '%s'\0A\00"
@.str.9 = [34 x i8] c"Called with numeric argument: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = icmp eq i32 %0, 3
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %38
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %32, label %14
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %32, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %32, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %28)
br label %38
30: ; preds = %23
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %11)
br label %38
32: ; preds = %20, %17, %14, %9
%33 = phi i32 [ 2, %9 ], [ 8, %14 ], [ 10, %17 ], [ 16, %20 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 2
%35 = load i8*, i8** %34
%36 = tail call i32 @strtol(i8* nocapture %35, i32* null, i32 %33)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32, %30, %26, %5
%39 = phi i32 [ 1, %5 ], [ 0, %26 ], [ 0, %30 ], [ 0, %32 ]
ret i32 %39
}