#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*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ wprintw(int /*<<< orphan*/ *, char *, unsigned long long);
void printlargenum(unsigned long long i, WINDOW *win) {
  if (i < 100000000)
    wprintw(win, "%9llu", i);
  else if (i < 1000000000)
    wprintw(win, "%8lluK", i / 1000);
  else if (i < 100000000000ULL)
    wprintw(win, "%8lluM", i / 1000000);
  else if (i < 100000000000000ULL)
    wprintw(win, "%8lluG", i / 1000000000ULL);
  else
    wprintw(win, "%8lluT", i / 1000000000000ULL);
}


x86 assembly (clang, -O0):
<printlargenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x5f5e100,-0x8(%rbp)
05
jae    1147 <printlargenum+0x37>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xec3(%rip),%rsi
call   1030 <wprintw@plt>
jmp    1224 <printlargenum+0x114>
cmpq   $0x3b9aca00,-0x8(%rbp)
3b
jae    117b <printlargenum+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0xe95(%rip),%rsi
call   1030 <wprintw@plt>
jmp    121f <printlargenum+0x10f>
movabs $0x174876e800,%rax
cmp    %rax,-0x8(%rbp)
jae    11b5 <printlargenum+0xa5>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0xe62(%rip),%rsi
call   1030 <wprintw@plt>
jmp    121a <printlargenum+0x10a>
movabs $0x5af3107a4000,%rax
cmp    %rax,-0x8(%rbp)
jae    11ef <printlargenum+0xdf>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    $0x3b9aca00,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0xe2f(%rip),%rsi
call   1030 <wprintw@plt>
jmp    1215 <printlargenum+0x105>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movabs $0xe8d4a51000,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
lea    0xe0b(%rip),%rsi
call   1030 <wprintw@plt>
jmp    121a <printlargenum+0x10a>
jmp    121f <printlargenum+0x10f>
jmp    1224 <printlargenum+0x114>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlargenum>:
mov    %rsi,%rcx
mov    %rdi,%rdx
cmp    $0x5f5e0ff,%rdi
ja     112e <printlargenum+0x1e>
lea    0xeda(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <wprintw@plt>
cmp    $0x3b9ac9ff,%rdx
ja     1153 <printlargenum+0x43>
mov    %edx,%eax
imul   $0x10624dd3,%rax,%rdx
shr    $0x26,%rdx
lea    0xebb(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <wprintw@plt>
mov    %rdx,%rax
shr    $0xb,%rax
cmp    $0x2e90edc,%rax
ja     1185 <printlargenum+0x75>
movabs $0x431bde82d7b634db,%rsi
de 1b 43
mov    %rdx,%rax
mul    %rsi
shr    $0x12,%rdx
lea    0xe90(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <wprintw@plt>
movabs $0x5af3107a3fff,%rax
cmp    %rax,%rdx
ja     11bb <printlargenum+0xab>
shr    $0x9,%rdx
movabs $0x44b82fa09b5a53,%rsi
mov    %rdx,%rax
mul    %rsi
shr    $0xb,%rdx
lea    0xe61(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <wprintw@plt>
movabs $0x232f33025bd42233,%rsi
33 2f 23
mov    %rdx,%rax
mul    %rsi
shr    $0x25,%rdx
lea    0xe45(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <wprintw@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%9llu\00"
@.str.1 = [7 x i8] c"%8lluK\00"
@.str.2 = [7 x i8] c"%8lluM\00"
@.str.3 = [7 x i8] c"%8lluG\00"
@.str.4 = [7 x i8] c"%8lluT\00"
define void @printlargenum(i64 %0, i32* %1) {
%3 = alloca i64
%4 = alloca i32*
store i64 %0, i64* %3
store i32* %1, i32** %4
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 100000000
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32*, i32** %4
%9 = load i64, i64* %3
%10 = call i32 @wprintw(i32* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %43
11: ; preds = %2
%12 = load i64, i64* %3
%13 = icmp ult i64 %12, 1000000000
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32*, i32** %4
%16 = load i64, i64* %3
%17 = udiv i64 %16, 1000
%18 = call i32 @wprintw(i32* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %42
19: ; preds = %11
%20 = load i64, i64* %3
%21 = icmp ult i64 %20, 100000000000
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32*, i32** %4
%24 = load i64, i64* %3
%25 = udiv i64 %24, 1000000
%26 = call i32 @wprintw(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %25)
br label %41
27: ; preds = %19
%28 = load i64, i64* %3
%29 = icmp ult i64 %28, 100000000000000
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32*, i32** %4
%32 = load i64, i64* %3
%33 = udiv i64 %32, 1000000000
%34 = call i32 @wprintw(i32* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %33)
br label %40
35: ; preds = %27
%36 = load i32*, i32** %4
%37 = load i64, i64* %3
%38 = udiv i64 %37, 1000000000000
%39 = call i32 @wprintw(i32* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %38)
br label %40
40: ; preds = %35, %30
br label %41
41: ; preds = %40, %22
br label %42
42: ; preds = %41, %14
br label %43
43: ; preds = %42, %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%9llu\00"
@.str.1 = [7 x i8] c"%8lluK\00"
@.str.2 = [7 x i8] c"%8lluM\00"
@.str.3 = [7 x i8] c"%8lluG\00"
@.str.4 = [7 x i8] c"%8lluT\00"
define void @printlargenum(i64 %0, i32* %1) {
%3 = icmp ult i64 %0, 100000000
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @wprintw(i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %26
6: ; preds = %2
%7 = icmp ult i64 %0, 1000000000
br i1 %7, label %8, label %13
8: ; preds = %6
%9 = trunc i64 %0 to i32
%10 = udiv i32 %9, 1000
%11 = zext i32 %10 to i64
%12 = tail call i32 @wprintw(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %11)
br label %26
13: ; preds = %6
%14 = icmp ult i64 %0, 100000000000
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = udiv i64 %0, 1000000
%17 = tail call i32 @wprintw(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %16)
br label %26
18: ; preds = %13
%19 = icmp ult i64 %0, 100000000000000
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = udiv i64 %0, 1000000000
%22 = tail call i32 @wprintw(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %21)
br label %26
23: ; preds = %18
%24 = udiv i64 %0, 1000000000000
%25 = tail call i32 @wprintw(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %8, %20, %23, %15, %4
ret void
}