#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*/ BufRead(int, char *);
int /*<<< orphan*/ DevResetDiskAccessCount();
int /*<<< orphan*/ PrintBufInfo();
int /*<<< orphan*/ PrintDiskAccessCountInfo();
int /*<<< orphan*/ printf(char *, ...);
int testcase2() {
  int i;
  char pData[1024];
  DevResetDiskAccessCount();
  for (i = 0; i < (10) / 2; i++) {
    BufRead(i, pData);
    printf("read[%d]:%s ", i, (char *)pData);
  }
  printf("\n----------------------------------\n");
  PrintBufInfo();
  for (i = (10) / 2; i < (10); i++) {
    BufRead(i, pData);
    printf("read[%d]:%s ", i, (char *)pData);
  }
  printf("\n----------------------------------\n");
  PrintBufInfo();
  PrintDiskAccessCountInfo();
  return 1;
}


x86 assembly (clang, -O0):
<testcase2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    $0x0,%al
call   1050 <DevResetDiskAccessCount@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x5,-0x4(%rbp)
jge    11a8 <testcase2+0x58>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1070 <BufRead@plt>
mov    -0x4(%rbp),%esi
lea    -0x410(%rbp),%rdx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1169 <testcase2+0x19>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <PrintBufInfo@plt>
movl   $0x5,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1203 <testcase2+0xb3>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1070 <BufRead@plt>
mov    -0x4(%rbp),%esi
lea    -0x410(%rbp),%rdx
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c4 <testcase2+0x74>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <PrintBufInfo@plt>
mov    $0x0,%al
call   1060 <PrintDiskAccessCountInfo@plt>
mov    $0x1,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcase2>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
xor    %eax,%eax
call   1060 <DevResetDiskAccessCount@plt>
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
lea    0xe79(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf4(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <PrintBufInfo@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x6,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x8,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x9,%edi
mov    %rbx,%rsi
call   1080 <BufRead@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <PrintBufInfo@plt>
xor    %eax,%eax
call   1070 <PrintDiskAccessCountInfo@plt>
mov    $0x1,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"read[%d]:%s \00"
@.str.1 = [37 x i8] c"\0A----------------------------------\0A\00"
define i32 @testcase2() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = call i32 (...) @DevResetDiskAccessCount()
store i32 0, i32* %1
br label %4
4: ; preds = %14, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 5
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = load i32, i32* %1
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%10 = call i32 @BufRead(i32 %8, i8* %9)
%11 = load i32, i32* %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %12)
br label %14
14: ; preds = %7
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %4
17: ; preds = %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (...) @PrintBufInfo()
store i32 5, i32* %1
br label %20
20: ; preds = %30, %17
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %1
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%26 = call i32 @BufRead(i32 %24, i8* %25)
%27 = load i32, i32* %1
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %27, i8* %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %20
33: ; preds = %20
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 (...) @PrintBufInfo()
%36 = call i32 (...) @PrintDiskAccessCountInfo()
ret i32 1
}

LLVM IR (-O2):
@.str = [13 x i8] c"read[%d]:%s \00"
@str.2 = [36 x i8] c"\0A----------------------------------\00"
define i32 @testcase2() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @DevResetDiskAccessCount()
%4 = call i32 @BufRead(i32 0, i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0, i8* %2)
%6 = call i32 @BufRead(i32 1, i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1, i8* %2)
%8 = call i32 @BufRead(i32 2, i8* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 2, i8* %2)
%10 = call i32 @BufRead(i32 3, i8* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 3, i8* %2)
%12 = call i32 @BufRead(i32 4, i8* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 4, i8* %2)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.2, i64 0, i64 0))
%15 = call i32 (...) @PrintBufInfo()
%16 = call i32 @BufRead(i32 5, i8* %2)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 5, i8* %2)
%18 = call i32 @BufRead(i32 6, i8* %2)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 6, i8* %2)
%20 = call i32 @BufRead(i32 7, i8* %2)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 7, i8* %2)
%22 = call i32 @BufRead(i32 8, i8* %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 8, i8* %2)
%24 = call i32 @BufRead(i32 9, i8* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 9, i8* %2)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.2, i64 0, i64 0))
%27 = call i32 (...) @PrintBufInfo()
%28 = call i32 (...) @PrintDiskAccessCountInfo()
ret i32 1
}