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


x86 assembly (clang, -O0):
<miniprintn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1161 <miniprintn+0x41>
cmpl   $0x0,-0x4(%rbp)
jge    1161 <miniprintn+0x41>
mov    -0x10(%rbp),%rsi
mov    $0x2d,%edi
call   1040 <fputc@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     1189 <miniprintn+0x69>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
movzbl -0x11(%rbp),%edx
call   1030 <miniprintn@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x30,%edi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<miniprintn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %edi,%ebp
test   %edi,%edi
jns    1147 <miniprintn+0x27>
test   %r15b,%r15b
je     1147 <miniprintn+0x27>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
neg    %ebp
mov    %ebp,%ebx
cmp    $0xa,%ebp
jb     1167 <miniprintn+0x47>
mov    $0xcccccccd,%edi
imul   %rbx,%rdi
shr    $0x23,%rdi
movzbl %r15b,%edx
mov    %r14,%rsi
call   1030 <miniprintn@plt>
mov    $0xcccccccd,%eax
imul   %rbx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputc@plt>

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

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