#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_put_char(int);
void my_put_number(int num) {
  int div = 1;
  if (num < 0) {
    my_put_char('-');
    num = -num;
  }
  while (num / div > 9 || num / div < -9)
    div = div * 10;
  while (div >= 1) {
    if (num > 0)
      my_put_char('0' + (num / div) % 10);
    else
      my_put_char('0' - (num / div) % 10);
    div = div / 10;
  }
}


x86 assembly (clang, -O0):
<my_put_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    113e <my_put_number+0x2e>
mov    $0x2d,%edi
call   1030 <my_put_char@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1143 <my_put_number+0x33>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x9(%rbp)
jg     116a <my_put_number+0x5a>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0xfffffff7,%eax
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    117a <my_put_number+0x6a>
jmp    1186 <my_put_number+0x76>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1143 <my_put_number+0x33>
jmp    118b <my_put_number+0x7b>
cmpl   $0x1,-0x8(%rbp)
jl     11eb <my_put_number+0xdb>
cmpl   $0x0,-0x4(%rbp)
jle    11bd <my_put_number+0xad>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <my_put_char@plt>
jmp    11d8 <my_put_number+0xc8>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x30,%edi
sub    %edx,%edi
call   1030 <my_put_char@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    118b <my_put_number+0x7b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_number>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
test   %edi,%edi
jns    1128 <my_put_number+0x18>
mov    $0x2d,%edi
call   1030 <my_put_char@plt>
neg    %r14d
lea    -0xa(%r14),%eax
mov    $0x1,%ebx
cmp    $0xffffffec,%eax
ja     1153 <my_put_number+0x43>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %r14d,%eax
cltd
idiv   %ebx
add    $0xfffffff6,%eax
cmp    $0xffffffed,%eax
jb     1140 <my_put_number+0x30>
mov    %r14d,%ebp
neg    %ebp
cmovs  %r14d,%ebp
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %rax,%rcx
imul   %r14,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
or     $0x30,%eax
mov    %eax,%edi
call   1030 <my_put_char@plt>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
cmp    $0x9,%ebx
mov    %eax,%ebx
ja     1170 <my_put_number+0x60>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @my_put_number(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_put_char(i32 45)
%8 = load i32, i32* %2
%9 = sub nsw i32 0, %8
store i32 %9, i32* %2
br label %10
10: ; preds = %6, %1
br label %11
11: ; preds = %23, %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 %21, label %16
16: ; preds = %11
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sdiv i32 %17, %18
%20 = icmp slt i32 %19, -9
br label %21
21: ; preds = %16, %11
%22 = phi i1 [ true, %11 ], [ %20, %16 ]
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 10
store i32 %25, i32* %3
br label %11
26: ; preds = %21
br label %27
27: ; preds = %47, %26
%28 = load i32, i32* %3
%29 = icmp sge i32 %28, 1
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = load i32, i32* %2
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = sdiv i32 %34, %35
%37 = srem i32 %36, 10
%38 = add nsw i32 48, %37
%39 = call i32 @my_put_char(i32 %38)
br label %47
40: ; preds = %30
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = sdiv i32 %41, %42
%44 = srem i32 %43, 10
%45 = sub nsw i32 48, %44
%46 = call i32 @my_put_char(i32 %45)
br label %47
47: ; preds = %40, %33
%48 = load i32, i32* %3
%49 = sdiv i32 %48, 10
store i32 %49, i32* %3
br label %27
50: ; preds = %27
ret void
}

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