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


x86 assembly (clang, -O0):
<ft_ulitobase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <ft_strnew@plt>
mov    %rax,0x2ee7(%rip)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     1194 <ft_ulitobase+0x54>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <ft_ulitobase@plt>
mov    0x2ead(%rip),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax,%rdx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2e85(%rip)
mov    0x2e7e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_ulitobase>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%edi
call   1040 <ft_strnew@plt>
mov    %rax,0x2eec(%rip)
mov    %r14,%rdi
call   1030 <ft_strlen@plt>
mov    %rax,%rbx
cmp    %r15,%rax
ja     1194 <ft_ulitobase+0x54>
mov    %r15,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1182 <ft_ulitobase+0x42>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
jmp    1189 <ft_ulitobase+0x49>
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <ft_ulitobase@plt>
mov    0x2ead(%rip),%rdi
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     11b1 <ft_ulitobase+0x71>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
jmp    11b8 <ft_ulitobase+0x78>
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
movsbl (%r14,%rdx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2e7f(%rip)
pop    %rbx
pop    %r14
pop    %r15
ret

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

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