#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);
int 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,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    113d <my_putnbr+0x2d>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <my_putnbr+0x32>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x9,%eax
jle    115e <my_putnbr+0x4e>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <my_putnbr+0x32>
jmp    1163 <my_putnbr+0x53>
cmpl   $0x0,-0xc(%rbp)
je     1199 <my_putnbr+0x89>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <my_putchar@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1163 <my_putnbr+0x53>
mov    -0x4(%rbp),%eax
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 i32 @my_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 @my_putchar(i32 45)
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, -1
store i32 %10, i32* %3
br label %11
11: ; preds = %7, %1
br label %12
12: ; preds = %17, %11
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = sdiv i32 %13, %14
%16 = icmp sgt i32 %15, 9
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %4
%19 = mul nsw i32 %18, 10
store i32 %19, i32* %4
br label %12
20: ; preds = %12
br label %21
21: ; preds = %24, %20
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = sdiv i32 %25, %26
%28 = srem i32 %27, 10
%29 = add nsw i32 %28, 48
%30 = call i32 @my_putchar(i32 %29)
%31 = load i32, i32* %4
%32 = sdiv i32 %31, 10
store i32 %32, i32* %4
br label %21
33: ; preds = %21
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @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 i32 undef
}