#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 */
struct stat {
  scalar_t__ st_size;
};

/* Variables and functions */
long countlength(float);
int /*<<< orphan*/ float_to_string(float, char *);
int mystrlen(char *);
int /*<<< orphan*/ write(int, char *, int);
void getfilesize_with_h(struct stat fileStat, int block, long long blocks) {
  float filesize;
  int y = 0, p, overallprint = 0, inita = 0;
  if (block == 0) {
    filesize = (float)fileStat.st_size;
  } else if (block == 1) {
    filesize = (float)blocks;
  }
  while (filesize >= 1024) {
    y++;
    filesize = (float)((float)filesize / (float)1024);
  }
  long siz = (long)filesize;
  long h = countlength(filesize);
  char ans[h + 1];
  float_to_string(filesize, ans);
  for (p = 0; p < mystrlen(ans); p++) {
    if (ans[p] == '.' && siz == filesize) {
      inita = 1;
      break;
    } else if (ans[p] == '.') {
      overallprint += 2;
      write(1, ".", 1);
      write(1, (ans + p + 1), 1);
      break;
    } else {
      write(1, (ans + p), 1);
      overallprint++;
    }
  }
  char suffix[5] = {'K', 'M', 'G', 'T'};
  if (y != 0) {
    if (inita == 1) {
      write(1, ".0", 2);
      overallprint += 2;
    }
    write(1, (suffix + y - 1), 1);
    overallprint++;
  }
  int u;
  for (u = 0; u < 5 - overallprint; ++u)
    write(1, " ", 1);
}


