#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 */
struct Global {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ Putchar(struct Global *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
void Putint(struct Global *global, int number) {
  char buffer[16];
  char *point = buffer;
  sprintf(buffer, "%d", number);
  while (*point)
    Putchar(global, *point++);
}


x86 assembly (clang, -O0):
<Putint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xebb(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1177 <Putint+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%esi
call   1040 <Putchar@plt>
jmp    114a <Putint+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Putint>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%edx
mov    %rdi,%r14
lea    0xecd(%rip),%rsi
mov    %rsp,%rdi
call   1030 <sprintf@plt>
mov    (%rsp),%al
test   %al,%al
je     1166 <Putint+0x46>
lea    0x1(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r14,%rdi
call   1040 <Putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <Putint+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Global = type { i32 }
@.str = [3 x i8] c"%d\00"
define void @Putint(%struct.Global* %0, i32 %1) {
%3 = alloca %struct.Global*
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i8*
store %struct.Global* %0, %struct.Global** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
store i8* %7, i8** %6
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %15, %2
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load %struct.Global*, %struct.Global** %3
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %6
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
%21 = call i32 @Putchar(%struct.Global* %16, i32 %20)
br label %11
22: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.Global = type { i32 }
@.str = [3 x i8] c"%d\00"
define void @Putint(%struct.Global* %0, i32 %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = phi i8 [ %14, %8 ], [ %6, %2 ]
%10 = phi i8* [ %11, %8 ], [ %4, %2 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = sext i8 %9 to i32
%13 = tail call i32 @Putchar(%struct.Global* %0, i32 %12)
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %8, %2
ret void
}