#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 *);
int get_root_ent_bname(char *, char *);
void test_frdf() {
  char buf[32];
  char tbuf[512];
  int i = 0, t = 0;
  i = get_root_ent_bname("BBB.TXT", buf);
  disp_str("==============                             \n");
  disp_int(i);
  disp_str("                                           \n");
  tbuf[3] = tbuf[4] = '\0';
  disp_str(tbuf);
  disp_str("                                           \n");
  for (i = 0; i < 3; i++) {
    t = (int)tbuf[i];
    t = t & 0x0ff;
    disp_int(t);
    disp_str(((i + 1) % 8 == 0) ? "           \n      " : "  ");
  }
  disp_str("                                           \n");
  disp_str("==============                             \n");
}


x86 assembly (clang, -O0):
<test_frdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x224(%rbp)
movl   $0x0,-0x228(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <get_root_ent_bname@plt>
mov    %eax,-0x224(%rbp)
lea    0xe9c(%rip),%rdi
call   1030 <disp_str@plt>
mov    -0x224(%rbp),%edi
call   1050 <disp_int@plt>
lea    0xeb2(%rip),%rdi
call   1030 <disp_str@plt>
movb   $0x0,-0x21c(%rbp)
movb   $0x0,-0x21d(%rbp)
lea    -0x220(%rbp),%rdi
call   1030 <disp_str@plt>
lea    0xe8c(%rip),%rdi
call   1030 <disp_str@plt>
movl   $0x0,-0x224(%rbp)
cmpl   $0x3,-0x224(%rbp)
jge    1235 <test_frdf+0x105>
movslq -0x224(%rbp),%rax
movsbl -0x220(%rbp,%rax,1),%eax
ff
mov    %eax,-0x228(%rbp)
mov    -0x228(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x228(%rbp)
mov    -0x228(%rbp),%edi
call   1050 <disp_int@plt>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
lea    0xe64(%rip),%rdi
lea    0xe4d(%rip),%rax
cmp    $0x0,%edx
cmove  %rax,%rdi
call   1030 <disp_str@plt>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    11b8 <test_frdf+0x88>
lea    0xdf9(%rip),%rdi
call   1030 <disp_str@plt>
lea    0xdc0(%rip),%rdi
call   1030 <disp_str@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_frdf>:
push   %r15
push   %r14
push   %rbx
sub    $0x220,%rsp
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
call   1040 <get_root_ent_bname@plt>
mov    %eax,%ebx
lea    0xeb4(%rip),%r14
mov    %r14,%rdi
call   1030 <disp_str@plt>
mov    %ebx,%edi
call   1050 <disp_int@plt>
lea    0xecb(%rip),%r15
mov    %r15,%rdi
call   1030 <disp_str@plt>
movw   $0x0,0x23(%rsp)
lea    0x20(%rsp),%rdi
call   1030 <disp_str@plt>
mov    %r15,%rdi
call   1030 <disp_str@plt>
movzbl 0x20(%rsp),%edi
call   1050 <disp_int@plt>
lea    0xec6(%rip),%rbx
mov    %rbx,%rdi
call   1030 <disp_str@plt>
movzbl 0x21(%rsp),%edi
call   1050 <disp_int@plt>
mov    %rbx,%rdi
call   1030 <disp_str@plt>
movzbl 0x22(%rsp),%edi
call   1050 <disp_int@plt>
mov    %rbx,%rdi
call   1030 <disp_str@plt>
mov    %r15,%rdi
call   1030 <disp_str@plt>
mov    %r14,%rdi
call   1030 <disp_str@plt>
add    $0x220,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"BBB.TXT\00"
@.str.1 = [45 x i8] c"============== \0A\00"
@.str.2 = [45 x i8] c" \0A\00"
@.str.4 = [3 x i8] c" \00"
define void @test_frdf() {
%1 = alloca [32 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_root_ent_bname(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @disp_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @disp_int(i32 %5)
%8 = call i32 @disp_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 4
store i8 0, i8* %9
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 3
store i8 0, i8* %10
%11 = call i32 @disp_str(i8* %4)
%12 = call i32 @disp_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8, i8* %4
%14 = zext i8 %13 to i32
%15 = call i32 @disp_int(i32 %14)
%16 = call i32 @disp_str(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 @disp_int(i32 %19)
%21 = call i32 @disp_str(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 2
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = call i32 @disp_int(i32 %24)
%26 = call i32 @disp_str(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @disp_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @disp_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
ret void
}