#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 */
scalar_t__ char_to_str(int /*<<< orphan*/);
char *my_select_dict(int);
char *my_strcat(char *, scalar_t__);
int /*<<< orphan*/ str_to_char(char *);
char *my_putnbr_base(int nbr, int base, int dict) {
  char *nbr_convert;
  char *tab_base = my_select_dict(dict);
  if (nbr < base) {
    return (char *)char_to_str(str_to_char(tab_base + nbr));
  } else {
    nbr_convert = my_strcat(my_putnbr_base(nbr / base, base, dict),
                            char_to_str(str_to_char(tab_base + (nbr % base))));
    return (char *)nbr_convert;
  }
}


x86 assembly (clang, -O0):
<my_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <my_select_dict@plt>
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1199 <my_putnbr_base+0x49>
mov    -0x28(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
call   1060 <str_to_char@plt>
mov    %eax,%edi
call   1070 <char_to_str@plt>
mov    %rax,-0x8(%rbp)
jmp    11e6 <my_putnbr_base+0x96>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <my_putnbr_base@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
movslq %edx,%rax
add    %rax,%rdi
call   1060 <str_to_char@plt>
mov    %eax,%edi
call   1070 <char_to_str@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   1050 <my_strcat@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr_base>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    %edx,%edi
call   1040 <my_select_dict@plt>
mov    %rax,%rbx
cmp    %r15d,%ebp
jge    118d <my_putnbr_base+0x3d>
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <str_to_char@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <char_to_str@plt>
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %edx,%ebp
mov    %eax,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1030 <my_putnbr_base@plt>
mov    %rax,%r14
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,%rdi
call   1060 <str_to_char@plt>
mov    %eax,%edi
call   1070 <char_to_str@plt>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <my_strcat@plt>

LLVM IR (-O0):
define i8* @my_putnbr_base(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = call i8* @my_select_dict(i32 %10)
store i8* %11, i8** %9
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %3
%16 = load i8*, i8** %9
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = call i32 @str_to_char(i8* %19)
%21 = call i64 @char_to_str(i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %4
br label %40
23: ; preds = %3
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = sdiv i32 %24, %25
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i8* @my_putnbr_base(i32 %26, i32 %27, i32 %28)
%30 = load i8*, i8** %9
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = srem i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
%36 = call i32 @str_to_char(i8* %35)
%37 = call i64 @char_to_str(i32 %36)
%38 = call i8* @my_strcat(i8* %29, i64 %37)
store i8* %38, i8** %8
%39 = load i8*, i8** %8
store i8* %39, i8** %4
br label %40
40: ; preds = %23, %15
%41 = load i8*, i8** %4
ret i8* %41
}

LLVM IR (-O2):
define i8* @my_putnbr_base(i32 %0, i32 %1, i32 %2) {
%4 = tail call i8* @my_select_dict(i32 %2)
%5 = icmp slt i32 %0, %1
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = sext i32 %0 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = tail call i32 @str_to_char(i8* %8)
%10 = tail call i64 @char_to_str(i32 %9)
%11 = inttoptr i64 %10 to i8*
br label %12
12: ; preds = %6, %14
%13 = phi i8* [ %22, %14 ], [ %11, %6 ]
ret i8* %13
14: ; preds = %3
%15 = sdiv i32 %0, %1
%16 = tail call i8* @my_putnbr_base(i32 %15, i32 %1, i32 %2)
%17 = srem i32 %0, %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %4, i64 %18
%20 = tail call i32 @str_to_char(i8* %19)
%21 = tail call i64 @char_to_str(i32 %20)
%22 = tail call i8* @my_strcat(i8* %16, i64 %21)
br label %12
}