#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*/ term_print_decu(unsigned long);
int /*<<< orphan*/ term_putchar(char const);
void term_print_size(unsigned long size) {
  const char prefixes[] = "KMGTP";
  int i = 0;
  for (; (size >> 10 * i) > 1024; i++)
    ;
  term_print_decu(size >> 10 * i);
  if (i > 0) {
    term_putchar(prefixes[i - 1]);
    term_putchar('i');
  }
  term_putchar('B');
}


x86 assembly (clang, -O0):
<term_print_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0xe(%rbp)
mov    0xec8(%rip),%ax
mov    %ax,-0xa(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xa,-0x14(%rbp),%ecx
mov    %ecx,%ecx
shr    %cl,%rax
cmp    $0x400,%rax
jbe    1173 <term_print_size+0x53>
jmp    1165 <term_print_size+0x45>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <term_print_size+0x27>
mov    -0x8(%rbp),%rdi
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
shr    %cl,%rdi
call   1030 <term_print_decu@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11ad <term_print_size+0x8d>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xe(%rbp,%rax,1),%edi
call   1040 <term_putchar@plt>
mov    $0x69,%edi
call   1040 <term_putchar@plt>
mov    $0x42,%edi
call   1040 <term_putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_print_size>:
push   %rbx
xor    %edx,%edx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,%ecx
and    $0xfe,%cl
mov    %rdi,%rax
shr    %cl,%rax
add    $0xffffffffffffffff,%rbx
add    $0xa,%rdx
cmp    $0x400,%rax
ja     1130 <term_print_size+0x10>
mov    %rax,%rdi
call   1030 <term_print_decu@plt>
cmp    $0xffffffff,%ebx
je     1179 <term_print_size+0x59>
mov    $0xfffffffe,%eax
sub    %ebx,%eax
lea    0xe9a(%rip),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <term_putchar@plt>
mov    $0x69,%edi
call   1040 <term_putchar@plt>
mov    $0x42,%edi
pop    %rbx
jmp    1040 <term_putchar@plt>

LLVM IR (-O0):
@__const.term_print_size.prefixes = [6 x i8] c"KMGTP\00"
define void @term_print_size(i64 %0) {
%2 = alloca i64
%3 = alloca [6 x i8]
%4 = alloca i32
store i64 %0, i64* %2
%5 = bitcast [6 x i8]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %14, %1
%7 = load i64, i64* %2
%8 = load i32, i32* %4
%9 = mul nsw i32 10, %8
%10 = zext i32 %9 to i64
%11 = lshr i64 %7, %10
%12 = icmp ugt i64 %11, 1024
br i1 %12, label %13, label %17
13: ; preds = %6
br label %14
14: ; preds = %13
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %6
17: ; preds = %6
%18 = load i64, i64* %2
%19 = load i32, i32* %4
%20 = mul nsw i32 10, %19
%21 = zext i32 %20 to i64
%22 = lshr i64 %18, %21
%23 = call i32 @term_print_decu(i64 %22)
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %17
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @term_putchar(i8 signext %31)
%33 = call i32 @term_putchar(i8 signext 105)
br label %34
34: ; preds = %26, %17
%35 = call i32 @term_putchar(i8 signext 66)
ret void
}

LLVM IR (-O2):
@__const.term_print_size.prefixes = [6 x i8] c"KMGTP\00"
define void @term_print_size(i64 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %8, %2 ], [ 0, %1 ]
%4 = mul i64 %3, 10
%5 = and i64 %4, 4294967294
%6 = lshr i64 %0, %5
%7 = icmp ugt i64 %6, 1024
%8 = add nuw i64 %3, 1
br i1 %7, label %2, label %9
9: ; preds = %2
%10 = trunc i64 %3 to i32
%11 = tail call i32 @term_print_decu(i64 %6)
%12 = icmp eq i32 %10, 0
br i1 %12, label %20, label %13
13: ; preds = %9
%14 = add i64 %3, 4294967295
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [6 x i8], [6 x i8]* @__const.term_print_size.prefixes, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @term_putchar(i8 signext %17)
%19 = tail call i32 @term_putchar(i8 signext 105)
br label %20
20: ; preds = %13, %9
%21 = tail call i32 @term_putchar(i8 signext 66)
ret void
}