#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ burptest(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  FILE *f;
  char buffer[(8192)];
  int bufsize;
  if (argc < 2) {
    printf("usage:\t%s file.xml\n", argv[0]);
    return 1;
  }
  f = fopen(argv[1], "r");
  if (!f) {
    printf("cannot open file %s\n", argv[1]);
    return 1;
  }
  bufsize = (int)fread(buffer, 1, (8192), f);
  fclose(f);
  burptest(buffer, bufsize);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1192 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1217 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1217 <main+0xc7>
lea    -0x2020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2000,%edx
call   1030 <fread@plt>
mov    %eax,-0x2024(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x2020(%rbp),%rdi
mov    -0x2024(%rbp),%esi
call   1060 <burptest@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x2000,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1170 <main+0x20>
mov    (%rbx),%rsi
lea    0xe92(%rip),%rdi
jmp    11c4 <main+0x74>
mov    0x8(%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b9 <main+0x69>
mov    %rax,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x2000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <burptest@plt>
xor    %eax,%eax
jmp    11ce <main+0x7e>
mov    0x8(%rbx),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"usage:\09%s file.xml\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"cannot open file %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [8192 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %38
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %38
28: ; preds = %16
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i64 @fread(i8* %29, i32 1, i32 8192, i32* %30)
%32 = trunc i64 %31 to i32
store i32 %32, i32* %8
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%36 = load i32, i32* %8
%37 = call i32 @burptest(i8* %35, i32 %36)
store i32 0, i32* %3
br label %38
38: ; preds = %28, %23, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [20 x i8] c"usage:\09%s file.xml\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"cannot open file %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %22
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %22
17: ; preds = %9
%18 = call i64 @fread(i8* %4, i32 1, i32 8192, i32* %12)
%19 = trunc i64 %18 to i32
%20 = tail call i32 @fclose(i32* %12)
%21 = call i32 @burptest(i8* %4, i32 %19)
br label %22
22: ; preds = %17, %14, %6
%23 = phi i32 [ 1, %6 ], [ 0, %17 ], [ 1, %14 ]
ret i32 %23
}