#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*/ disp_int(int);
int /*<<< orphan*/ disp_str(char *);
long fat_fsize(char *);
int /*<<< orphan*/ fat_root_ent(int, char *);
void test_froot() {
  int i = 0, x = 0;
  char buf[32];
  fat_root_ent(1, buf);
  long fsize = fat_fsize(buf);
  disp_str("\n===========\n");
  disp_int(fsize);
  disp_str("                 \n===========");
  disp_str("\n===========\n");
  for (i = 0; i < 32; i++) {
    x = (int)buf[i];
    x = x & 0x0ff;
    disp_int(x);
    disp_str(((i + 1) % 8 == 0) ? "        \n" : "  ");
  }
  disp_str("===========\n");
}


x86 assembly (clang, -O0):
<test_froot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x1,%edi
call   1040 <fat_root_ent@plt>
lea    -0x30(%rbp),%rdi
call   1050 <fat_fsize@plt>
mov    %rax,-0x38(%rbp)
lea    0xe88(%rip),%rdi
call   1030 <disp_str@plt>
mov    -0x38(%rbp),%rax
mov    %eax,%edi
call   1060 <disp_int@plt>
lea    0xe7f(%rip),%rdi
call   1030 <disp_str@plt>
lea    0xe65(%rip),%rdi
call   1030 <disp_str@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    1206 <test_froot+0xc6>
movslq -0x4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <disp_int@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
lea    0xe51(%rip),%rdi
lea    0xe40(%rip),%rax
cmp    $0x0,%edx
cmove  %rax,%rdi
call   1030 <disp_str@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <test_froot+0x67>
lea    0xdf4(%rip),%rdi
call   1030 <disp_str@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_froot>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <fat_root_ent@plt>
mov    %rbx,%rdi
call   1050 <fat_fsize@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%r14
mov    %r14,%rdi
call   1030 <disp_str@plt>
mov    %ebx,%edi
call   1060 <disp_int@plt>
lea    0xe8d(%rip),%rdi
call   1030 <disp_str@plt>
mov    %r14,%rdi
call   1030 <disp_str@plt>
mov    $0x1,%ebx
lea    0xe92(%rip),%r14
lea    0xe95(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rsp,%rbx,1),%edi
call   1060 <disp_int@plt>
test   $0x7,%bl
mov    %r15,%rdi
cmove  %r14,%rdi
call   1030 <disp_str@plt>
add    $0x1,%rbx
cmp    $0x21,%rbx
jne    11b0 <test_froot+0x70>
lea    0xe27(%rip),%rdi
call   1030 <disp_str@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0A===========\0A\00"
@.str.1 = [30 x i8] c" \0A===========\00"
@.str.2 = [10 x i8] c" \0A\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [13 x i8] c"===========\0A\00"
define void @test_froot() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = call i32 @fat_root_ent(i32 1, i8* %5)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = call i64 @fat_fsize(i8* %7)
store i64 %8, i64* %4
%9 = call i32 @disp_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %4
%11 = trunc i64 %10 to i32
%12 = call i32 @disp_int(i32 %11)
%13 = call i32 @disp_str(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @disp_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %15
15: ; preds = %35, %0
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 32
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = and i32 %24, 255
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = call i32 @disp_int(i32 %26)
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
%30 = srem i32 %29, 8
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%34 = call i32 @disp_str(i8* %33)
br label %35
35: ; preds = %18
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %15
38: ; preds = %15
%39 = call i32 @disp_str(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0A===========\0A\00"
@.str.1 = [30 x i8] c" \0A===========\00"
@.str.2 = [10 x i8] c" \0A\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [13 x i8] c"===========\0A\00"
define void @test_froot() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = call i32 @fat_root_ent(i32 1, i8* %2)
%4 = call i64 @fat_fsize(i8* %2)
%5 = call i32 @disp_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = trunc i64 %4 to i32
%7 = call i32 @disp_int(i32 %6)
%8 = call i32 @disp_str(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @disp_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %10
%11 = phi i64 [ 0, %0 ], [ %16, %10 ]
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = call i32 @disp_int(i32 %14)
%16 = add nuw nsw i64 %11, 1
%17 = and i64 %16, 7
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%20 = call i32 @disp_str(i8* %19)
%21 = icmp eq i64 %16, 32
br i1 %21, label %22, label %10
22: ; preds = %10
%23 = call i32 @disp_str(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret void
}