#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 atoi(char *);
int /*<<< orphan*/ convertFromBase10(int, int);
int convertToBase10(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ validateBase(char *, int, int);
main(int argc, char *argv[]) {
  if (argv[1] == NULL || argv[2] == NULL || argv[3] == NULL) {
    printf("Usage convert <number> <from_base> <to_base>\n");
    exit(0);
  }
  int frombase, tobase;
  frombase = atoi(argv[2]);
  tobase = atoi(argv[3]);
  validateBase(argv[1], frombase, tobase);
  int tmp;
  tmp = convertToBase10(argv[1], frombase);
  convertFromBase10(tmp, tobase);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     119c <main+0x3c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     119c <main+0x3c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
jne    11af <main+0x4f>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <validateBase@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1060 <convertToBase10@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <convertFromBase10@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%r14
test   %r14,%r14
je     11c5 <main+0x65>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
test   %rdi,%rdi
je     11c5 <main+0x65>
mov    0x18(%rbx),%r15
test   %r15,%r15
je     11c5 <main+0x65>
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <validateBase@plt>
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
call   1060 <convertToBase10@plt>
mov    %eax,%edi
mov    %r15d,%esi
call   1030 <convertFromBase10@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"Usage convert <number> <from_base> <to_base>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %22, label %12
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17, %12, %2
%23 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %17
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %5
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %5
%38 = load i32, i32* %6
%39 = call i32 @validateBase(i8* %36, i32 %37, i32 %38)
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i32, i32* %5
%44 = call i32 @convertToBase10(i8* %42, i32 %43)
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = load i32, i32* %6
%47 = call i32 @convertFromBase10(i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@str = [45 x i8] c"Usage convert <number> <from_base> <to_base>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10, %6, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %10
%18 = tail call i32 @atoi(i8* %8)
%19 = tail call i32 @atoi(i8* %12)
%20 = tail call i32 @validateBase(i8* %4, i32 %18, i32 %19)
%21 = load i8*, i8** %3
%22 = tail call i32 @convertToBase10(i8* %21, i32 %18)
%23 = tail call i32 @convertFromBase10(i32 %22, i32 %19)
ret i32 0
}