#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;
    if (numberXX < 10) {
      printf("%d", numberXX);
    } else {
      printf("%c", 55 + 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    121c <main+0xec>
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)
cmpl   $0xa,-0x1c(%rbp)
jge    11ee <main+0xbe>
mov    -0x1c(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1202 <main+0xd2>
mov    -0x1c(%rbp),%esi
add    $0x37,%esi
lea    0xe0d(%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    0xde8(%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
cmp    $0x9,%eax
jg     11e0 <main+0xa0>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ea <main+0xaa>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x37,%eax
mov    %eax,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%eax
cltd
idiv   %ebp
mov    %edx,0x8(%rsp)
test   %ebx,%ebx
jle    1202 <main+0xc2>
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 = [3 x i8] c"%c\00"
@.str.4 = [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 = %53, %29
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, -1
br i1 %32, label %33, label %56
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 = icmp slt i32 %40, 10
br i1 %41, label %42, label %45
42: ; preds = %33
%43 = load i32, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %49
45: ; preds = %33
%46 = load i32, i32* %7
%47 = add nsw i32 55, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %45, %42
%50 = load i32, i32* %6
%51 = load i32, i32* %2
%52 = srem i32 %51, %50
store i32 %52, i32* %2
br label %53
53: ; preds = %49
%54 = load i32, i32* %4
%55 = add nsw i32 %54, -1
store i32 %55, i32* %4
br label %30
56: ; preds = %30
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, 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, %37
%22 = phi i32 [ %39, %37 ], [ %14, %15 ]
%23 = phi i32 [ %38, %37 ], [ %17, %15 ]
%24 = call i32 @powerBase(i32 %22, i32 %23)
%25 = load i32, i32* %1
%26 = sdiv i32 %25, %24
%27 = icmp slt i32 %26, 10
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %33
30: ; preds = %21
%31 = add nuw nsw i32 %26, 55
%32 = call i32 @putchar(i32 %31)
br label %33
33: ; preds = %30, %28
%34 = load i32, i32* %1
%35 = srem i32 %34, %24
store i32 %35, i32* %1
%36 = icmp sgt i32 %23, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = add nsw i32 %23, -1
%39 = load i32, i32* %2
br label %21
40: ; preds = %33
%41 = call i32 @putchar(i32 10)
ret i32 0
}