int main(void) {
  int **x;
  int nl, nc, i, j;
  nl = 3;
  nc = 4;
  x = (int **)malloc(nl * sizeof(int *));
  x[0] = (int *)malloc(nl * nc * sizeof(int));
  for (int i = 1; i < nl; i++) {
    x[i] = x[i - 1] + nc;
  }
  for (i = 0; i < nl; i++) {
    for (j = 0; j < nc; j++) {
      x[i][j] = rand() % 11 - 5;
    }
  }
  for (i = 0; i < nl; i++) {
    for (j = 0; j < nc; j++) {
      printf("%3d ", x[i][j]);
    }
    printf("\n");
  }
  free(x[0]);
  free(x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movslq -0x14(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
movslq %eax,%rdi
shl    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d4 <main+0x94>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1192 <main+0x52>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1240 <main+0x100>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122d <main+0xed>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
sub    $0x5,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ee <main+0xae>
jmp    1232 <main+0xf2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11db <main+0x9b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12b1 <main+0x171>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1295 <main+0x155>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    125a <main+0x11a>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1247 <main+0x107>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x30,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
movd   %r15d,%xmm0
movd   %ebp,%xmm1
punpckldq %xmm1,%xmm0
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
movdqa 0xe54(%rip),%xmm3
movdqa %xmm0,%xmm1
pmuludq %xmm3,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pxor   %xmm2,%xmm2
pcmpgtd %xmm0,%xmm2
pand   %xmm3,%xmm2
psubd  %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x1,%xmm1
paddd  %xmm2,%xmm1
movdqa 0xe1b(%rip),%xmm3
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psubd  %xmm1,%xmm0
paddd  0xe04(%rip),%xmm0
movdqu %xmm0,(%r14)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
movd   %r15d,%xmm0
movd   %ebp,%xmm1
punpckldq %xmm1,%xmm0
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,%xmm1
movdqa 0xd93(%rip),%xmm3
pmuludq %xmm3,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pxor   %xmm2,%xmm2
pcmpgtd %xmm0,%xmm2
pand   %xmm3,%xmm2
psubd  %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x1,%xmm1
paddd  %xmm2,%xmm1
pshufd $0xf5,%xmm1,%xmm2
movdqa 0xd59(%rip),%xmm3
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psubd  %xmm1,%xmm0
paddd  0xd47(%rip),%xmm0
movdqu %xmm0,0x10(%r14)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
movd   %r15d,%xmm0
movd   %ebp,%xmm1
punpckldq %xmm1,%xmm0
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
movdqa %xmm0,%xmm1
movdqa 0xcd5(%rip),%xmm3
pmuludq %xmm3,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pxor   %xmm2,%xmm2
pcmpgtd %xmm0,%xmm2
pand   %xmm3,%xmm2
psubd  %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x1,%xmm1
paddd  %xmm2,%xmm1
pshufd $0xf5,%xmm1,%xmm2
movdqa 0xc9b(%rip),%xmm3
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psubd  %xmm1,%xmm0
paddd  0xc89(%rip),%xmm0
movdqu %xmm0,0x20(%r14)
mov    (%r14),%esi
lea    0xc89(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x10(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x20(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%3d \00"
@.str.1 = [2 x i8] c"\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
store i32 0, i32* %1
store i32 3, i32* %3
store i32 4, i32* %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = call i8* @malloc(i64 %10)
%12 = bitcast i8* %11 to i32**
store i32** %12, i32*** %2
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = call i8* @malloc(i64 %17)
%19 = bitcast i8* %18 to i32*
%20 = load i32**, i32*** %2
%21 = getelementptr inbounds i32*, i32** %20, i64 0
store i32* %19, i32** %21
store i32 1, i32* %7
br label %22
22: ; preds = %40, %0
%23 = load i32, i32* %7
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = load i32**, i32*** %2
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %27, i64 %30
%32 = load i32*, i32** %31
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32**, i32*** %2
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
store i32* %35, i32** %39
br label %40
40: ; preds = %26
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %22
43: ; preds = %22
store i32 0, i32* %5
br label %44
44: ; preds = %69, %43
%45 = load i32, i32* %5
%46 = load i32, i32* %3
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %72
48: ; preds = %44
store i32 0, i32* %6
br label %49
49: ; preds = %65, %48
%50 = load i32, i32* %6
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %68
53: ; preds = %49
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 11
%56 = sub nsw i32 %55, 5
%57 = load i32**, i32*** %2
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32*, i32** %57, i64 %59
%61 = load i32*, i32** %60
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
store i32 %56, i32* %64
br label %65
65: ; preds = %53
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %49
68: ; preds = %49
br label %69
69: ; preds = %68
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %44
72: ; preds = %44
store i32 0, i32* %5
br label %73
73: ; preds = %98, %72
%74 = load i32, i32* %5
%75 = load i32, i32* %3
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %101
77: ; preds = %73
store i32 0, i32* %6
br label %78
78: ; preds = %93, %77
%79 = load i32, i32* %6
%80 = load i32, i32* %4
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %96
82: ; preds = %78
%83 = load i32**, i32*** %2
%84 = load i32, i32* %5
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32*, i32** %83, i64 %85
%87 = load i32*, i32** %86
%88 = load i32, i32* %6
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %87, i64 %89
%91 = load i32, i32* %90
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %82
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
br label %78
96: ; preds = %78
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %98
98: ; preds = %96
%99 = load i32, i32* %5
%100 = add nsw i32 %99, 1
store i32 %100, i32* %5
br label %73
101: ; preds = %73
%102 = load i32**, i32*** %2
%103 = getelementptr inbounds i32*, i32** %102, i64 0
%104 = load i32*, i32** %103
%105 = bitcast i32* %104 to i8*
%106 = load i32**, i32*** %2
%107 = bitcast i32** %106 to i8*
ret i32 0
}

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