#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*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int **inti_2DArray(int, int);
int **create_2DArray(FILE *ptr, int r, int c) {
  int **x, i, j;
  x = inti_2DArray(r, c);
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      fscanf(ptr, "%d", &x[i][j]);
    }
  }
  return x;
}


x86 assembly (clang, -O0):
<create_2DArray>:
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
call   1030 <inti_2DArray@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <create_2DArray+0x8f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119c <create_2DArray+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe77(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <create_2DArray+0x3b>
jmp    11a1 <create_2DArray+0x81>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <create_2DArray+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_2DArray>:
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
call   1030 <inti_2DArray@plt>
mov    %rax,%rbp
test   %r15d,%r15d
jle    11ae <create_2DArray+0x8e>
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
shl    $0x2,%rbx
xor    %r14d,%r14d
lea    0xe9d(%rip),%r15
jmp    117b <create_2DArray+0x5b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11ae <create_2DArray+0x8e>
cmpl   $0x0,0xc(%rsp)
jle    1170 <create_2DArray+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   1040 <fscanf@plt>
add    $0x4,%r12
cmp    %r12,%rbx
jne    1190 <create_2DArray+0x70>
jmp    1170 <create_2DArray+0x50>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32** @create_2DArray(i32* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32** @inti_2DArray(i32 %1, i32 %2)
%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 i32*, i32** %4, i64 %11
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %19, %14 ]
%16 = load i32*, i32** %13
%17 = getelementptr inbounds i32, i32* %16, i64 %15
%18 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %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 i32** %4
}