#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int saveIndex(int index[2][11]) {
  FILE *fp = NULL;
  char destination[] = "Database/profile/index";
  fp = fopen(destination, "w");
  if (fp == NULL) {
    return 0;
  }
  char data[100];
  for (int i = 0; i < 11; i++) {
    sprintf(data, "%d,%d", index[0][i], index[1][i]);
    fprintf(fp, "%s\n", data);
  }
  fclose(fp);
  fp = NULL;
  return 1;
}


x86 assembly (clang, -O0):
<saveIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0xea2(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9d(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xe97(%rip),%ax
mov    %ax,-0x1c(%rbp)
mov    0xe8f(%rip),%al
mov    %al,-0x1a(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <saveIndex+0x75>
movl   $0x0,-0x4(%rbp)
jmp    123f <saveIndex+0xff>
movl   $0x0,-0xa4(%rbp)
cmpl   $0xb,-0xa4(%rbp)
jge    1227 <saveIndex+0xe7>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0xa4(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0xa4(%rbp),%rcx
mov    0x2c(%rax,%rcx,4),%ecx
lea    0xe22(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xe11(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11bf <saveIndex+0x7f>
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):
<saveIndex>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %rdi,%rbx
movaps 0xea6(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x7865646e692f65,%rax
mov    %rax,0xf(%rsp)
lea    0xea3(%rip),%rsi
mov    %rsp,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     12fe <saveIndex+0x1be>
mov    %rax,%r14
mov    (%rbx),%edx
mov    0x2c(%rbx),%ecx
lea    0xe85(%rip),%r12
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
lea    0xe74(%rip),%r13
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x4(%rbx),%edx
mov    0x30(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x8(%rbx),%edx
mov    0x34(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0xc(%rbx),%edx
mov    0x38(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x10(%rbx),%edx
mov    0x3c(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x14(%rbx),%edx
mov    0x40(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x18(%rbx),%edx
mov    0x44(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x1c(%rbx),%edx
mov    0x48(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x20(%rbx),%edx
mov    0x4c(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x24(%rbx),%edx
mov    0x50(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    0x28(%rbx),%edx
mov    0x54(%rbx),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    1300 <saveIndex+0x1c0>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.saveIndex.destination = [23 x i8] c"Database/profile/index\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [6 x i8] c"%d,%d\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @saveIndex([11 x i32]* nocapture %0) {
%2 = alloca [23 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %76, label %7
7: ; preds = %1
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 0
%12 = load i32, i32* %11
%13 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
%14 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%15 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 1
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%21 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 2
%22 = load i32, i32* %21
%23 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 2
%24 = load i32, i32* %23
%25 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %24)
%26 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%27 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 3
%28 = load i32, i32* %27
%29 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 3
%30 = load i32, i32* %29
%31 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30)
%32 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%33 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 4
%34 = load i32, i32* %33
%35 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 4
%36 = load i32, i32* %35
%37 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %36)
%38 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%39 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 5
%40 = load i32, i32* %39
%41 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 5
%42 = load i32, i32* %41
%43 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %42)
%44 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%45 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 6
%46 = load i32, i32* %45
%47 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 6
%48 = load i32, i32* %47
%49 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %46, i32 %48)
%50 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%51 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 7
%52 = load i32, i32* %51
%53 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 7
%54 = load i32, i32* %53
%55 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %52, i32 %54)
%56 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%57 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 8
%58 = load i32, i32* %57
%59 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 8
%60 = load i32, i32* %59
%61 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %60)
%62 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%63 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 9
%64 = load i32, i32* %63
%65 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 9
%66 = load i32, i32* %65
%67 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %64, i32 %66)
%68 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%69 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 0, i64 10
%70 = load i32, i32* %69
%71 = getelementptr inbounds [11 x i32], [11 x i32]* %0, i64 1, i64 10
%72 = load i32, i32* %71
%73 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %70, i32 %72)
%74 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%75 = call i32 @fclose(i32* %5)
br label %76
76: ; preds = %1, %7
%77 = phi i32 [ 1, %7 ], [ 0, %1 ]
ret i32 %77
}