#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*/ fputc_cons(long);
void miniprintn(long number, unsigned char flag) {
  unsigned long i;
  if (flag && number < 0) {
    fputc_cons('-');
    number = -number;
  }
  if ((i = (unsigned long)number / 10L) != 0)
    miniprintn(i, flag);
  fputc_cons(number % 10 + '0');
}


x86 assembly (clang, -O0):
<miniprintn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x0,%eax
je     115e <miniprintn+0x3e>
cmpq   $0x0,-0x8(%rbp)
jge    115e <miniprintn+0x3e>
mov    $0x2d,%edi
call   1040 <fputc_cons@plt>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1187 <miniprintn+0x67>
mov    -0x18(%rbp),%rdi
movzbl -0x9(%rbp),%esi
call   1030 <miniprintn@plt>
mov    -0x8(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
add    $0x30,%rdi
call   1040 <fputc_cons@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<miniprintn>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rdi,%rdi
jns    113f <miniprintn+0x1f>
test   %bpl,%bpl
je     113f <miniprintn+0x1f>
mov    $0x2d,%edi
call   1040 <fputc_cons@plt>
neg    %rbx
cmp    $0xa,%rbx
jb     1165 <miniprintn+0x45>
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rdi
shr    $0x3,%rdi
movzbl %bpl,%esi
call   1030 <miniprintn@plt>
movabs $0x6666666666666667,%rcx
66 66 66
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
neg    %rax
lea    (%rbx,%rax,1),%rdi
add    $0x30,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fputc_cons@plt>

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

LLVM IR (-O2):
define void @miniprintn(i64 %0, i8 zeroext %1) {
%3 = icmp ne i8 %1, 0
%4 = icmp slt i64 %0, 0
%5 = and i1 %4, %3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @fputc_cons(i64 45)
%8 = sub nsw i64 0, %0
br label %9
9: ; preds = %6, %2
%10 = phi i64 [ %8, %6 ], [ %0, %2 ]
%11 = icmp ult i64 %10, 10
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = udiv i64 %10, 10
tail call void @miniprintn(i64 %13, i8 zeroext %1)
br label %14
14: ; preds = %12, %9
%15 = srem i64 %10, 10
%16 = add nsw i64 %15, 48
%17 = tail call i32 @fputc_cons(i64 %16)
ret void
}