#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 get(int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(int argc, char *argv[]) {
  int a, b, i;
  char out[10000];
  scanf("%i%i", &a, &b);
  for (i = 0; a > 0; i++) {
    out[i] = get(a % b);
    a /= b;
  }
  for (i--; i >= 0; i--)
    printf("%c", out[i]);
  if (argc > 1)
    for (;;)
      ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a3 <main+0x73>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,%edi
call   1040 <get@plt>
mov    %al,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x2730(%rbp,%rax,1)
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1164 <main+0x34>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11dc <main+0xac>
movslq -0x1c(%rbp),%rax
lea    0xe44(%rip),%rdi
movsbl -0x2730(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x7c>
cmpl   $0x1,-0x8(%rbp)
jle    11f0 <main+0xc0>
jmp    11eb <main+0xbb>
jmp    11eb <main+0xbb>
xor    %eax,%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2720,%rsp
mov    %edi,%r14d
lea    0xebb(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    11ca <main+0x9a>
mov    0xc(%rsp),%ecx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <get@plt>
mov    %al,0x10(%rsp,%rbx,1)
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %eax,0x8(%rsp)
add    $0x1,%rbx
test   %eax,%eax
jg     1170 <main+0x40>
test   %ebx,%ebx
jle    11ca <main+0x9a>
mov    %ebx,%ebp
add    $0x1,%rbp
lea    0xe5f(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rbp),%eax
movsbl 0x10(%rsp,%rax,1),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     11b0 <main+0x80>
cmp    $0x2,%r14d
jl     11d2 <main+0xa2>
jmp    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%i%i\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10000 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %39
12: ; preds = %2
%13 = load i32, i32* %4
br label %19
14: ; preds = %19
%15 = trunc i64 %29 to i32
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = and i64 %29, 4294967295
br label %31
19: ; preds = %12, %19
%20 = phi i32 [ %13, %12 ], [ %26, %19 ]
%21 = phi i64 [ 0, %12 ], [ %29, %19 ]
%22 = phi i32 [ %10, %12 ], [ %28, %19 ]
%23 = srem i32 %22, %20
%24 = call signext i8 @get(i32 %23)
%25 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %21
store i8 %24, i8* %25
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = sdiv i32 %27, %26
store i32 %28, i32* %3
%29 = add nuw i64 %21, 1
%30 = icmp sgt i32 %28, 0
br i1 %30, label %19, label %14
31: ; preds = %17, %31
%32 = phi i64 [ %18, %17 ], [ %33, %31 ]
%33 = add nsw i64 %32, -1
%34 = and i64 %33, 4294967295
%35 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %36)
%38 = icmp ugt i64 %32, 1
br i1 %38, label %31, label %39
39: ; preds = %31, %2, %14
%40 = icmp sgt i32 %0, 1
br i1 %40, label %41, label %42
41: ; preds = %39, %41
br label %41
42: ; preds = %39
ret i32 0
}