#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int strtol(char *, char **, int);
int getIndex(int index[2][11]) {
  FILE *fp = NULL;
  char destination[] = "Database/profile/index";
  fp = fopen(destination, "r");
  if (fp == NULL) {
    return 0;
  }
  int i = 0;
  char data[100];
  while (fgets(data, 100, fp) != NULL) {
    char position[3], id[4];
    sscanf(data, "%[^,],%[^,]", id, position);
    char *ptr = NULL;
    index[0][i] = strtol(id, &ptr, 10);
    index[1][i] = strtol(position, &ptr, 10);
    i++;
  }
  fclose(fp);
  fp = NULL;
  return 1;
}


x86 assembly (clang, -O0):
<getIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0xe92(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe8f(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe8d(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xe87(%rip),%ax
mov    %ax,-0x1c(%rbp)
mov    0xe7f(%rip),%al
mov    %al,-0x1a(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c5 <getIndex+0x75>
movl   $0x0,-0x4(%rbp)
jmp    1288 <getIndex+0x138>
movl   $0x0,-0x34(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1270 <getIndex+0x120>
lea    -0xa0(%rbp),%rdi
lea    -0xa7(%rbp),%rdx
lea    -0xa3(%rbp),%rcx
lea    0xe12(%rip),%rsi
call   1060 <sscanf@plt>
movq   $0x0,-0xb0(%rbp)
lea    -0xa7(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0xa3(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,0x2c(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cc <getIndex+0x7c>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIndex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rdi,%rbx
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x7865646e692f65,%rax
mov    %rax,0x2f(%rsp)
lea    0xe91(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     123b <getIndex+0xeb>
mov    %rax,%r14
lea    0x40(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     122c <getIndex+0xdc>
lea    0x40(%rsp),%r12
lea    0x1c(%rsp),%r13
lea    0xd(%rsp),%rbp
lea    0x10(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
lea    0xe3f(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1060 <sscanf@plt>
movq   $0x0,0x10(%rsp)
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,(%rbx)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,0x2c(%rbx)
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
add    $0x4,%rbx
test   %rax,%rax
jne    11d0 <getIndex+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    123d <getIndex+0xed>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.getIndex.destination = [23 x i8] c"Database/profile/index\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"%[^,],%[^,]\00"
define i32 @getIndex([11 x i32]* %0) {
%2 = alloca i32
%3 = alloca [11 x i32]*
%4 = alloca i32*
%5 = alloca [23 x i8]
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [3 x i8]
%9 = alloca [4 x i8]
%10 = alloca i8*
store [11 x i32]* %0, [11 x i32]** %3
store i32* null, i32** %4
%11 = bitcast [23 x i8]* %5 to i8*
%12 = getelementptr inbounds [23 x i8], [23 x i8]* %5, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 0, i32* %2
br label %47
17: ; preds = %1
store i32 0, i32* %6
br label %18
18: ; preds = %23, %17
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32* @fgets(i8* %19, i32 100, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %44
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%27 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
store i8* null, i8** %10
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%29 = call i32 @strtol(i8* %28, i8** %10, i32 10)
%30 = load [11 x i32]*, [11 x i32]** %3
%31 = getelementptr inbounds [11 x i32], [11 x i32]* %30, i64 0
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [11 x i32], [11 x i32]* %31, i64 0, i64 %33
store i32 %29, i32* %34
%35 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%36 = call i32 @strtol(i8* %35, i8** %10, i32 10)
%37 = load [11 x i32]*, [11 x i32]** %3
%38 = getelementptr inbounds [11 x i32], [11 x i32]* %37, i64 1
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [11 x i32], [11 x i32]* %38, i64 0, i64 %40
store i32 %36, i32* %41
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %18
44: ; preds = %18
%45 = load i32*, i32** %4
%46 = call i32 @fclose(i32* %45)
store i32* null, i32** %4
store i32 1, i32* %2
br label %47
47: ; preds = %44, %16
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@__const.getIndex.destination = [23 x i8] c"Database/profile/index\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"%[^,],%[^,]\00"
define i32 @getIndex([11 x i32]* nocapture writeonly %0) {
%2 = alloca [23 x i8]
%3 = alloca [100 x i8]
%4 = alloca [3 x i8]
%5 = alloca [4 x i8]
%6 = alloca i8*
%7 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %30, label %10
10: ; preds = %1
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32* @fgets(i8* %11, i32 100, i32* %8)
%13 = icmp eq i32* %12, null
br i1 %13, label %28, label %14
14: ; preds = %10
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%17 = bitcast i8** %6 to i8*
br label %18
18: ; preds = %14, %18
%19 = phi i64 [ 0, %14 ], [ %25, %18 ]
%20 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %15)
store i8* null, i8** %6
%21 = call i32 @strtol(i8* %16, i8** %6, i32 10)
%22 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 %19
store i32 %21, i32* %22
%23 = call i32 @strtol(i8* %15, i8** %6, i32 10)
%24 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 %19
store i32 %23, i32* %24
%25 = add nuw i64 %19, 1
%26 = call i32* @fgets(i8* %11, i32 100, i32* %8)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %18
28: ; preds = %18, %10
%29 = call i32 @fclose(i32* %8)
br label %30
30: ; preds = %1, %28
%31 = phi i32 [ 1, %28 ], [ 0, %1 ]
ret i32 %31
}