#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 */
void *calloc(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, double *);
double **createMatrix(int m, int n) {
  double **matrix;
  int i, j;
  matrix = calloc(m, sizeof(double *));
  for (i = 0; i < m; i++) {
    matrix[i] = calloc(n, sizeof(double));
    printf("Unesite %d. vrstu matrice:\n", i);
    for (j = 0; j < n; j++)
      scanf("%lf", &matrix[i][j]);
  }
  return matrix;
}


x86 assembly (clang, -O0):
<createMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e4 <createMatrix+0xb4>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d1 <createMatrix+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe5e(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1194 <createMatrix+0x64>
jmp    11d6 <createMatrix+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <createMatrix+0x26>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r12d
mov    %edi,%ebx
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x8(%rsp)
test   %ebx,%ebx
jle    11c7 <createMatrix+0x97>
mov    %ebx,%r15d
mov    %r12d,%eax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
lea    0xeb1(%rip),%rbp
jmp    1179 <createMatrix+0x49>
nopl   (%rax)
add    $0x1,%r13
cmp    %r15,%r13
je     11c7 <createMatrix+0x97>
mov    %r12d,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
mov    %rbx,(%rax,%r13,8)
lea    0xe67(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
test   %r12d,%r12d
jle    1170 <createMatrix+0x40>
mov    0x10(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%r14
jne    11b0 <createMatrix+0x80>
jmp    1170 <createMatrix+0x40>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [28 x i8] c"Unesite %d. vrstu matrice:\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
define noalias double** @createMatrix(i32 %0, i32 %1) {
%3 = tail call i8* @calloc(i32 %0, i32 8)
%4 = bitcast i8* %3 to double**
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %27
6: ; preds = %2
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %24
%11 = phi i64 [ 0, %6 ], [ %25, %24 ]
%12 = tail call i8* @calloc(i32 %1, i32 8)
%13 = getelementptr inbounds double*, double** %4, i64 %11
%14 = bitcast double** %13 to i8**
store i8* %12, i8** %14
%15 = trunc i64 %11 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = bitcast i8* %12 to double*
br i1 %7, label %18, label %24
18: ; preds = %10, %18
%19 = phi i64 [ %22, %18 ], [ 0, %10 ]
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %20)
%22 = add nuw nsw i64 %19, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %18
24: ; preds = %18, %10
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %10
27: ; preds = %24, %2
ret double** %4
}