#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 */
char *concatenate_string(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
char *convertDecimalToBase(long inputNumber, int destBase) {
  if (inputNumber == 0)
    return "";
  long nextNumber = inputNumber / destBase;
  int digit = inputNumber % destBase;
  char digitCharArray[25];
  sprintf(digitCharArray, "%d", digit);
  char *newdigit = (char *)digitCharArray;
  char *finalDigit = NULL;
  if (strcmp(newdigit, "10") == 0)
    finalDigit = "A";
  else if (strcmp(newdigit, "11") == 0)
    finalDigit = "B";
  else if (strcmp(newdigit, "12") == 0)
    finalDigit = "C";
  else if (strcmp(newdigit, "13") == 0)
    finalDigit = "D";
  else if (strcmp(newdigit, "14") == 0)
    finalDigit = "E";
  else if (strcmp(newdigit, "15") == 0)
    finalDigit = "F";
  else
    finalDigit = newdigit;
  return concatenate_string(convertDecimalToBase(nextNumber, destBase),
                            finalDigit);
}


x86 assembly (clang, -O0):
<convertDecimalToBase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116a <convertDecimalToBase+0x2a>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e9 <convertDecimalToBase+0x1a9>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe65(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <convertDecimalToBase+0x9a>
lea    0xe35(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12cd <convertDecimalToBase+0x18d>
mov    -0x48(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1204 <convertDecimalToBase+0xc4>
lea    0xe10(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12c8 <convertDecimalToBase+0x188>
mov    -0x48(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122e <convertDecimalToBase+0xee>
lea    0xdeb(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12c3 <convertDecimalToBase+0x183>
mov    -0x48(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1258 <convertDecimalToBase+0x118>
lea    0xdc6(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12be <convertDecimalToBase+0x17e>
mov    -0x48(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1282 <convertDecimalToBase+0x142>
lea    0xda1(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12b9 <convertDecimalToBase+0x179>
mov    -0x48(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12ac <convertDecimalToBase+0x16c>
lea    0xd7c(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    12b4 <convertDecimalToBase+0x174>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    12b9 <convertDecimalToBase+0x179>
jmp    12be <convertDecimalToBase+0x17e>
jmp    12c3 <convertDecimalToBase+0x183>
jmp    12c8 <convertDecimalToBase+0x188>
jmp    12cd <convertDecimalToBase+0x18d>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <convertDecimalToBase@plt>
mov    %rax,%rdi
mov    -0x50(%rbp),%rsi
call   1050 <concatenate_string@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertDecimalToBase>:
test   %rdi,%rdi
je     116d <convertDecimalToBase+0x2d>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
movslq %esi,%rcx
mov    %rdi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1175 <convertDecimalToBase+0x35>
mov    %rdi,%rax
cqto
idiv   %rcx
mov    %rax,%r14
jmp    117e <convertDecimalToBase+0x3e>
lea    0xe91(%rip),%rax
ret
mov    %edi,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%r14d
lea    0xe7b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1216 <convertDecimalToBase+0xd6>
lea    0xe5d(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     121f <convertDecimalToBase+0xdf>
lea    0xe4e(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1228 <convertDecimalToBase+0xe8>
lea    0xe3f(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1231 <convertDecimalToBase+0xf1>
lea    0xe30(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     123a <convertDecimalToBase+0xfa>
lea    0xe1e(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
lea    0xe0f(%rip),%rbx
cmovne %r15,%rbx
jmp    1241 <convertDecimalToBase+0x101>
lea    0xde9(%rip),%rbx
jmp    1241 <convertDecimalToBase+0x101>
lea    0xde5(%rip),%rbx
jmp    1241 <convertDecimalToBase+0x101>
lea    0xde1(%rip),%rbx
jmp    1241 <convertDecimalToBase+0x101>
lea    0xddd(%rip),%rbx
jmp    1241 <convertDecimalToBase+0x101>
lea    0xdd9(%rip),%rbx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <convertDecimalToBase@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <concatenate_string@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [2 x i8] c"A\00"
@.str.4 = [3 x i8] c"11\00"
@.str.5 = [2 x i8] c"B\00"
@.str.6 = [3 x i8] c"12\00"
@.str.7 = [2 x i8] c"C\00"
@.str.8 = [3 x i8] c"13\00"
@.str.9 = [2 x i8] c"D\00"
@.str.10 = [3 x i8] c"14\00"
@.str.11 = [2 x i8] c"E\00"
@.str.12 = [3 x i8] c"15\00"
@.str.13 = [2 x i8] c"F\00"
define i8* @convertDecimalToBase(i64 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca [25 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i64 %0, i64* %4
store i32 %1, i32* %5
%11 = load i64, i64* %4
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %70
14: ; preds = %2
%15 = load i64, i64* %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = sdiv i64 %15, %17
store i64 %18, i64* %6
%19 = load i64, i64* %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = srem i64 %19, %21
%23 = trunc i64 %22 to i32
store i32 %23, i32* %7
%24 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 0
%25 = load i32, i32* %7
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [25 x i8], [25 x i8]* %8, i64 0, i64 0
store i8* %27, i8** %9
store i8* null, i8** %10
%28 = load i8*, i8** %9
%29 = call i64 @strcmp(i8* %28, 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 %32
31: ; preds = %14
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %10
br label %64
32: ; preds = %14
%33 = load i8*, i8** %9
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %10
br label %63
37: ; preds = %32
%38 = load i8*, i8** %9
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8** %10
br label %62
42: ; preds = %37
%43 = load i8*, i8** %9
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %10
br label %61
47: ; preds = %42
%48 = load i8*, i8** %9
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i8** %10
br label %60
52: ; preds = %47
%53 = load i8*, i8** %9
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8** %10
br label %59
57: ; preds = %52
%58 = load i8*, i8** %9
store i8* %58, i8** %10
br label %59
59: ; preds = %57, %56
br label %60
60: ; preds = %59, %51
br label %61
61: ; preds = %60, %46
br label %62
62: ; preds = %61, %41
br label %63
63: ; preds = %62, %36
br label %64
64: ; preds = %63, %31
%65 = load i64, i64* %6
%66 = load i32, i32* %5
%67 = call i8* @convertDecimalToBase(i64 %65, i32 %66)
%68 = load i8*, i8** %10
%69 = call i8* @concatenate_string(i8* %67, i8* %68)
store i8* %69, i8** %3
br label %70
70: ; preds = %64, %13
%71 = load i8*, i8** %3
ret i8* %71
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [2 x i8] c"A\00"
@.str.4 = [3 x i8] c"11\00"
@.str.5 = [2 x i8] c"B\00"
@.str.6 = [3 x i8] c"12\00"
@.str.7 = [2 x i8] c"C\00"
@.str.8 = [3 x i8] c"13\00"
@.str.9 = [2 x i8] c"D\00"
@.str.10 = [3 x i8] c"14\00"
@.str.11 = [2 x i8] c"E\00"
@.str.12 = [3 x i8] c"15\00"
@.str.13 = [2 x i8] c"F\00"
define i8* @convertDecimalToBase(i64 %0, i32 %1) {
%3 = alloca [25 x i8]
%4 = icmp eq i64 %0, 0
br i1 %4, label %34, label %5
5: ; preds = %2
%6 = sext i32 %1 to i64
%7 = sdiv i64 %0, %6
%8 = srem i64 %0, %6
%9 = trunc i64 %8 to i32
%10 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %5
%15 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %30, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %17
%21 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* %10
br label %30
30: ; preds = %26, %23, %20, %17, %14, %5
%31 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %14 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %17 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %20 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), %23 ], [ %29, %26 ]
%32 = call i8* @convertDecimalToBase(i64 %7, i32 %1)
%33 = call i8* @concatenate_string(i8* %32, i8* %31)
br label %34
34: ; preds = %2, %30
%35 = phi i8* [ %33, %30 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %35
}