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

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Please provide a stabping *.dat file as first argument\n");
  }
  char *filename = argv[1];
  FILE *file = fopen(filename, "r");
  int32_t buf[3];
  while (fread(buf, sizeof(int32_t), 3, file) == 3) {
    printf("%11d %2d %8d\n", buf[0], buf[1], buf[2]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1175 <main+0x35>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
mov    $0x3,%edx
call   1030 <fread@plt>
cmp    $0x3,%eax
jne    11cf <main+0x8f>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
jmp    1195 <main+0x55>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1166 <main+0x26>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x8(%rbx),%rdi
lea    0xec7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
cmp    $0x3,%eax
jne    11de <main+0x9e>
lea    0xe9e(%rip),%r14
lea    0x4(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x3,%eax
je     11b0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [56 x i8] c"Please provide a stabping *.dat file as first argument\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%11d %2d %8d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [3 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
br label %20
20: ; preds = %25, %14
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%22 = load i32*, i32** %7
%23 = call i32 @fread(i32* %21, i32 4, i32 3, i32* %22)
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%27 = load i32, i32* %26
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 2
%31 = load i32, i32* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %29, i32 %31)
br label %20
33: ; preds = %20
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [56 x i8] c"Please provide a stabping *.dat file as first argument\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%11d %2d %8d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = bitcast [3 x i32]* %3 to i8*
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%14 = call i32 @fread(i32* %13, i32 4, i32 3, i32* %11)
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %26
16: ; preds = %8
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
br label %19
19: ; preds = %16, %19
%20 = load i32, i32* %13
%21 = load i32, i32* %17
%22 = load i32, i32* %18
%23 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = call i32 @fread(i32* %13, i32 4, i32 3, i32* %11)
%25 = icmp eq i32 %24, 3
br i1 %25, label %19, label %26
26: ; preds = %19, %8
ret i32 0
}