#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*/ ft_putchar(char);
int ft_strlen(char *);
void ft_putmaxneg_base(int nbr, char *base) {
  if (nbr <= (-1 * ft_strlen(base))) {
    ft_putmaxneg_base(nbr / ft_strlen(base), base);
    ft_putmaxneg_base(nbr % ft_strlen(base), base);
  } else
    ft_putchar(base[-nbr]);
}


x86 assembly (clang, -O0):
<ft_putmaxneg_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   $0xffffffff,%ecx,%ecx
cmp    %ecx,%eax
jg     11aa <ft_putmaxneg_base+0x7a>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1050 <ft_putmaxneg_base@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x10(%rbp),%rsi
call   1050 <ft_putmaxneg_base@plt>
jmp    11bf <ft_putmaxneg_base+0x8f>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
sub    -0x4(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <ft_putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_putmaxneg_base>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <ft_strlen@plt>
neg    %eax
cmp    %ebp,%eax
jl     1188 <ft_putmaxneg_base+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <ft_putmaxneg_base@plt>
mov    %rbx,%rdi
call   1030 <ft_strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%ebp
mov    %rbx,%rdi
call   1030 <ft_strlen@plt>
neg    %eax
cmp    %eax,%ebp
jle    1150 <ft_putmaxneg_base+0x20>
movslq %ebp,%rax
sub    %rax,%rbx
movsbl (%rbx),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ft_putchar@plt>

LLVM IR (-O0):
define void @ft_putmaxneg_base(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = load i8*, i8** %4
%7 = call i32 @ft_strlen(i8* %6)
%8 = mul nsw i32 -1, %7
%9 = icmp sle i32 %5, %8
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load i32, i32* %3
%12 = load i8*, i8** %4
%13 = call i32 @ft_strlen(i8* %12)
%14 = sdiv i32 %11, %13
%15 = load i8*, i8** %4
%16 = load i32, i32* %3
%17 = load i8*, i8** %4
%18 = call i32 @ft_strlen(i8* %17)
%19 = srem i32 %16, %18
%20 = load i8*, i8** %4
br label %29
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = load i32, i32* %3
%24 = sub nsw i32 0, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @ft_putchar(i8 signext %27)
br label %29
29: ; preds = %21, %10
ret void
}

LLVM IR (-O2):
define void @ft_putmaxneg_base(i32 %0, i8* %1) {
%3 = tail call i32 @ft_strlen(i8* %1)
%4 = sub nsw i32 0, %3
%5 = icmp slt i32 %4, %0
br i1 %5, label %15, label %6
6: ; preds = %2, %6
%7 = phi i32 [ %11, %6 ], [ %0, %2 ]
%8 = tail call i32 @ft_strlen(i8* %1)
%9 = sdiv i32 %7, %8
tail call void @ft_putmaxneg_base(i32 %9, i8* %1)
%10 = tail call i32 @ft_strlen(i8* %1)
%11 = srem i32 %7, %10
%12 = tail call i32 @ft_strlen(i8* %1)
%13 = sub nsw i32 0, %12
%14 = icmp sgt i32 %11, %13
br i1 %14, label %15, label %6
15: ; preds = %6, %2
%16 = phi i32 [ %0, %2 ], [ %11, %6 ]
%17 = sub nsw i32 0, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
%21 = tail call i32 @ft_putchar(i8 signext %20)
ret void
}