#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*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int *malloc(int);
void get_graph(int **table, int *size_arr) {
  FILE *fd = fopen("data/preprocess.txt", "r");
  int i, j;
  int size;
  for (i = 0; i < 27770; i++) {
    fscanf(fd, "%d", &size);
    size_arr[i] = size;
    table[i] = malloc(size * sizeof(int));
    for (j = 0; j < size; j++) {
      fscanf(fd, "%d", &table[i][j]);
    }
  }
  fclose(fd);
}


x86 assembly (clang, -O0):
<get_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea9(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6c7a,-0x1c(%rbp)
jge    1216 <get_graph+0xd6>
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1203 <get_graph+0xc3>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe26(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <get_graph+0x82>
jmp    1208 <get_graph+0xc8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <get_graph+0x2e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_graph>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r15
lea    0xea3(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0xea1(%rip),%r12
jmp    1191 <get_graph+0x51>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    $0x6c7a,%rbp
je     1219 <get_graph+0xd9>
mov    %rbx,%rdi
mov    %r12,%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
mov    0xc(%rsp),%r14d
mov    0x10(%rsp),%rax
mov    %r14d,(%rax,%rbp,4)
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
test   %r14d,%r14d
jle    1180 <get_graph+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1040 <fscanf@plt>
cmpl   $0x2,0xc(%rsp)
jl     1180 <get_graph+0x40>
mov    $0x1,%r13d
mov    $0x4,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rdx
add    %r14,%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <fscanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%rax
add    $0x4,%r14
cmp    %rax,%r13
jl     11f0 <get_graph+0xb0>
jmp    1180 <get_graph+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"data/preprocess.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
define void @get_graph(i32** nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i32* %3 to i8*
br label %6
6: ; preds = %2, %28
%7 = phi i64 [ 0, %2 ], [ %29, %28 ]
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = getelementptr inbounds i32, i32* %1, i64 %7
store i32 %9, i32* %10
%11 = shl i32 %9, 2
%12 = call i32* @malloc(i32 %11)
%13 = getelementptr inbounds i32*, i32** %0, i64 %7
store i32* %12, i32** %13
%14 = icmp sgt i32 %9, 0
br i1 %14, label %15, label %28
15: ; preds = %6
%16 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %28
19: ; preds = %15, %19
%20 = phi i64 [ %24, %19 ], [ 1, %15 ]
%21 = load i32*, i32** %13
%22 = getelementptr inbounds i32, i32* %21, i64 %20
%23 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %20, 1
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %19, label %28
28: ; preds = %19, %15, %6
%29 = add nuw nsw i64 %7, 1
%30 = icmp eq i64 %29, 27770
br i1 %30, label %31, label %6
31: ; preds = %28
%32 = call i32 @fclose(i32* %4)
ret void
}