#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*/ write(int, char *, size_t);
void dynld_print_d(int val) {
  char buffer[64];
  char *put = buffer + 64;
  size_t sz = 0;
  do {
    *--put = '0' + (val % 10);
    val /= 10;
    sz++;
  } while (val != 0);
  write(2, put, sz);
}


x86 assembly (clang, -O0):
<dynld_print_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x50(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x58(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    112f <dynld_print_d+0x1f>
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    $0x2,%edi
call   1030 <write@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dynld_print_d>:
sub    $0x48,%rsp
lea    0x40(%rsp),%rsi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movslq %edi,%rax
imul   $0x66666667,%rax,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rdi
add    %ecx,%edi
lea    (%rdi,%rdi,1),%ecx
lea    (%rcx,%rcx,4),%r8d
mov    %eax,%ecx
sub    %r8d,%ecx
add    $0x30,%cl
mov    %cl,-0x1(%rsi)
add    $0xffffffffffffffff,%rsi
add    $0x1,%rdx
add    $0x9,%eax
cmp    $0x12,%eax
ja     1120 <dynld_print_d+0x10>
mov    $0x2,%edi
call   1030 <write@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
define void @dynld_print_d(i32 %0) {
%2 = alloca i32
%3 = alloca [64 x i8]
%4 = alloca i8*
%5 = alloca i64
store i32 %0, i32* %2
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i8, i8* %6, i64 64
store i8* %7, i8** %4
store i64 0, i64* %5
br label %8
8: ; preds = %19, %1
%9 = load i32, i32* %2
%10 = srem i32 %9, 10
%11 = add nsw i32 48, %10
%12 = trunc i32 %11 to i8
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 -1
store i8* %14, i8** %4
store i8 %12, i8* %14
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 10
store i32 %16, i32* %2
%17 = load i64, i64* %5
%18 = add i64 %17, 1
store i64 %18, i64* %5
br label %19
19: ; preds = %8
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 0
br i1 %21, label %8, label %22
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = load i64, i64* %5
%25 = call i32 @write(i32 2, i8* %23, i64 %24)
ret void
}

LLVM IR (-O2):
define void @dynld_print_d(i32 %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 64
br label %5
5: ; preds = %5, %1
%6 = phi i32 [ %0, %1 ], [ %13, %5 ]
%7 = phi i8* [ %4, %1 ], [ %12, %5 ]
%8 = phi i64 [ 0, %1 ], [ %14, %5 ]
%9 = srem i32 %6, 10
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 48
%12 = getelementptr inbounds i8, i8* %7, i64 -1
store i8 %11, i8* %12
%13 = sdiv i32 %6, 10
%14 = add i64 %8, 1
%15 = add i32 %6, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %17, label %5
17: ; preds = %5
%18 = call i32 @write(i32 2, i8* %12, i64 %14)
ret void
}