#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*/ my_putchar(int);
void my_putnbr(int nb) {
  int div;
  div = 1;
  if (nb < 0) {
    my_putchar('-');
    nb = nb * -1;
  }
  while (nb / div > 9)
    div = div * 10;
  while (div != 0) {
    my_putchar(nb / div % 10 + '0');
    div = div / 10;
  }
}


x86 assembly (clang, -O0):
<my_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    113d <my_putnbr+0x2d>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1142 <my_putnbr+0x32>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x9,%eax
jle    115e <my_putnbr+0x4e>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <my_putnbr+0x32>
jmp    1163 <my_putnbr+0x53>
cmpl   $0x0,-0x8(%rbp)
je     1199 <my_putnbr+0x89>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1163 <my_putnbr+0x53>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
test   %edi,%edi
jns    1125 <my_putnbr+0x15>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
neg    %ebp
mov    $0x1,%ebx
cmp    $0xa,%ebp
jb     1150 <my_putnbr+0x40>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ebp,%eax
cltd
idiv   %ebx
cmp    $0x9,%eax
jg     1140 <my_putnbr+0x30>
nop
mov    %ebp,%eax
cltd
idiv   %ebx
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x30,%edi
call   1030 <my_putchar@plt>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
add    $0x9,%eax
cmp    $0x12,%eax
ja     1150 <my_putnbr+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @my_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = call i32 @my_putchar(i32 45)
%8 = load i32, i32* %2
%9 = mul nsw i32 %8, -1
store i32 %9, i32* %2
br label %10
10: ; preds = %6, %1
br label %11
11: ; preds = %16, %10
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = sdiv i32 %12, %13
%15 = icmp sgt i32 %14, 9
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 10
store i32 %18, i32* %3
br label %11
19: ; preds = %11
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = sdiv i32 %24, %25
%27 = srem i32 %26, 10
%28 = add nsw i32 %27, 48
%29 = call i32 @my_putchar(i32 %28)
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 10
store i32 %31, i32* %3
br label %20
32: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @my_putnbr(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @my_putchar(i32 45)
%5 = sub nsw i32 0, %0
br label %6
6: ; preds = %3, %1
%7 = phi i32 [ %5, %3 ], [ %0, %1 ]
%8 = icmp ugt i32 %7, 9
br i1 %8, label %9, label %14
9: ; preds = %6, %9
%10 = phi i32 [ %11, %9 ], [ 1, %6 ]
%11 = mul nuw nsw i32 %10, 10
%12 = sdiv i32 %7, %11
%13 = icmp sgt i32 %12, 9
br i1 %13, label %9, label %14
14: ; preds = %9, %6
%15 = phi i32 [ 1, %6 ], [ %11, %9 ]
br label %16
16: ; preds = %14, %16
%17 = phi i32 [ %22, %16 ], [ %15, %14 ]
%18 = sdiv i32 %7, %17
%19 = srem i32 %18, 10
%20 = add nsw i32 %19, 48
%21 = tail call i32 @my_putchar(i32 %20)
%22 = sdiv i32 %17, 10
%23 = add i32 %17, 9
%24 = icmp ult i32 %23, 19
br i1 %24, label %25, label %16
25: ; preds = %16
ret void
}