#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ printc(int /*<<< orphan*/ *, int);
void printd(FILE *fp, int n) {
  int c;
  if (n < 0) {
    printc(fp, '-');
    if ((n = -n) < 0)
      n = 0;
  }
  c = n % 10 + '0';
  n /= 10;
  if (n != 0)
    printd(fp, n);
  printc(fp, c);
}


x86 assembly (clang, -O0):
<printd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1164 <printd+0x44>
mov    -0x8(%rbp),%rdi
mov    $0x2d,%esi
call   1040 <printc@plt>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    115f <printd+0x3f>
movl   $0x0,-0xc(%rbp)
jmp    1164 <printd+0x44>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1199 <printd+0x79>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <printd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <printc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printd>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
test   %esi,%esi
jns    113d <printd+0x1d>
mov    %r14,%rdi
mov    $0x2d,%esi
call   1040 <printc@plt>
neg    %ebx
mov    %ebx,%r15d
cmp    $0xa,%ebx
jb     115a <printd+0x3a>
mov    $0xcccccccd,%esi
imul   %r15,%rsi
shr    $0x23,%rsi
mov    %r14,%rdi
call   1030 <printd@plt>
mov    $0xcccccccd,%eax
imul   %r15,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printc@plt>

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

LLVM IR (-O2):
define void @printd(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @printc(i32* %0, i32 45)
%6 = sub nsw i32 0, %1
br label %7
7: ; preds = %4, %2
%8 = phi i32 [ %6, %4 ], [ %1, %2 ]
%9 = icmp ult i32 %8, 10
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = udiv i32 %8, 10
tail call void @printd(i32* %0, i32 %11)
br label %12
12: ; preds = %10, %7
%13 = urem i32 %8, 10
%14 = or i32 %13, 48
%15 = tail call i32 @printc(i32* %0, i32 %14)
ret void
}