#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 **malloc2d(int, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int i, j, k;
  int x = 10;
  int y = 10;
  int z = 10;
  int **t = malloc2d(y, x);
  for (i = 0; i < y; ++i) {
    for (j = 0; j < x; ++j) {
      t[i][j] = 1;
    }
  }
  printf("2d Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <malloc2d@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b1 <main+0x91>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119e <main+0x7e>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x4d>
jmp    11a3 <main+0x83>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115a <main+0x3a>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
mov    $0xa,%esi
call   1030 <malloc2d@plt>
mov    (%rax),%rdx
movaps 0xec6(%rip),%xmm0
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
movabs $0x100000001,%rcx
mov    %rcx,0x20(%rdx)
mov    0x8(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x10(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x18(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x20(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x28(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x30(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x38(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x40(%rax),%rdx
movups %xmm0,(%rdx)
movups %xmm0,0x10(%rdx)
mov    %rcx,0x20(%rdx)
mov    0x48(%rax),%rax
movups %xmm0,(%rax)
movups %xmm0,0x10(%rax)
mov    %rcx,0x20(%rax)
lea    0xe33(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str = [11 x i8] c"2d Success\00"
define i32 @main() {
%1 = tail call i32** @malloc2d(i32 10, i32 10)
%2 = load i32*, i32** %1
%3 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %3
%4 = getelementptr inbounds i32, i32* %2, i64 4
%5 = bitcast i32* %4 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %5
%6 = getelementptr inbounds i32, i32* %2, i64 8
store i32 1, i32* %6
%7 = getelementptr inbounds i32, i32* %2, i64 9
store i32 1, i32* %7
%8 = getelementptr inbounds i32*, i32** %1, i64 1
%9 = load i32*, i32** %8
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %9, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %9, i64 8
store i32 1, i32* %13
%14 = getelementptr inbounds i32, i32* %9, i64 9
store i32 1, i32* %14
%15 = getelementptr inbounds i32*, i32** %1, i64 2
%16 = load i32*, i32** %15
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %16, i64 4
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %16, i64 8
store i32 1, i32* %20
%21 = getelementptr inbounds i32, i32* %16, i64 9
store i32 1, i32* %21
%22 = getelementptr inbounds i32*, i32** %1, i64 3
%23 = load i32*, i32** %22
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %23, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %23, i64 8
store i32 1, i32* %27
%28 = getelementptr inbounds i32, i32* %23, i64 9
store i32 1, i32* %28
%29 = getelementptr inbounds i32*, i32** %1, i64 4
%30 = load i32*, i32** %29
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %31
%32 = getelementptr inbounds i32, i32* %30, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %30, i64 8
store i32 1, i32* %34
%35 = getelementptr inbounds i32, i32* %30, i64 9
store i32 1, i32* %35
%36 = getelementptr inbounds i32*, i32** %1, i64 5
%37 = load i32*, i32** %36
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %38
%39 = getelementptr inbounds i32, i32* %37, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %40
%41 = getelementptr inbounds i32, i32* %37, i64 8
store i32 1, i32* %41
%42 = getelementptr inbounds i32, i32* %37, i64 9
store i32 1, i32* %42
%43 = getelementptr inbounds i32*, i32** %1, i64 6
%44 = load i32*, i32** %43
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %45
%46 = getelementptr inbounds i32, i32* %44, i64 4
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %47
%48 = getelementptr inbounds i32, i32* %44, i64 8
store i32 1, i32* %48
%49 = getelementptr inbounds i32, i32* %44, i64 9
store i32 1, i32* %49
%50 = getelementptr inbounds i32*, i32** %1, i64 7
%51 = load i32*, i32** %50
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %52
%53 = getelementptr inbounds i32, i32* %51, i64 4
%54 = bitcast i32* %53 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %54
%55 = getelementptr inbounds i32, i32* %51, i64 8
store i32 1, i32* %55
%56 = getelementptr inbounds i32, i32* %51, i64 9
store i32 1, i32* %56
%57 = getelementptr inbounds i32*, i32** %1, i64 8
%58 = load i32*, i32** %57
%59 = bitcast i32* %58 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %59
%60 = getelementptr inbounds i32, i32* %58, i64 4
%61 = bitcast i32* %60 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %61
%62 = getelementptr inbounds i32, i32* %58, i64 8
store i32 1, i32* %62
%63 = getelementptr inbounds i32, i32* %58, i64 9
store i32 1, i32* %63
%64 = getelementptr inbounds i32*, i32** %1, i64 9
%65 = load i32*, i32** %64
%66 = bitcast i32* %65 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %66
%67 = getelementptr inbounds i32, i32* %65, i64 4
%68 = bitcast i32* %67 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %68
%69 = getelementptr inbounds i32, i32* %65, i64 8
store i32 1, i32* %69
%70 = getelementptr inbounds i32, i32* %65, i64 9
store i32 1, i32* %70
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}