#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*/ write(int, int *, int);
void decToBase(int number, int base) {
  int temp;
  int i = 0;
  int array[100];
  int arrayTemp[1];
  while (number) {
    array[i] = (number % base) + 48;
    i++;
    number = number / base;
  }
  array[i] = 0;
  for (temp = i; temp >= 0; temp--) {
    arrayTemp[0] = array[temp];
    if (arrayTemp[0] > 58) {
      arrayTemp[0] += (65 - 58);
    }
    write(1, arrayTemp, 1);
  }
}


x86 assembly (clang, -O0):
<decToBase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     115f <decToBase+0x4f>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
add    $0x30,%edx
movslq -0x10(%rbp),%rax
mov    %edx,-0x1a0(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x4(%rbp)
jmp    1128 <decToBase+0x18>
movslq -0x10(%rbp),%rax
movl   $0x0,-0x1a0(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11cc <decToBase+0xbc>
movslq -0xc(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1a4(%rbp)
cmpl   $0x3a,-0x1a4(%rbp)
jle    11ab <decToBase+0x9b>
mov    -0x1a4(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x1a4(%rbp)
lea    -0x1a4(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <decToBase+0x64>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decToBase>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
test   %edi,%edi
je     1156 <decToBase+0x46>
mov    %edi,%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltd
idiv   %esi
add    $0x30,%edx
mov    %edx,0x10(%rsp,%rcx,4)
add    $0x1,%rcx
test   %eax,%eax
jne    1130 <decToBase+0x20>
mov    %ecx,%ebx
movl   $0x0,0x10(%rsp,%rbx,4)
test   $0x80000000,%ecx
je     1160 <decToBase+0x50>
jmp    11bd <decToBase+0xad>
movl   $0x0,0x10(%rsp)
xor    %ebx,%ebx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
test   %rbx,%rbx
je     11bd <decToBase+0xad>
add    $0x1,%rbx
lea    0xc(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp,%rbx,4),%eax
lea    0x7(%rax),%ecx
cmp    $0x3b,%eax
cmovl  %eax,%ecx
mov    %ecx,0xc(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jg     1190 <decToBase+0x80>
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @decToBase(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i32]
%8 = alloca [1 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
br label %9
9: ; preds = %12, %2
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = srem i32 %13, %14
%16 = add nsw i32 %15, 48
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 %18
store i32 %16, i32* %19
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = sdiv i32 %22, %23
store i32 %24, i32* %3
br label %9
25: ; preds = %9
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 %27
store i32 0, i32* %28
%29 = load i32, i32* %6
store i32 %29, i32* %5
br label %30
30: ; preds = %49, %25
%31 = load i32, i32* %5
%32 = icmp sge i32 %31, 0
br i1 %32, label %33, label %52
33: ; preds = %30
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %7, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = getelementptr inbounds [1 x i32], [1 x i32]* %8, i64 0, i64 0
store i32 %37, i32* %38
%39 = getelementptr inbounds [1 x i32], [1 x i32]* %8, i64 0, i64 0
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 58
br i1 %41, label %42, label %46
42: ; preds = %33
%43 = getelementptr inbounds [1 x i32], [1 x i32]* %8, i64 0, i64 0
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 7
store i32 %45, i32* %43
br label %46
46: ; preds = %42, %33
%47 = getelementptr inbounds [1 x i32], [1 x i32]* %8, i64 0, i64 0
%48 = call i32 @write(i32 1, i32* %47, i32 1)
br label %49
49: ; preds = %46
%50 = load i32, i32* %5
%51 = add nsw i32 %50, -1
store i32 %51, i32* %5
br label %30
52: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @decToBase(i32 %0, i32 %1) {
%3 = alloca [100 x i32]
%4 = alloca [1 x i32]
%5 = bitcast [100 x i32]* %3 to i8*
%6 = bitcast [1 x i32]* %4 to i8*
%7 = icmp eq i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
store i32 0, i32* %9
br label %24
10: ; preds = %2, %10
%11 = phi i64 [ %16, %10 ], [ 0, %2 ]
%12 = phi i32 [ %17, %10 ], [ %0, %2 ]
%13 = srem i32 %12, %1
%14 = add nsw i32 %13, 48
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %11
store i32 %14, i32* %15
%16 = add nuw i64 %11, 1
%17 = sdiv i32 %12, %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %10
%20 = and i64 %16, 4294967295
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %20
store i32 0, i32* %21
%22 = and i64 %16, 2147483648
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %8, %19
%25 = phi i64 [ 0, %8 ], [ %20, %19 ]
%26 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 0
store i32 0, i32* %26
%27 = call i32 @write(i32 1, i32* %26, i32 1)
%28 = icmp eq i64 %25, 0
br i1 %28, label %39, label %29
29: ; preds = %24, %29
%30 = phi i64 [ %31, %29 ], [ %25, %24 ]
%31 = add nsw i64 %30, -1
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, 58
%35 = add nsw i32 %33, 7
%36 = select i1 %34, i32 %35, i32 %33
store i32 %36, i32* %26
%37 = call i32 @write(i32 1, i32* %26, i32 1)
%38 = icmp sgt i64 %30, 1
br i1 %38, label %29, label %39
39: ; preds = %29, %24, %19
ret void
}