#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 */

/* Variables and functions */
int /*<<< orphan*/ free(double **);
int /*<<< orphan*/ load_image(double **, int, int, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int line = 3, row = 3;
  int i = 0, j = 0;
  double **image = NULL;
  image = (double **)malloc(line * sizeof(double *));
  for (i = 0; i < line; i++) {
    image[i] = (double *)malloc(row * sizeof(double));
  }
  load_image(image, line, row, "test_im.txt");
  for (i = 0; i < line; i++) {
    for (j = 0; j < row; j++) {
      printf("%f ", image[i][j]);
    }
    printf("\n");
  }
  free(image);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cc <main+0x8c>
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x54>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe23(%rip),%rcx
call   1050 <load_image@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1255 <main+0x115>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1239 <main+0xf9>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11fc <main+0xbc>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e9 <main+0xa9>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x18,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x18,%edi
call   1070 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x18,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x18,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rbx)
lea    0xe6f(%rip),%rcx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <load_image@plt>
mov    (%rbx),%rax
movsd  (%rax),%xmm0
lea    0xe5b(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    (%rbx),%rax
movsd  0x8(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    (%rbx),%rax
movsd  0x10(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x8(%rbx),%rax
movsd  (%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x8(%rbx),%rax
movsd  0x8(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x8(%rbx),%rax
movsd  0x10(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x10(%rbx),%rax
movsd  (%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x10(%rbx),%rax
movsd  0x8(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x10(%rbx),%rax
movsd  0x10(%rax),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"test_im.txt\00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
store i32 3, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store double** null, double*** %10
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 8
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double**
store double** %16, double*** %10
store i32 0, i32* %8
br label %17
17: ; preds = %32, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to double*
%28 = load double**, double*** %10
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %28, i64 %30
store double* %27, double** %31
br label %32
32: ; preds = %21
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %17
35: ; preds = %17
%36 = load double**, double*** %10
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = call i32 @load_image(double** %36, i32 %37, i32 %38, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %40
40: ; preds = %65, %35
%41 = load i32, i32* %8
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %68
44: ; preds = %40
store i32 0, i32* %9
br label %45
45: ; preds = %60, %44
%46 = load i32, i32* %9
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load double**, double*** %10
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double*, double** %50, i64 %52
%54 = load double*, double** %53
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %58)
br label %60
60: ; preds = %49
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %45
63: ; preds = %45
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %63
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
store i32 %67, i32* %8
br label %40
68: ; preds = %40
%69 = load double**, double*** %10
%70 = call i32 @free(double** %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"test_im.txt\00"
@.str.1 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 24)
%4 = inttoptr i64 %3 to double**
%5 = tail call i64 @malloc(i32 24)
%6 = inttoptr i64 %5 to double*
store double* %6, double** %4
%7 = tail call i64 @malloc(i32 24)
%8 = inttoptr i64 %7 to double*
%9 = getelementptr inbounds double*, double** %4, i64 1
store double* %8, double** %9
%10 = tail call i64 @malloc(i32 24)
%11 = inttoptr i64 %10 to double*
%12 = getelementptr inbounds double*, double** %4, i64 2
store double* %11, double** %12
%13 = tail call i32 @load_image(double** %4, i32 3, i32 3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = load double*, double** %4
%15 = load double, double* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %23)
%25 = tail call i32 @putchar(i32 10)
%26 = load double*, double** %9
%27 = load double, double* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = load double*, double** %9
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %31)
%33 = load double*, double** %9
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = tail call i32 @putchar(i32 10)
%38 = load double*, double** %12
%39 = load double, double* %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %39)
%41 = load double*, double** %12
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %43)
%45 = load double*, double** %12
%46 = getelementptr inbounds double, double* %45, i64 2
%47 = load double, double* %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %47)
%49 = tail call i32 @putchar(i32 10)
%50 = tail call i32 @free(double** %4)
ret i32 0
}