#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 my_pow(int);
int my_putstr(char *);
int my_putnbr_write(int car, int nbr_save, int writed) {
  char nbr_put[car + 1];
  int i;
  i = 0;
  while (car > 0) {
    nbr_put[i++] = nbr_save % my_pow(car) / my_pow(car - 1) + 48;
    car--;
  }
  nbr_put[i] = 0;
  return (writed + my_putstr(nbr_put));
}


x86 assembly (clang, -O0):
<my_putnbr_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11c1 <my_putnbr_write+0xa1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <my_pow@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <my_pow@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
add    $0x30,%ecx
mov    %cl,%dl
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1161 <my_putnbr_write+0x41>
mov    -0x30(%rbp),%rdi
movslq -0x24(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
call   1040 <my_putstr@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr_write>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %edi,%ebx
lea    0x1(%rbx),%eax
mov    %rsp,%rdi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
test   %ebx,%ebx
jle    11b7 <my_putnbr_write+0x97>
mov    %esi,%r12d
mov    %r14d,-0x2c(%rbp)
mov    %ebx,%eax
mov    %rax,-0x38(%rbp)
neg    %rax
mov    %rax,-0x40(%rbp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdi,%r14
mov    %ebx,%edi
call   1030 <my_pow@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
mov    %edx,%r13d
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1030 <my_pow@plt>
mov    %r14,%rdi
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
add    $0x30,%al
mov    %al,(%r14,%r15,1)
add    $0x1,%r15
mov    -0x40(%rbp),%rax
add    %r15,%rax
jne    1170 <my_putnbr_write+0x50>
mov    -0x2c(%rbp),%r14d
mov    -0x38(%rbp),%rax
jmp    11b9 <my_putnbr_write+0x99>
xor    %eax,%eax
movb   $0x0,(%rdi,%rax,1)
call   1040 <my_putstr@plt>
add    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_putnbr_write(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
store i32 0, i32* %9
br label %15
15: ; preds = %18, %3
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = call i32 @my_pow(i32 %20)
%22 = srem i32 %19, %21
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = call i32 @my_pow(i32 %24)
%26 = sdiv i32 %22, %25
%27 = add nsw i32 %26, 48
%28 = trunc i32 %27 to i8
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %14, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
br label %15
35: ; preds = %15
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %14, i64 %37
store i8 0, i8* %38
%39 = load i32, i32* %6
%40 = call i32 @my_putstr(i8* %14)
%41 = add nsw i32 %39, %40
%42 = load i8*, i8** %7
ret i32 %41
}

LLVM IR (-O2):
define i32 @my_putnbr_write(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %0, 1
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %25
8: ; preds = %3
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %20, %10 ]
%12 = phi i32 [ %0, %8 ], [ %15, %10 ]
%13 = tail call i32 @my_pow(i32 %12)
%14 = srem i32 %1, %13
%15 = add nsw i32 %12, -1
%16 = tail call i32 @my_pow(i32 %15)
%17 = sdiv i32 %14, %16
%18 = trunc i32 %17 to i8
%19 = add i8 %18, 48
%20 = add nuw nsw i64 %11, 1
%21 = getelementptr inbounds i8, i8* %6, i64 %11
store i8 %19, i8* %21
%22 = icmp eq i64 %20, %9
br i1 %22, label %23, label %10
23: ; preds = %10
%24 = zext i32 %0 to i64
br label %25
25: ; preds = %3, %23
%26 = phi i64 [ %24, %23 ], [ 0, %3 ]
%27 = getelementptr inbounds i8, i8* %6, i64 %26
store i8 0, i8* %27
%28 = call i32 @my_putstr(i8* %6)
%29 = add nsw i32 %28, %2
ret i32 %29
}