#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*/ printf(char *, ...);
void ConvertDecToOther(int newbase, int value) {
  int level;
  int stack[100];
  level = 0;
  while (value != 0) {
    stack[level++] = value % newbase;
    value = value / newbase;
  }
  for (; level > 0; level--) {
    printf("%d", stack[level - 1]);
    if ((level - 1) % 4 == 0) {
      printf(" ");
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<ConvertDecToOther>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     115c <ConvertDecToOther+0x4c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    %edx,-0x1a0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x8(%rbp)
jmp    1128 <ConvertDecToOther+0x18>
jmp    1161 <ConvertDecToOther+0x51>
cmpl   $0x0,-0xc(%rbp)
jle    11c0 <ConvertDecToOther+0xb0>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ad <ConvertDecToOther+0x9d>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <ConvertDecToOther+0xa2>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1161 <ConvertDecToOther+0x51>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertDecToOther>:
push   %r15
push   %r14
push   %rbx
sub    $0x190,%rsp
test   %esi,%esi
je     11a0 <ConvertDecToOther+0x80>
mov    %esi,%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltd
idiv   %edi
mov    %edx,(%rsp,%rcx,4)
add    $0x1,%rcx
test   %eax,%eax
jne    1140 <ConvertDecToOther+0x20>
test   %ecx,%ecx
jle    11a0 <ConvertDecToOther+0x80>
mov    %ecx,%ebx
add    $0x1,%rbx
lea    0xea1(%rip),%r14
jmp    117a <ConvertDecToOther+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jbe    11a0 <ConvertDecToOther+0x80>
lea    -0x2(%rbx),%r15
mov    %r15d,%eax
mov    (%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x3,%r15b
jne    1170 <ConvertDecToOther+0x50>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1170 <ConvertDecToOther+0x50>
mov    $0xa,%edi
add    $0x190,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @ConvertDecToOther(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %10, %2
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = srem i32 %11, %12
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %16
store i32 %13, i32* %17
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = sdiv i32 %18, %19
store i32 %20, i32* %4
br label %7
21: ; preds = %7
br label %22
22: ; preds = %39, %21
%23 = load i32, i32* %5
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %22
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 1
%34 = srem i32 %33, 4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %25
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
br label %22
42: ; preds = %22
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @ConvertDecToOther(i32 %0, i32 %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
%5 = icmp eq i32 %1, 0
br i1 %5, label %32, label %11
6: ; preds = %11
%7 = trunc i64 %15 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = and i64 %15, 4294967295
br label %19
11: ; preds = %2, %11
%12 = phi i64 [ %15, %11 ], [ 0, %2 ]
%13 = phi i32 [ %17, %11 ], [ %1, %2 ]
%14 = srem i32 %13, %0
%15 = add nuw i64 %12, 1
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %12
store i32 %14, i32* %16
%17 = sdiv i32 %13, %0
%18 = icmp eq i32 %17, 0
br i1 %18, label %6, label %11
19: ; preds = %9, %30
%20 = phi i64 [ %10, %9 ], [ %21, %30 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = and i64 %21, 3
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = tail call i32 @putchar(i32 32)
br label %30
30: ; preds = %19, %28
%31 = icmp ugt i64 %20, 1
br i1 %31, label %19, label %32
32: ; preds = %30, %2, %6
%33 = tail call i32 @putchar(i32 10)
ret void
}