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

/* Variables and functions */
int /*<<< orphan*/ wprintw(int /*<<< orphan*/ *, char *, unsigned long long,
                           char *);
void aligned_1024(WINDOW *pad, unsigned long long value) {
  char *prefix[] = {"", "ki", "mi", "gi", "ti", "pi"};
  unsigned i = 0;
  while (i < sizeof(prefix) / sizeof(*prefix)) {
    if (value < 10240)
      break;
    value = (value + 512) / 1024;
    i++;
  }
  if (!i)
    wprintw(pad, "  %5llu%s", value, prefix[i]);
  else
    wprintw(pad, "%5llu%s", value, prefix[i]);
}


x86 assembly (clang, -O0):
<aligned_1024>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xec1(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe9e(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe8e(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    $0x6,%rax
jae    11c9 <aligned_1024+0xa9>
cmpq   $0x2800,-0x10(%rbp)
jae    11a9 <aligned_1024+0x89>
jmp    11c9 <aligned_1024+0xa9>
mov    -0x10(%rbp),%rax
add    $0x200,%rax
shr    $0xa,%rax
mov    %rax,-0x10(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1189 <aligned_1024+0x69>
cmpl   $0x0,-0x44(%rbp)
jne    11f4 <aligned_1024+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x44(%rbp),%eax
mov    -0x40(%rbp,%rax,8),%rcx
lea    0xe25(%rip),%rsi
call   1040 <wprintw@plt>
jmp    1210 <aligned_1024+0xf0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x44(%rbp),%eax
mov    -0x40(%rbp,%rax,8),%rcx
lea    0xe06(%rip),%rsi
call   1040 <wprintw@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aligned_1024>:
mov    %rsi,%rax
lea    0xeee(%rip),%rcx
mov    %rcx,-0x38(%rsp)
lea    0xeda(%rip),%rcx
mov    %rcx,-0x30(%rsp)
lea    0xed1(%rip),%rcx
mov    %rcx,-0x28(%rsp)
lea    0xec8(%rip),%rcx
mov    %rcx,-0x20(%rsp)
lea    0xebf(%rip),%rcx
mov    %rcx,-0x18(%rsp)
lea    0xeb6(%rip),%rcx
mov    %rcx,-0x10(%rsp)
cmp    $0x2800,%rsi
jae    1178 <aligned_1024+0x68>
mov    -0x38(%rsp),%rcx
lea    0xe9f(%rip),%rsi
mov    %rax,%rdx
jmp    1030 <wprintw@plt>
add    $0x200,%rax
mov    %rax,%rdx
shr    $0xa,%rdx
mov    $0x1,%ecx
cmp    $0xa00000,%rax
jb     121d <aligned_1024+0x10d>
add    $0x200,%rdx
shr    $0xa,%rdx
mov    %rax,%rsi
shr    $0x13,%rsi
mov    $0x2,%ecx
cmp    $0x4fff,%rsi
jb     121d <aligned_1024+0x10d>
add    $0x200,%rdx
shr    $0xa,%rdx
mov    $0x3,%ecx
cmp    $0x13ffbff,%rsi
jb     121d <aligned_1024+0x10d>
add    $0x200,%rdx
shr    $0xa,%rdx
mov    $0x4,%ecx
movabs $0x27ff7fdff80000,%rsi
cmp    %rsi,%rax
jb     121d <aligned_1024+0x10d>
add    $0x200,%rdx
shr    $0xa,%rdx
mov    $0x5,%ecx
movabs $0x9ffdff7fdff80000,%rsi
ff fd 9f
cmp    %rsi,%rax
jb     121d <aligned_1024+0x10d>
add    $0x200,%rdx
shr    $0xa,%rdx
mov    $0x6,%ecx
mov    -0x38(%rsp,%rcx,8),%rcx
lea    0xde8(%rip),%rsi
jmp    1030 <wprintw@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"ki\00"
@.str.2 = [3 x i8] c"mi\00"
@.str.3 = [3 x i8] c"gi\00"
@.str.4 = [3 x i8] c"ti\00"
@.str.5 = [3 x i8] c"pi\00"
@.str.6 = [10 x i8] c" %5llu%s\00"
@.str.7 = [8 x i8] c"%5llu%s\00"
define void @aligned_1024(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca [6 x i8*]
%6 = alloca i32
store i32* %0, i32** %3
store i64 %1, i64* %4
%7 = bitcast [6 x i8*]* %5 to i8*
%8 = bitcast i8* %7 to [6 x i8*]*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i32 0, i32 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8** %14
store i32 0, i32* %6
br label %15
15: ; preds = %23, %2
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = icmp ult i64 %17, 6
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i64, i64* %4
%21 = icmp ult i64 %20, 10240
br i1 %21, label %22, label %23
22: ; preds = %19
br label %29
23: ; preds = %19
%24 = load i64, i64* %4
%25 = add i64 %24, 512
%26 = udiv i64 %25, 1024
store i64 %26, i64* %4
%27 = load i32, i32* %6
%28 = add i32 %27, 1
store i32 %28, i32* %6
br label %15
29: ; preds = %22, %15
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %40, label %32
32: ; preds = %29
%33 = load i32*, i32** %3
%34 = load i64, i64* %4
%35 = load i32, i32* %6
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @wprintw(i32* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %34, i8* %38)
br label %48
40: ; preds = %29
%41 = load i32*, i32** %3
%42 = load i64, i64* %4
%43 = load i32, i32* %6
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @wprintw(i32* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 %42, i8* %46)
br label %48
48: ; preds = %40, %32
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"ki\00"
@.str.2 = [3 x i8] c"mi\00"
@.str.3 = [3 x i8] c"gi\00"
@.str.4 = [3 x i8] c"ti\00"
@.str.5 = [3 x i8] c"pi\00"
@.str.6 = [10 x i8] c" %5llu%s\00"
@.str.7 = [8 x i8] c"%5llu%s\00"
define void @aligned_1024(i32* %0, i64 %1) {
%3 = alloca [6 x i8*]
%4 = bitcast [6 x i8*]* %3 to i8*
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %10
%11 = icmp ult i64 %1, 10240
br i1 %11, label %35, label %12
12: ; preds = %2
%13 = add i64 %1, 512
%14 = lshr i64 %13, 10
%15 = icmp ult i64 %13, 10485760
br i1 %15, label %39, label %16
16: ; preds = %12
%17 = add nuw nsw i64 %14, 512
%18 = lshr i64 %17, 10
%19 = icmp ult i64 %13, 10736893952
br i1 %19, label %39, label %20
20: ; preds = %16
%21 = add nuw nsw i64 %18, 512
%22 = lshr i64 %21, 10
%23 = icmp ult i64 %13, 10994578882560
br i1 %23, label %39, label %24
24: ; preds = %20
%25 = add nuw nsw i64 %22, 512
%26 = lshr i64 %25, 10
%27 = icmp ult i64 %13, 11258448775217152
br i1 %27, label %39, label %28
28: ; preds = %24
%29 = add nuw nsw i64 %26, 512
%30 = lshr i64 %29, 10
%31 = icmp ult i64 %13, -6918092527887712256
br i1 %31, label %39, label %32
32: ; preds = %28
%33 = add nuw nsw i64 %30, 512
%34 = lshr i64 %33, 10
br label %39
35: ; preds = %2
%36 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 0
%37 = load i8*, i8** %36
%38 = tail call i32 @wprintw(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %1, i8* %37)
br label %45
39: ; preds = %32, %28, %24, %20, %16, %12
%40 = phi i64 [ %14, %12 ], [ %18, %16 ], [ %22, %20 ], [ %26, %24 ], [ %30, %28 ], [ %34, %32 ]
%41 = phi i64 [ 1, %12 ], [ 2, %16 ], [ 3, %20 ], [ 4, %24 ], [ 5, %28 ], [ 6, %32 ]
%42 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = tail call i32 @wprintw(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 %40, i8* %43)
br label %45
45: ; preds = %39, %35
ret void
}