#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*/ BufSync();
int /*<<< orphan*/ BufWrite(int, char *);
int /*<<< orphan*/ DevResetDiskAccessCount();
int /*<<< orphan*/ PrintBufInfo();
int /*<<< orphan*/ PrintDiskAccessCountInfo();
int /*<<< orphan*/ PrintDiskInfo(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int testcase1() {
  int i;
  char pData[1024];
  DevResetDiskAccessCount();
  for (i = 0; i < 8; i++) {
    sprintf(pData, "[block %d]", i);
    BufWrite(i, pData);
  }
  PrintBufInfo();
  {
    sprintf(pData, "[block %d]", 8);
    BufWrite(8, pData);
  }
  for (i = 9; i < 15; i++) {
    sprintf(pData, "[block %d]", i);
    BufWrite(i, pData);
  }
  PrintBufInfo();
  printf("========= BufSync() =========\n");
  BufSync();
  PrintBufInfo();
  PrintDiskInfo(0, 14);
  PrintDiskAccessCountInfo();
  return 1;
}


x86 assembly (clang, -O0):
<testcase1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    $0x0,%al
call   1070 <DevResetDiskAccessCount@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    11d6 <testcase1+0x56>
lea    -0x410(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe4c(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <BufWrite@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <testcase1+0x19>
mov    $0x0,%al
call   1040 <PrintBufInfo@plt>
lea    -0x410(%rbp),%rdi
lea    0xe15(%rip),%rsi
mov    $0x8,%edx
call   10a0 <sprintf@plt>
lea    -0x410(%rbp),%rsi
mov    $0x8,%edi
call   1060 <BufWrite@plt>
movl   $0x9,-0x4(%rbp)
cmpl   $0xf,-0x4(%rbp)
jge    124a <testcase1+0xca>
lea    -0x410(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdd8(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
call   1060 <BufWrite@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120d <testcase1+0x8d>
mov    $0x0,%al
call   1040 <PrintBufInfo@plt>
lea    0xdb3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <BufSync@plt>
mov    $0x0,%al
call   1040 <PrintBufInfo@plt>
xor    %edi,%edi
mov    $0xe,%esi
call   1080 <PrintDiskInfo@plt>
mov    $0x0,%al
call   1090 <PrintDiskAccessCountInfo@plt>
mov    $0x1,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testcase1>:
push   %r14
push   %rbx
sub    $0x408,%rsp
xor    %eax,%eax
call   1070 <DevResetDiskAccessCount@plt>
lea    0xe68(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   10a0 <sprintf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   10a0 <sprintf@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   10a0 <sprintf@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   10a0 <sprintf@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   10a0 <sprintf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   10a0 <sprintf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   10a0 <sprintf@plt>
mov    $0x6,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   10a0 <sprintf@plt>
mov    $0x7,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
xor    %eax,%eax
call   1050 <PrintBufInfo@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   10a0 <sprintf@plt>
mov    $0x8,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   10a0 <sprintf@plt>
mov    $0x9,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   10a0 <sprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
call   10a0 <sprintf@plt>
mov    $0xb,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
call   10a0 <sprintf@plt>
mov    $0xc,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xd,%edx
call   10a0 <sprintf@plt>
mov    $0xd,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xe,%edx
call   10a0 <sprintf@plt>
mov    $0xe,%edi
mov    %rbx,%rsi
call   1060 <BufWrite@plt>
xor    %eax,%eax
call   1050 <PrintBufInfo@plt>
lea    0xcae(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <BufSync@plt>
xor    %eax,%eax
call   1050 <PrintBufInfo@plt>
xor    %edi,%edi
mov    $0xe,%esi
call   1080 <PrintDiskInfo@plt>
xor    %eax,%eax
call   1090 <PrintDiskAccessCountInfo@plt>
mov    $0x1,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"[block %d]\00"
@.str.1 = [31 x i8] c"========= BufSync() =========\0A\00"
define i32 @testcase1() {
%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, 8
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %1
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = call i32 @BufWrite(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 (...) @PrintBufInfo()
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 8)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%22 = call i32 @BufWrite(i32 8, i8* %21)
store i32 9, i32* %1
br label %23
23: ; preds = %33, %17
%24 = load i32, i32* %1
%25 = icmp slt i32 %24, 15
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* %1
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %1
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%32 = call i32 @BufWrite(i32 %30, i8* %31)
br label %33
33: ; preds = %26
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
br label %23
36: ; preds = %23
%37 = call i32 (...) @PrintBufInfo()
%38 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 (...) @BufSync()
%40 = call i32 (...) @PrintBufInfo()
%41 = call i32 @PrintDiskInfo(i32 0, i32 14)
%42 = call i32 (...) @PrintDiskAccessCountInfo()
ret i32 1
}

LLVM IR (-O2):
@.str = [11 x i8] c"[block %d]\00"
@str = [30 x i8] c"========= BufSync() =========\00"
define i32 @testcase1() {
%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 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = call i32 @BufWrite(i32 0, i8* %2)
%6 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = call i32 @BufWrite(i32 1, i8* %2)
%8 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = call i32 @BufWrite(i32 2, i8* %2)
%10 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = call i32 @BufWrite(i32 3, i8* %2)
%12 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = call i32 @BufWrite(i32 4, i8* %2)
%14 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%15 = call i32 @BufWrite(i32 5, i8* %2)
%16 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 6)
%17 = call i32 @BufWrite(i32 6, i8* %2)
%18 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 7)
%19 = call i32 @BufWrite(i32 7, i8* %2)
%20 = call i32 (...) @PrintBufInfo()
%21 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 8)
%22 = call i32 @BufWrite(i32 8, i8* %2)
%23 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 9)
%24 = call i32 @BufWrite(i32 9, i8* %2)
%25 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%26 = call i32 @BufWrite(i32 10, i8* %2)
%27 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11)
%28 = call i32 @BufWrite(i32 11, i8* %2)
%29 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 12)
%30 = call i32 @BufWrite(i32 12, i8* %2)
%31 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 13)
%32 = call i32 @BufWrite(i32 13, i8* %2)
%33 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 14)
%34 = call i32 @BufWrite(i32 14, i8* %2)
%35 = call i32 (...) @PrintBufInfo()
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%37 = call i32 (...) @BufSync()
%38 = call i32 (...) @PrintBufInfo()
%39 = call i32 @PrintDiskInfo(i32 0, i32 14)
%40 = call i32 (...) @PrintDiskAccessCountInfo()
ret i32 1
}