#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 powerBase(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int number10, base;
  int power = 0;
  scanf("%d %d", &number10, &base);
  if (number10 < 0) {
    number10 *= -1;
    printf("-");
  }
  for (int dividend = number10 / base; dividend > 0; dividend /= base) {
    power += 1;
  }
  for (; power > -1; power--) {
    int basePower = powerBase(base, power);
    int numberXX = number10 / basePower;
    printf("%d", numberXX);
    number10 %= basePower;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1179 <main+0x49>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a7 <main+0x77>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    1183 <main+0x53>
jmp    11ac <main+0x7c>
cmpl   $0xffffffff,-0x10(%rbp)
jle    11f9 <main+0xc9>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <powerBase@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11ac <main+0x7c>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jns    117a <main+0x3a>
neg    %eax
mov    %eax,0x8(%rsp)
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%eax
mov    $0xffffffff,%ebx
mov    0xc(%rsp),%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cltd
idiv   %edi
add    $0x1,%ebx
test   %eax,%eax
jg     1190 <main+0x50>
lea    0xe62(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%esi
call   1060 <powerBase@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%eax
cltd
idiv   %ebp
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%eax
cltd
idiv   %ebp
mov    %edx,0x8(%rsp)
test   %ebx,%ebx
jle    11e4 <main+0xa4>
add    $0xffffffff,%ebx
mov    0xc(%rsp),%edi
jmp    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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