#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 */
double **aml_array_dbl_2d_new(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *);
double **aml_array_dbl_2d_load(FILE *file, int s1, int s2) {
  int i, j;
  double **arr = aml_array_dbl_2d_new(s1, s2, 0);
  for (i = 0; i < s1; i++)
    for (j = 0; j < s2; j++)
      fscanf(file, "%lf", &arr[i][j]);
  return arr;
}


x86 assembly (clang, -O0):
<aml_array_dbl_2d_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
xor    %edx,%edx
call   1040 <aml_array_dbl_2d_new@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <aml_array_dbl_2d_load+0x91>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119e <aml_array_dbl_2d_load+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe75(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115d <aml_array_dbl_2d_load+0x3d>
jmp    11a3 <aml_array_dbl_2d_load+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <aml_array_dbl_2d_load+0x2a>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_2d_load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r15d
mov    %rdi,%r13
mov    %esi,%edi
mov    %edx,0xc(%rsp)
mov    %edx,%esi
xor    %edx,%edx
call   1040 <aml_array_dbl_2d_new@plt>
mov    %rax,%rbp
test   %r15d,%r15d
jle    11ae <aml_array_dbl_2d_load+0x8e>
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
shl    $0x3,%rbx
xor    %r14d,%r14d
lea    0xe9b(%rip),%r15
jmp    117b <aml_array_dbl_2d_load+0x5b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11ae <aml_array_dbl_2d_load+0x8e>
cmpl   $0x0,0xc(%rsp)
jle    1170 <aml_array_dbl_2d_load+0x50>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp,%r14,8),%rdx
add    %r12,%rdx
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <fscanf@plt>
add    $0x8,%r12
cmp    %r12,%rbx
jne    1190 <aml_array_dbl_2d_load+0x70>
jmp    1170 <aml_array_dbl_2d_load+0x50>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define double** @aml_array_dbl_2d_load(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double**
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call double** @aml_array_dbl_2d_new(i32 %10, i32 %11, i32 0)
store double** %12, double*** %9
store i32 0, i32* %7
br label %13
13: ; preds = %37, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %40
17: ; preds = %13
store i32 0, i32* %8
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32*, i32** %4
%24 = load double**, double*** %9
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double*, double** %24, i64 %26
%28 = load double*, double** %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %31)
br label %33
33: ; preds = %22
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %18
36: ; preds = %18
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %13
40: ; preds = %13
%41 = load double**, double*** %9
ret double** %41
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define double** @aml_array_dbl_2d_load(i32* nocapture %0, i32 %1, i32 %2) {
%4 = tail call double** @aml_array_dbl_2d_new(i32 %1, i32 %2, i32 0)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %21
%11 = phi i64 [ 0, %6 ], [ %22, %21 ]
br i1 %7, label %12, label %21
12: ; preds = %10
%13 = getelementptr inbounds double*, double** %4, i64 %11
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %19, %14 ]
%16 = load double*, double** %13
%17 = getelementptr inbounds double, double* %16, i64 %15
%18 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %17)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %14
21: ; preds = %14, %10
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %10
24: ; preds = %21, %3
ret double** %4
}