#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ stderr;
int load_markers(char *markfile, int *markx, int *marky, int *nmark) {
  FILE *f;
  f = fopen(markfile, "r");
  if (!f) {
    fprintf(stderr, "Couldn't load %s\n", markfile);
    return 1;
  }
  (*nmark) = 0;
  while (!feof(f)) {
    if (fscanf(f, "%d ", markx + (*nmark)) != 1)
      continue;
    if (fscanf(f, "%d ", marky + (*nmark)) != 1)
      return 2;
    (*nmark)++;
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<load_markers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ac <load_markers+0x5c>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    125b <load_markers+0x10b>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d4 <load_markers+0x84>
jmp    124b <load_markers+0xfb>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe23(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     1204 <load_markers+0xb4>
jmp    11b6 <load_markers+0x66>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdf3(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     123b <load_markers+0xeb>
movl   $0x2,-0x4(%rbp)
jmp    125b <load_markers+0x10b>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11b6 <load_markers+0x66>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_markers>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1199 <load_markers+0x49>
mov    %rax,%rbx
movl   $0x0,(%r12)
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11c0 <load_markers+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11b6 <load_markers+0x66>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
mov    %r13,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe4d(%rip),%r13
jmp    11dc <load_markers+0x8c>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    118d <load_markers+0x3d>
movslq (%r12),%rax
lea    (%r15,%rax,4),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11d0 <load_markers+0x80>
movslq (%r12),%rax
lea    (%r14,%rax,4),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1213 <load_markers+0xc3>
addl   $0x1,(%r12)
jmp    11d0 <load_markers+0x80>
mov    $0x2,%eax
jmp    11b6 <load_markers+0x66>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Couldn't load %s\0A\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @load_markers(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%11 = load i8*, i8** %6
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = icmp ne i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %6
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 1, i32* %5
br label %53
19: ; preds = %4
%20 = load i32*, i32** %9
store i32 0, i32* %20
br label %21
21: ; preds = %46, %35, %19
%22 = load i32*, i32** %10
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %50
26: ; preds = %21
%27 = load i32*, i32** %10
%28 = load i32*, i32** %7
%29 = load i32*, i32** %9
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = call i32 @fscanf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %32)
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %26
br label %21
36: ; preds = %26
%37 = load i32*, i32** %10
%38 = load i32*, i32** %8
%39 = load i32*, i32** %9
%40 = load i32, i32* %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %38, i64 %41
%43 = call i32 @fscanf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %42)
%44 = icmp ne i32 %43, 1
br i1 %44, label %45, label %46
45: ; preds = %36
store i32 2, i32* %5
br label %53
46: ; preds = %36
%47 = load i32*, i32** %9
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
store i32 %49, i32* %47
br label %21
50: ; preds = %21
%51 = load i32*, i32** %10
%52 = call i32 @fclose(i32* %51)
store i32 0, i32* %5
br label %53
53: ; preds = %50, %45, %15
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Couldn't load %s\0A\00"
@.str.2 = [4 x i8] c"%d \00"
define i32 @load_markers(i8* %0, i32* %1, i32* %2, i32* nocapture %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %33
10: ; preds = %4
store i32 0, i32* %3
%11 = tail call i32 @feof(i32* %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %10, %28
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %1, i64 %15
%17 = tail call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %13
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %2, i64 %21
%23 = tail call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %33
25: ; preds = %19
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %13
%29 = tail call i32 @feof(i32* %5)
%30 = icmp eq i32 %29, 0
br i1 %30, label %13, label %31
31: ; preds = %28, %10
%32 = tail call i32 @fclose(i32* %5)
br label %33
33: ; preds = %19, %31, %7
%34 = phi i32 [ 0, %31 ], [ 1, %7 ], [ 2, %19 ]
ret i32 %34
}