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


x86 assembly (clang, -O0):
<ft_litobase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <ft_strnew@plt>
mov    %rax,0x2ee7(%rip)
mov    -0x10(%rbp),%rdi
call   1040 <ft_strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    1182 <ft_litobase+0x42>
imul   $0xffffffffffffffff,-0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jl     11a6 <ft_litobase+0x66>
mov    -0x8(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <ft_litobase@plt>
mov    0x2e9b(%rip),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax,%rdx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2e75(%rip)
mov    0x2e6e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_litobase>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x1,%edi
call   1050 <ft_strnew@plt>
mov    %rax,0x2ee9(%rip)
mov    %r14,%rdi
call   1040 <ft_strlen@plt>
mov    %rax,%r15
mov    %r12,%rbx
neg    %rbx
cmovs  %r12,%rbx
cmp    %rax,%rbx
jl     11a1 <ft_litobase+0x61>
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     118f <ft_litobase+0x4f>
mov    %rbx,%rax
cqto
idiv   %r15
jmp    1196 <ft_litobase+0x56>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <ft_litobase@plt>
mov    0x2ea0(%rip),%rdi
mov    %r15,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11be <ft_litobase+0x7e>
mov    %rbx,%rax
cqto
idiv   %r15
jmp    11c5 <ft_litobase+0x85>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
movsbl (%r14,%rdx,1),%esi
call   1060 <ft_chrjoin@plt>
mov    %rax,0x2e72(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ft_litobase.ret = internal global i8* null
define i8* @ft_litobase(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_litobase.ret
%7 = load i8*, i8** %4
%8 = call i64 @ft_strlen(i8* %7)
store i64 %8, i64* %5
%9 = load i64, i64* %3
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i64, i64* %3
%13 = mul nsw i64 %12, -1
store i64 %13, i64* %3
br label %14
14: ; preds = %11, %2
%15 = load i64, i64* %3
%16 = load i64, i64* %5
%17 = icmp sge i64 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i64, i64* %3
%20 = load i64, i64* %5
%21 = sdiv i64 %19, %20
%22 = load i8*, i8** %4
%23 = call i8* @ft_litobase(i64 %21, i8* %22)
br label %24
24: ; preds = %18, %14
%25 = load i8*, i8** @ft_litobase.ret
%26 = load i8*, i8** %4
%27 = load i64, i64* %3
%28 = load i64, i64* %5
%29 = srem i64 %27, %28
%30 = getelementptr inbounds i8, i8* %26, i64 %29
%31 = load i8, i8* %30
%32 = call i8* @ft_chrjoin(i8* %25, i8 signext %31)
store i8* %32, i8** @ft_litobase.ret
%33 = load i8*, i8** @ft_litobase.ret
ret i8* %33
}

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