#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int strlen(char const *);
void readMatrixDescriptor(int *desc, const char *location) {
  char *file_name = malloc(sizeof(char) * (strlen(location) + 300));
  sprintf(file_name, "%s/descriptor.txt", location);
  FILE *store = fopen(file_name, "r");
  int i;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int size = 9;
  for (i = 0; i < size; i++) {
    if ((read = getline(&line, &len, store)) != -1) {
      desc[i] = atoi(line);
    }
  }
  free(line);
  fclose(store);
}


x86 assembly (clang, -O0):
<readMatrixDescriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x12c,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x9,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1247 <readMatrixDescriptor+0xc7>
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1090 <getline@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     1234 <readMatrixDescriptor+0xb4>
mov    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1239 <readMatrixDescriptor+0xb9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f5 <readMatrixDescriptor+0x75>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readMatrixDescriptor>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
lea    0x12c(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe54(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   10a0 <sprintf@plt>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%r15
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     11fb <readMatrixDescriptor+0x7b>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     121d <readMatrixDescriptor+0x9d>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x4(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     123f <readMatrixDescriptor+0xbf>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x8(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     1261 <readMatrixDescriptor+0xe1>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0xc(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     1283 <readMatrixDescriptor+0x103>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x10(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     12a5 <readMatrixDescriptor+0x125>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x14(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     12c7 <readMatrixDescriptor+0x147>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x18(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     12e9 <readMatrixDescriptor+0x169>
mov    (%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x1c(%r14)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
mov    (%rsp),%rbx
cmp    $0xffffffff,%eax
je     130e <readMatrixDescriptor+0x18e>
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %eax,0x20(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%s/descriptor.txt\00"
@.str.1 = [2 x i8] c"r\00"
define void @readMatrixDescriptor(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, 300
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
%17 = trunc i64 %16 to i32
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %5
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
store i8* null, i8** %8
store i64 0, i64* %9
store i32 9, i32* %11
store i32 0, i32* %7
br label %24
24: ; preds = %40, %2
%25 = load i32, i32* %7
%26 = load i32, i32* %11
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i32*, i32** %6
%30 = call i32 @getline(i8** %8, i64* %9, i32* %29)
store i32 %30, i32* %10
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = load i8*, i8** %8
%34 = call i32 @atoi(i8* %33)
%35 = load i32*, i32** %3
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %32, %28
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %24
43: ; preds = %24
%44 = load i8*, i8** %8
%45 = call i32 @free(i8* %44)
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s/descriptor.txt\00"
@.str.1 = [2 x i8] c"r\00"
define void @readMatrixDescriptor(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, 300
%7 = tail call i8* @malloc(i32 %6)
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%11 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%12 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%13 = icmp eq i32 %12, -1
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %0
br label %17
17: ; preds = %2, %14
%18 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%19 = icmp eq i32 %18, -1
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = call i32 @atoi(i8* %21)
%23 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %22, i32* %23
br label %24
24: ; preds = %20, %17
%25 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%26 = icmp eq i32 %25, -1
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = load i8*, i8** %3
%29 = call i32 @atoi(i8* %28)
%30 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %29, i32* %30
br label %31
31: ; preds = %27, %24
%32 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%33 = icmp eq i32 %32, -1
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = call i32 @atoi(i8* %35)
%37 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %36, i32* %37
br label %38
38: ; preds = %34, %31
%39 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%40 = icmp eq i32 %39, -1
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = load i8*, i8** %3
%43 = call i32 @atoi(i8* %42)
%44 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %43, i32* %44
br label %45
45: ; preds = %41, %38
%46 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%47 = icmp eq i32 %46, -1
br i1 %47, label %52, label %48
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = call i32 @atoi(i8* %49)
%51 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %50, i32* %51
br label %52
52: ; preds = %48, %45
%53 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%54 = icmp eq i32 %53, -1
br i1 %54, label %59, label %55
55: ; preds = %52
%56 = load i8*, i8** %3
%57 = call i32 @atoi(i8* %56)
%58 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %57, i32* %58
br label %59
59: ; preds = %55, %52
%60 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%61 = icmp eq i32 %60, -1
br i1 %61, label %66, label %62
62: ; preds = %59
%63 = load i8*, i8** %3
%64 = call i32 @atoi(i8* %63)
%65 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %64, i32* %65
br label %66
66: ; preds = %62, %59
%67 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%68 = icmp eq i32 %67, -1
%69 = load i8*, i8** %3
br i1 %68, label %73, label %70
70: ; preds = %66
%71 = call i32 @atoi(i8* %69)
%72 = getelementptr inbounds i32, i32* %0, i64 8
store i32 %71, i32* %72
br label %73
73: ; preds = %66, %70
%74 = call i32 @free(i8* %69)
%75 = call i32 @fclose(i32* %9)
ret void
}