x86 assembly (clang, -O0):
<getfilesize_with_h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1182 <getfilesize_with_h+0x42>
cvtsi2ssq -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    119c <getfilesize_with_h+0x5c>
cmpl   $0x1,-0xc(%rbp)
jne    1197 <getfilesize_with_h+0x57>
cvtsi2ssq -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    119c <getfilesize_with_h+0x5c>
jmp    11a1 <getfilesize_with_h+0x61>
movss  -0x1c(%rbp),%xmm0
movss  0xe52(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11db <getfilesize_with_h+0x9b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xe33(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11a1 <getfilesize_with_h+0x61>
cvttss2si -0x1c(%rbp),%rax
mov    %rax,-0x38(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1050 <countlength@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rsp,%rdx
mov    %rdx,-0x48(%rbp)
add    $0x10,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x68(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1060 <float_to_string@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
call   1040 <mystrlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    130b <getfilesize_with_h+0x1cb>
mov    -0x68(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1282 <getfilesize_with_h+0x142>
cvtsi2ssq -0x38(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jne    1282 <getfilesize_with_h+0x142>
jp     1282 <getfilesize_with_h+0x142>
movl   $0x1,-0x2c(%rbp)
jmp    130b <getfilesize_with_h+0x1cb>
mov    -0x68(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    12d3 <getfilesize_with_h+0x193>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    $0x1,%edx
lea    0xd58(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x68(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
jmp    130b <getfilesize_with_h+0x1cb>
mov    -0x68(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12f8 <getfilesize_with_h+0x1b8>
jmp    12fd <getfilesize_with_h+0x1bd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    122f <getfilesize_with_h+0xef>
mov    0xcf5(%rip),%eax
mov    %eax,-0x55(%rbp)
mov    0xcf0(%rip),%al
mov    %al,-0x51(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1374 <getfilesize_with_h+0x234>
cmpl   $0x1,-0x2c(%rbp)
jne    1350 <getfilesize_with_h+0x210>
mov    $0x1,%edi
lea    0xcce(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
lea    -0x55(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
add    $0xffffffffffffffff,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x5,%ecx
sub    -0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    13af <getfilesize_with_h+0x26f>
mov    $0x1,%edx
lea    0xc74(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    137b <getfilesize_with_h+0x23b>
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getfilesize_with_h>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %r15d,%r15d
test   %esi,%esi
je     115e <getfilesize_with_h+0x1e>
cmp    $0x1,%esi
jne    118f <getfilesize_with_h+0x4f>
mov    %rdx,%rdi
cvtsi2ss %rdi,%xmm0
cmp    $0x400,%rdi
jl     118f <getfilesize_with_h+0x4f>
xor    %r15d,%r15d
movss  0xe89(%rip),%xmm2
movss  0xe85(%rip),%xmm1
nop
add    $0x1,%r15d
mulss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jae    1180 <getfilesize_with_h+0x40>
jmp    118f <getfilesize_with_h+0x4f>
movss  %xmm0,-0x24(%rbp)
call   1050 <countlength@plt>
mov    %rsp,%r14
add    $0x10,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
movss  -0x24(%rbp),%xmm0
mov    %r14,%rdi
call   1060 <float_to_string@plt>
mov    %r14,%rdi
call   1040 <mystrlen@plt>
test   %eax,%eax
jle    1225 <getfilesize_with_h+0xe5>
movss  -0x24(%rbp),%xmm1
cvttss2si %xmm1,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x30(%rbp)
xor    %ebx,%ebx
movaps %xmm1,%xmm0
nop
movzbl (%r14,%rbx,1),%eax
cmp    $0x2e,%al
jne    11f1 <getfilesize_with_h+0xb1>
ucomiss -0x30(%rbp),%xmm0
jne    11f1 <getfilesize_with_h+0xb1>
jnp    122a <getfilesize_with_h+0xea>
cmp    $0x2e,%al
je     125c <getfilesize_with_h+0x11c>
lea    (%r14,%rbx,1),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <mystrlen@plt>
movss  -0x24(%rbp),%xmm0
cltq
cmp    %rax,%rbx
jl     11e0 <getfilesize_with_h+0xa0>
mov    %ebx,%r12d
jmp    128d <getfilesize_with_h+0x14d>
xor    %r12d,%r12d
jmp    128d <getfilesize_with_h+0x14d>
movb   $0x0,-0x28(%rbp)
movl   $0x54474d4b,-0x2c(%rbp)
test   %r15d,%r15d
je     1304 <getfilesize_with_h+0x1c4>
lea    0xdca(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
add    $0x2,%ebx
mov    %ebx,%r12d
jmp    129d <getfilesize_with_h+0x15d>
lea    0x2(%rbx),%r12d
lea    0xda1(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
lea    (%r14,%rbx,1),%rsi
add    $0x1,%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
movb   $0x0,-0x28(%rbp)
movl   $0x54474d4b,-0x2c(%rbp)
test   %r15d,%r15d
je     12bb <getfilesize_with_h+0x17b>
mov    %r15d,%eax
lea    (%rax,%rbp,1),%rsi
add    $0xffffffffffffffd3,%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%r12d
cmp    $0x4,%r12d
jg     12f7 <getfilesize_with_h+0x1b7>
mov    $0x5,%ebx
sub    %r12d,%ebx
cmp    $0x2,%ebx
mov    $0x1,%eax
cmovl  %eax,%ebx
lea    0xd37(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0xffffffff,%ebx
jne    12e0 <getfilesize_with_h+0x1a0>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,%r12d
cmp    $0x4,%r12d
jle    12c1 <getfilesize_with_h+0x181>
jmp    12f7 <getfilesize_with_h+0x1b7>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [2 x i8] c".\00"
@__const.getfilesize_with_h.suffix = [5 x i8] c"KMGT\00"
@.str.1 = [3 x i8] c".0\00"
@.str.2 = [2 x i8] c" \00"
define void @getfilesize_with_h(i64 %0, i32 %1, i64 %2) {
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i64
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca [5 x i8]
%17 = alloca i32
%18 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
store i64 %0, i64* %18
store i32 %1, i32* %5
store i64 %2, i64* %6
store i32 0, i32* %8
store i32 0, i32* %10
store i32 0, i32* %11
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %3
%22 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%23 = load i64, i64* %22
%24 = sitofp i64 %23 to float
store float %24, float* %7
br label %32
25: ; preds = %3
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i64, i64* %6
%30 = sitofp i64 %29 to float
store float %30, float* %7
br label %31
31: ; preds = %28, %25
br label %32
32: ; preds = %31, %21
br label %33
33: ; preds = %36, %32
%34 = load float, float* %7
%35 = fcmp oge float %34, 1.024000e+03
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
%39 = load float, float* %7
%40 = fdiv float %39, 1.024000e+03
store float %40, float* %7
br label %33
41: ; preds = %33
%42 = load float, float* %7
%43 = fptosi float %42 to i64
store i64 %43, i64* %12
%44 = load float, float* %7
%45 = call i64 @countlength(float %44)
store i64 %45, i64* %13
%46 = load i64, i64* %13
%47 = add nsw i64 %46, 1
%48 = call i8* @llvm.stacksave()
store i8* %48, i8** %14
%49 = alloca i8, i64 %47
store i64 %47, i64* %15
%50 = load float, float* %7
%51 = call i32 @float_to_string(float %50, i8* %49)
store i32 0, i32* %9
br label %52
52: ; preds = %94, %41
%53 = load i32, i32* %9
%54 = call i32 @mystrlen(i8* %49)
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %97
56: ; preds = %52
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %49, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 46
br i1 %62, label %63, label %69
63: ; preds = %56
%64 = load i64, i64* %12
%65 = sitofp i64 %64 to float
%66 = load float, float* %7
%67 = fcmp oeq float %65, %66
br i1 %67, label %68, label %69
68: ; preds = %63
store i32 1, i32* %11
br label %97
69: ; preds = %63, %56
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %49, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 46
br i1 %75, label %76, label %85
76: ; preds = %69
%77 = load i32, i32* %10
%78 = add nsw i32 %77, 2
store i32 %78, i32* %10
%79 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %49, i64 %81
%83 = getelementptr inbounds i8, i8* %82, i64 1
%84 = call i32 @write(i32 1, i8* %83, i32 1)
br label %97
85: ; preds = %69
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %49, i64 %87
%89 = call i32 @write(i32 1, i8* %88, i32 1)
%90 = load i32, i32* %10
%91 = add nsw i32 %90, 1
store i32 %91, i32* %10
br label %92
92: ; preds = %85
br label %93
93: ; preds = %92
br label %94
94: ; preds = %93
%95 = load i32, i32* %9
%96 = add nsw i32 %95, 1
store i32 %96, i32* %9
br label %52
97: ; preds = %76, %68, %52
%98 = bitcast [5 x i8]* %16 to i8*
%99 = load i32, i32* %8
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %117
101: ; preds = %97
%102 = load i32, i32* %11
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %108
104: ; preds = %101
%105 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%106 = load i32, i32* %10
%107 = add nsw i32 %106, 2
store i32 %107, i32* %10
br label %108
108: ; preds = %104, %101
%109 = getelementptr inbounds [5 x i8], [5 x i8]* %16, i64 0, i64 0
%110 = load i32, i32* %8
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = getelementptr inbounds i8, i8* %112, i64 -1
%114 = call i32 @write(i32 1, i8* %113, i32 1)
%115 = load i32, i32* %10
%116 = add nsw i32 %115, 1
store i32 %116, i32* %10
br label %117
117: ; preds = %108, %97
store i32 0, i32* %17
br label %118
118: ; preds = %125, %117
%119 = load i32, i32* %17
%120 = load i32, i32* %10
%121 = sub nsw i32 5, %120
%122 = icmp slt i32 %119, %121
br i1 %122, label %123, label %128
123: ; preds = %118
%124 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %125
125: ; preds = %123
%126 = load i32, i32* %17
%127 = add nsw i32 %126, 1
store i32 %127, i32* %17
br label %118
128: ; preds = %118
%129 = load i8*, i8** %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@__const.getfilesize_with_h.suffix = [5 x i8] c"KMGT\00"
@.str.1 = [3 x i8] c".0\00"
@.str.2 = [2 x i8] c" \00"
define void @getfilesize_with_h(i64 %0, i32 %1, i64 %2) {
%4 = alloca [5 x i8]
switch i32 %1, label %16 [
i32 0, label %6
i32 1, label %5
]
5: ; preds = %3
br label %6
6: ; preds = %3, %5
%7 = phi i64 [ %2, %5 ], [ %0, %3 ]
%8 = sitofp i64 %7 to float
%9 = icmp slt i64 %7, 1024
br i1 %9, label %16, label %10
10: ; preds = %6, %10
%11 = phi float [ %14, %10 ], [ %8, %6 ]
%12 = phi i32 [ %13, %10 ], [ 0, %6 ]
%13 = add nuw nsw i32 %12, 1
%14 = fmul float %11, 0x3F50000000000000
%15 = fcmp ult float %14, 1.024000e+03
br i1 %15, label %16, label %10
16: ; preds = %10, %3, %6
%17 = phi i32 [ 0, %6 ], [ 0, %3 ], [ %13, %10 ]
%18 = phi float [ %8, %6 ], [ undef, %3 ], [ %14, %10 ]
%19 = tail call i64 @countlength(float %18)
%20 = add nsw i64 %19, 1
%21 = alloca i8, i64 %20
%22 = call i32 @float_to_string(float %18, i8* %21)
%23 = call i32 @mystrlen(i8* %21)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %50
25: ; preds = %16
%26 = fptosi float %18 to i64
%27 = sitofp i64 %26 to float
%28 = fcmp oeq float %18, %27
br label %29
29: ; preds = %25, %42
%30 = phi i64 [ 0, %25 ], [ %44, %42 ]
%31 = getelementptr inbounds i8, i8* %21, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 46
%34 = select i1 %33, i1 %28, i1 false
br i1 %34, label %54, label %35
35: ; preds = %29
br i1 %33, label %36, label %42
36: ; preds = %35
%37 = trunc i64 %30 to i32
%38 = add nuw nsw i32 %37, 2
%39 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%40 = getelementptr inbounds i8, i8* %31, i64 1
%41 = call i32 @write(i32 1, i8* %40, i32 1)
br label %50
42: ; preds = %35
%43 = call i32 @write(i32 1, i8* %31, i32 1)
%44 = add nuw nsw i64 %30, 1
%45 = call i32 @mystrlen(i8* %21)
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %29, label %48
48: ; preds = %42
%49 = trunc i64 %44 to i32
br label %50
50: ; preds = %48, %16, %36
%51 = phi i32 [ %38, %36 ], [ 0, %16 ], [ %49, %48 ]
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%53 = icmp eq i32 %17, 0
br i1 %53, label %68, label %61
54: ; preds = %29
%55 = trunc i64 %30 to i32
%56 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%57 = icmp eq i32 %17, 0
br i1 %57, label %68, label %58
58: ; preds = %54
%59 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%60 = add nuw nsw i32 %55, 2
br label %61
61: ; preds = %50, %58
%62 = phi i32 [ %60, %58 ], [ %51, %50 ]
%63 = zext i32 %17 to i64
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %63
%65 = getelementptr inbounds i8, i8* %64, i64 -1
%66 = call i32 @write(i32 1, i8* %65, i32 1)
%67 = add nsw i32 %62, 1
br label %68
68: ; preds = %54, %61, %50
%69 = phi i32 [ %67, %61 ], [ %51, %50 ], [ %55, %54 ]
%70 = icmp slt i32 %69, 5
br i1 %70, label %71, label %79
71: ; preds = %68
%72 = sub i32 5, %69
%73 = call i32 @llvm.smax.i32(i32 %72, i32 1)
br label %74
74: ; preds = %71, %74
%75 = phi i32 [ %77, %74 ], [ 0, %71 ]
%76 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%77 = add nuw nsw i32 %75, 1
%78 = icmp eq i32 %77, %73
br i1 %78, label %79, label %74
79: ; preds = %74, %68
%80 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
ret void
}