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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_parsing(char *, int);
int main(int argc, char **argv) {
  FILE *f;
  char buffer[4096];
  int l;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s file.xml\n", argv[0]);
    return 1;
  }
  f = fopen(argv[1], "r");
  if (!f) {
    fprintf(stderr, "Error : can not open file %s\n", argv[1]);
    return 2;
  }
  l = fread(buffer, 1, sizeof(buffer) - 1, f);
  fclose(f);
  buffer[l] = '\0';
  test_parsing(buffer, l);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119b <main+0x4b>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1238 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e7 <main+0x97>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe40(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1238 <main+0xe8>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0xfff,%edx
call   1030 <fread@plt>
mov    %eax,-0x1024(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
mov    -0x1024(%rbp),%esi
call   1070 <test_parsing@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1182 <main+0x32>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe8a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11ed <main+0x9d>
mov    0x8(%rbx),%rdi
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11cf <main+0x7f>
mov    %rax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xfff,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <fclose@plt>
movslq %ebp,%rsi
movb   $0x0,(%rsp,%rsi,1)
mov    %rbx,%rdi
call   1070 <test_parsing@plt>
xor    %eax,%eax
jmp    11ed <main+0x9d>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s file.xml\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Error : can not 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 [4096 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 %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %42
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %30, label %24
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %28)
store i32 2, i32* %3
br label %42
30: ; preds = %17
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%32 = load i32*, i32** %6
%33 = call i32 @fread(i8* %31, i32 1, i32 4095, i32* %32)
store i32 %33, i32* %8
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %37
store i8 0, i8* %38
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%40 = load i32, i32* %8
%41 = call i32 @test_parsing(i8* %39, i32 %40)
store i32 0, i32* %3
br label %42
42: ; preds = %30, %24, %11
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s file.xml\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Error : can not open file %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %25
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %25
19: ; preds = %10
%20 = call i32 @fread(i8* %4, i32 1, i32 4095, i32* %13)
%21 = tail call i32 @fclose(i32* %13)
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @test_parsing(i8* %4, i32 %20)
br label %25
25: ; preds = %19, %15, %6
%26 = phi i32 [ 1, %6 ], [ 0, %19 ], [ 2, %15 ]
ret i32 %26
}