#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*/ convert(int, char *, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int src_base, dest_base;
  char src_num[100] = {0}, dest_num[100] = {0};
  printf("Input a positive integer and its base, seperated by a space: ");
  scanf(" %s %d", src_num, &src_base);
  printf("What base do you want to convert (%s)%d into? (<= 16) ", src_num,
         src_base);
  scanf(" %d", &dest_base);
  if (dest_base > 16) {
    printf("Invalid input.\n");
  } else {
    convert(src_base, src_num, dest_base, dest_num);
    printf("%s\n", dest_num);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x10,-0xc(%rbp)
jle    11dd <main+0x9d>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1208 <main+0xc8>
mov    -0x8(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    -0xe0(%rbp),%rcx
call   1030 <convert@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xf0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xe0(%rsp)
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%edx
lea    0xe65(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe50(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%edx
cmp    $0x11,%edx
jl     120f <main+0xcf>
lea    0xe6f(%rip),%rdi
jmp    122b <main+0xeb>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x80(%rsp),%rbx
mov    %rbx,%rcx
call   1030 <convert@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Input a positive integer and its base, seperated by a space: \00"
@.str.1 = [7 x i8] c" %s %d\00"
@.str.2 = [55 x i8] c"What base do you want to convert (%s)%d into? (<= 16) \00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [16 x i8] c"Invalid input.\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
store i32 0, i32* %1
%6 = bitcast [100 x i8]* %4 to i8*
%7 = bitcast [100 x i8]* %5 to i8*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32* %2)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %11, i32 %12)
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 16
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %27
19: ; preds = %0
%20 = load i32, i32* %2
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%22 = load i32, i32* %3
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = call i32 @convert(i32 %20, i8* %21, i32 %22, i8* %23)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %19, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [62 x i8] c"Input a positive integer and its base, seperated by a space: \00"
@.str.1 = [7 x i8] c" %s %d\00"
@.str.2 = [55 x i8] c"What base do you want to convert (%s)%d into? (<= 16) \00"
@.str.3 = [4 x i8] c" %d\00"
@str = [15 x i8] c"Invalid input.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32* %1)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %7, i32 %11)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 16
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %22
18: ; preds = %0
%19 = load i32, i32* %1
%20 = call i32 @convert(i32 %19, i8* %7, i32 %14, i8* %8)
%21 = call i32 @puts(i8* %8)
br label %22
22: ; preds = %18, %16
ret i32 0
}