#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
void LoadFile(char name[], int a[], int p[], int *n) {
  FILE *f;
  if ((f = fopen(name, "r")) != NULL) {
    int num = 0;
    char bufer[100];
    while (!feof(f)) {
      if (fgets(bufer, 100, f) != NULL) {
        sscanf(bufer, "%d", &a[num]);
        int k = 0;
        while (bufer[k] != '-') {
          k++;
        }
        char *str = &bufer[k + 1];
        sscanf(str, "%d", &p[num]);
        num++;
        if (num == 1000) {
          break;
        }
      }
    }
    *n = num;
    fclose(f);
  } else {
    printf("File not found!\n");
  }
}


x86 assembly (clang, -O0):
<LoadFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12b0 <LoadFile+0x150>
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11be <LoadFile+0x5e>
jmp    1299 <LoadFile+0x139>
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1294 <LoadFile+0x134>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe08(%rip),%rsi
call   1070 <sscanf@plt>
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x2d,%eax
je     1235 <LoadFile+0xd5>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1209 <LoadFile+0xa9>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    -0x90(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd93(%rip),%rsi
call   1070 <sscanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x3e8,-0x2c(%rbp)
jne    128f <LoadFile+0x12f>
jmp    1299 <LoadFile+0x139>
jmp    1294 <LoadFile+0x134>
jmp    11a0 <LoadFile+0x40>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12bc <LoadFile+0x15c>
lea    0xd4e(%rip),%rdi
call   1040 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LoadFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %rsi,%r12
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11be <LoadFile+0x5e>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
mov    %rax,%rdi
call   1060 <feof@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     11d8 <LoadFile+0x78>
mov    0x8(%rsp),%rax
mov    %r14d,(%rax)
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe40(%rip),%rdi
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
xor    %r14d,%r14d
lea    0x10(%rsp),%r13
lea    0xe1b(%rip),%rbp
jmp    11fc <LoadFile+0x9c>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    119f <LoadFile+0x3f>
mov    %r13,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11f0 <LoadFile+0x90>
movslq %r14d,%r14
lea    (%r12,%r14,4),%rdx
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <sscanf@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x2d,0x10(%rsp,%rax,1)
lea    0x1(%rax),%rax
jne    1230 <LoadFile+0xd0>
mov    %eax,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
lea    (%r15,%r14,4),%rdx
mov    %rbp,%rsi
call   1070 <sscanf@plt>
add    $0x1,%r14d
cmp    $0x3e8,%r14d
jne    11f0 <LoadFile+0x90>
mov    $0x3e8,%r14d
jmp    119f <LoadFile+0x3f>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"File not found!\0A\00"
define void @LoadFile(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca [100 x i8]
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %9
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %68
17: ; preds = %4
store i32 0, i32* %10
br label %18
18: ; preds = %62, %17
%19 = load i32*, i32** %9
%20 = call i32 @feof(i32* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br i1 %22, label %23, label %63
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%25 = load i32*, i32** %9
%26 = call i32* @fgets(i8* %24, i32 100, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %62
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
store i32 0, i32* %12
br label %35
35: ; preds = %42, %28
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 45
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
store i32 %44, i32* %12
br label %35
45: ; preds = %35
%46 = load i32, i32* %12
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 %48
store i8* %49, i8** %13
%50 = load i8*, i8** %13
%51 = load i32*, i32** %7
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = call i32 @sscanf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %54)
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
%58 = load i32, i32* %10
%59 = icmp eq i32 %58, 1000
br i1 %59, label %60, label %61
60: ; preds = %45
br label %63
61: ; preds = %45
br label %62
62: ; preds = %61, %23
br label %18
63: ; preds = %60, %18
%64 = load i32, i32* %10
%65 = load i32*, i32** %8
store i32 %64, i32* %65
%66 = load i32*, i32** %9
%67 = call i32 @fclose(i32* %66)
br label %70
68: ; preds = %4
%69 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@str = [16 x i8] c"File not found!\00"
define void @LoadFile(i8* nocapture %0, i32* %1, i32* %2, i32* nocapture writeonly %3) {
%5 = alloca [100 x i8]
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %41, label %8
8: ; preds = %4
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%10 = call i32 @feof(i32* %6)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %38
12: ; preds = %8, %34
%13 = phi i32 [ %35, %34 ], [ 0, %8 ]
%14 = call i32* @fgets(i8* %9, i32 100, i32* %6)
%15 = icmp eq i32* %14, null
br i1 %15, label %34, label %16
16: ; preds = %12
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds i32, i32* %1, i64 %17
%19 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %20, %16
%21 = phi i64 [ %25, %20 ], [ 0, %16 ]
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 45
%25 = add nuw i64 %21, 1
br i1 %24, label %26, label %20
26: ; preds = %20
%27 = add i64 %21, 1
%28 = and i64 %27, 4294967295
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %28
%30 = getelementptr inbounds i32, i32* %2, i64 %17
%31 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
%32 = add nsw i32 %13, 1
%33 = icmp eq i32 %32, 1000
br i1 %33, label %38, label %34
34: ; preds = %26, %12
%35 = phi i32 [ %32, %26 ], [ %13, %12 ]
%36 = call i32 @feof(i32* %6)
%37 = icmp eq i32 %36, 0
br i1 %37, label %12, label %38
38: ; preds = %34, %26, %8
%39 = phi i32 [ 0, %8 ], [ 1000, %26 ], [ %35, %34 ]
store i32 %39, i32* %3
%40 = call i32 @fclose(i32* %6)
br label %43
41: ; preds = %4
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
ret void
}