#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*/ strcpy(char *, char *);
int strlen(char *);
void transfrom_base_k(char *s, int n, int k) {
  if (n == 0) {
    strcpy(s, "");
    return;
  }
  int len;
  transfrom_base_k(s, n / k, k);
  len = strlen(s);
  s[len] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[n % k];
  s[len + 1] = '\0';
}


x86 assembly (clang, -O0):
<transfrom_base_k>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1161 <transfrom_base_k+0x31>
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b2 <transfrom_base_k+0x82>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
mov    -0x10(%rbp),%edx
call   1050 <transfrom_base_k@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
movslq %edx,%rcx
lea    0xe6d(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transfrom_base_k>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %esi,%esi
je     1175 <transfrom_base_k+0x45>
mov    %edx,%ecx
mov    %esi,%eax
cltd
idiv   %ecx
mov    %edx,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %ecx,%edx
call   1050 <transfrom_base_k@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %ebp,%rcx
lea    0xe9f(%rip),%rdx
mov    (%rcx,%rdx,1),%cl
cltq
mov    %cl,(%rbx,%rax,1)
movb   $0x0,0x1(%rbx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [37 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
define void @transfrom_base_k(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %8
ret void
8: ; preds = %3
%9 = sdiv i32 %1, %2
tail call void @transfrom_base_k(i8* %0, i32 %9, i32 %2)
%10 = tail call i32 @strlen(i8* %0)
%11 = srem i32 %1, %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [37 x i8], [37 x i8]* @.str.1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i32 %10 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 %14, i8* %16
%17 = add nsw i32 %10, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
br label %7
}