#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 *ft_chrjoin(char *, char);
scalar_t__ ft_strlen(char *);
char *ft_strnew(int);
char *ft_uitobase(unsigned int n, char *str) {
  unsigned int base;
  static char *ret;
  ret = ft_strnew(1);
  base = (unsigned int)ft_strlen(str);
  if (n >= base)
    ft_uitobase(n / base, str);
  ret = ft_chrjoin(ret, str[(n % base)]);
  return (ret);
}


x86 assembly (clang, -O0):
<ft_uitobase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <ft_strnew@plt>
mov    %rax,0x2ee8(%rip)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x14(%rbp),%eax
jb     118b <ft_uitobase+0x4b>
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x14(%rbp)
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <ft_uitobase@plt>
mov    0x2eb6(%rip),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x14(%rbp)
mov    -0x20(%rbp),%rax
mov    %edx,%ecx
movsbl (%rax,%rcx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2e90(%rip)
mov    0x2e89(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_uitobase>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x1,%edi
call   1050 <ft_strnew@plt>
mov    %rax,0x2eee(%rip)
mov    %r14,%rdi
call   1030 <ft_strlen@plt>
mov    %rax,%rbx
cmp    %ebp,%ebx
ja     1179 <ft_uitobase+0x39>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <ft_uitobase@plt>
mov    0x2ec8(%rip),%rdi
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
movsbl (%r14,%rdx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2eb1(%rip)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@ft_uitobase.ret = internal global i8* null
define i8* @ft_uitobase(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call i8* @ft_strnew(i32 1)
store i8* %6, i8** @ft_uitobase.ret
%7 = load i8*, i8** %4
%8 = call i64 @ft_strlen(i8* %7)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = icmp uge i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = udiv i32 %14, %15
%17 = load i8*, i8** %4
%18 = call i8* @ft_uitobase(i32 %16, i8* %17)
br label %19
19: ; preds = %13, %2
%20 = load i8*, i8** @ft_uitobase.ret
%21 = load i8*, i8** %4
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = urem i32 %22, %23
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i8, i8* %26
%28 = call i8* @ft_chrjoin(i8* %20, i8 signext %27)
store i8* %28, i8** @ft_uitobase.ret
%29 = load i8*, i8** @ft_uitobase.ret
ret i8* %29
}

LLVM IR (-O2):
@ft_uitobase.ret = internal unnamed_addr global i8* null
define i8* @ft_uitobase(i32 %0, i8* %1) {
%3 = tail call i8* @ft_strnew(i32 1)
store i8* %3, i8** @ft_uitobase.ret
%4 = tail call i64 @ft_strlen(i8* %1)
%5 = trunc i64 %4 to i32
%6 = icmp ugt i32 %5, %0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = udiv i32 %0, %5
%9 = tail call i8* @ft_uitobase(i32 %8, i8* %1)
br label %10
10: ; preds = %7, %2
%11 = load i8*, i8** @ft_uitobase.ret
%12 = urem i32 %0, %5
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = tail call i8* @ft_chrjoin(i8* %11, i8 signext %15)
store i8* %16, i8** @ft_uitobase.ret
ret i8* %16
}