#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, long *, long *, long *, long *);
int /*<<< orphan*/ get_heading(char *, long *, long *, long *, long *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, const char *argv[]) {
  FILE *in_file = fopen(argv[1], "r");
  char cardinal_string[4];
  long int O, P, Q, R;
  while (fscanf(in_file, "%ld %ld %ld %ld\n", &O, &P, &Q, &R) != EOF) {
    get_heading(cardinal_string, &O, &P, &Q, &R);
    printf("%s\n", cardinal_string);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe89(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x40(%rbp),%r9
call   1050 <fscanf@plt>
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
je     11cc <main+0x8c>
lea    -0x1c(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1040 <get_heading@plt>
lea    -0x1c(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
jmp    116e <main+0x2e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x8(%rsi),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
lea    0xe9d(%rip),%rsi
lea    0x28(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x2e5b(%rip),%r14
cmp    (%r14),%rax
je     11f5 <main+0xb5>
lea    0x34(%rsp),%r15
lea    0x28(%rsp),%r12
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%rbx
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1040 <get_heading@plt>
lea    0xe48(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    0x8(%rsp),%rdi
lea    0xe23(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    %rbp,%r9
call   1050 <fscanf@plt>
cmp    (%r14),%rax
jne    11b0 <main+0x70>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"%ld %ld %ld %ld\0A\00"
@EOF = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [4 x i8]
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
br label %16
16: ; preds = %21, %2
%17 = load i32*, i32** %6
%18 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64* %8, i64* %9, i64* %10, i64* %11)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%23 = call i32 @get_heading(i8* %22, i64* %8, i64* %9, i64* %10, i64* %11)
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %16
26: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"%ld %ld %ld %ld\0A\00"
@EOF = global i64 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%12 = bitcast i64* %4 to i8*
%13 = bitcast i64* %5 to i8*
%14 = bitcast i64* %6 to i8*
%15 = bitcast i64* %7 to i8*
%16 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %5, i64* %6, i64* %7)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %25, label %19
19: ; preds = %2, %19
%20 = call i32 @get_heading(i8* %11, i64* %4, i64* %5, i64* %6, i64* %7)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%22 = call i64 @fscanf(i32* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %5, i64* %6, i64* %7)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %19
25: ; preds = %19, %2
ret i32 0
}