#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*/ printf(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ toBaseDec(char *, char *);
int /*<<< orphan*/ toBaseFib(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("This program takes TWO arguments.\n");
    return EXIT_FAILURE;
  }
  char base[8], value[32];
  strcpy(base, argv[1]);
  strcpy(value, argv[2]);
  if (strcmp(base, "F") && strcmp(base, "10")) {
    printf("Invalid base.\n");
    return EXIT_FAILURE;
  }
  char result[32];
  !strcmp(base, "10") ? toBaseFib(value, result) : toBaseDec(value, result);
  puts(result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     119d <main+0x3d>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <main+0xf2>
lea    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x18(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1210 <main+0xb0>
lea    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1210 <main+0xb0>
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <main+0xf2>
lea    -0x18(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <main+0xdc>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1080 <toBaseFib@plt>
jmp    1249 <main+0xe9>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1070 <toBaseDec@plt>
lea    -0x60(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
cmp    $0x3,%edi
jne    11b1 <main+0x61>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0x30(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c8 <main+0x78>
lea    0xe69(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c8 <main+0x78>
lea    0xe56(%rip),%rdi
jmp    11b8 <main+0x68>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
jmp    1200 <main+0xb0>
lea    0xe33(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <strcmp@plt>
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
test   %rax,%rax
je     11ef <main+0x9f>
call   1060 <toBaseDec@plt>
jmp    11f4 <main+0xa4>
call   1070 <toBaseFib@plt>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"This program takes TWO arguments.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"F\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [15 x i8] c"Invalid base.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %51
14: ; preds = %2
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %15, i8* %18)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @strcpy(i8* %20, i8* %23)
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %14
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %51
35: ; preds = %28, %14
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp ne i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%42 = call i32 @toBaseFib(i8* %40, i8* %41)
br label %47
43: ; preds = %35
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%46 = call i32 @toBaseDec(i8* %44, i8* %45)
br label %47
47: ; preds = %43, %39
%48 = phi i32 [ %42, %39 ], [ %46, %43 ]
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%50 = call i32 @puts(i8* %49)
br label %51
51: ; preds = %47, %32, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"F\00"
@.str.2 = [3 x i8] c"10\00"
@str = [14 x i8] c"Invalid base.\00"
@str.4 = [34 x i8] c"This program takes TWO arguments.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = icmp eq i32 %0, 3
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.4, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
br label %39
10: ; preds = %2
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %11, i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strcpy(i8* %12, i8* %17)
%19 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %10
%22 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
br label %37
27: ; preds = %21, %10
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%29 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @toBaseFib(i8* %12, i8* %28)
br label %35
33: ; preds = %27
%34 = call i32 @toBaseDec(i8* %12, i8* %28)
br label %35
35: ; preds = %33, %31
%36 = call i32 @puts(i8* %28)
br label %37
37: ; preds = %35, %24
%38 = phi i32 [ %26, %24 ], [ 0, %35 ]
br label %39
39: ; preds = %37, %7
%40 = phi i32 [ %9, %7 ], [ %38, %37 ]
ret i32 %40
}