#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int ***, int **, int *, int **);
int main() {
  int *pv = (int *)malloc(5 * sizeof(int));
  for (int i = 0; i < 5; i++) {
    pv[i] = i + 1;
  }
  int *pv2;
  pv2 = (int *)malloc(5 * sizeof(int));
  for (int i = 0; i < 5; i++) {
    *(pv + i) = i + 1;
  }
  int *arr[5];
  for (int i = 0; i < 5; i++) {
    arr[i] = (int *)malloc(sizeof(int));
    *arr[i] = i;
  }
  int *arr2[5];
  for (int i = 0; i < 5; i++) {
    *(arr + i) = (int *)malloc(sizeof(int));
    **(arr + i) = i;
  }
  printf("&arr2= %p\n&arr2[0]= %p\n&arrr2[0][0]= %p\narr2= %p\n", &arr2,
         &arr2[0], &arr2[0][0], arr2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1170 <main+0x50>
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <main+0x27>
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11ae <main+0x8e>
mov    -0x24(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1185 <main+0x65>
movl   $0x0,-0x54(%rbp)
cmpl   $0x5,-0x54(%rbp)
jge    11f1 <main+0xd1>
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x54(%rbp),%ecx
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    %ecx,(%rax)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11b5 <main+0x95>
movl   $0x0,-0x84(%rbp)
cmpl   $0x5,-0x84(%rbp)
jge    1249 <main+0x129>
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
movslq -0x84(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x84(%rbp),%ecx
movslq -0x84(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    %ecx,(%rax)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11fb <main+0xdb>
lea    -0x80(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    -0x80(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    0xda0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movaps 0xec7(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x5,0x10(%rax)
mov    $0x14,%edi
call   1040 <malloc@plt>
movaps 0xeac(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0x5,0x10(%rbx)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x0,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x1,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x2,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x3,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x4,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x0,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x1,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x2,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x3,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x4,(%rax)
lea    0xe0b(%rip),%rdi
mov    %rsp,%rdx
mov    %rdx,%rsi
mov    %rdx,%r8
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"&arr2= %p\0A&arr2[0]= %p\0A&arrr2[0][0]= %p\0Aarr2= %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [5 x i32*]
%7 = alloca i32
%8 = alloca [5 x i32*]
%9 = alloca i32
store i32 0, i32* %1
%10 = call i64 @malloc(i32 20)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %2
store i32 0, i32* %3
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %15
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %12
25: ; preds = %12
%26 = call i64 @malloc(i32 20)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %4
store i32 0, i32* %5
br label %28
28: ; preds = %38, %25
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = load i32*, i32** %2
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %31
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %28
41: ; preds = %28
store i32 0, i32* %7
br label %42
42: ; preds = %56, %41
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 5
br i1 %44, label %45, label %59
45: ; preds = %42
%46 = call i64 @malloc(i32 4)
%47 = inttoptr i64 %46 to i32*
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [5 x i32*], [5 x i32*]* %6, i64 0, i64 %49
store i32* %47, i32** %50
%51 = load i32, i32* %7
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5 x i32*], [5 x i32*]* %6, i64 0, i64 %53
%55 = load i32*, i32** %54
store i32 %51, i32* %55
br label %56
56: ; preds = %45
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %42
59: ; preds = %42
store i32 0, i32* %9
br label %60
60: ; preds = %76, %59
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 5
br i1 %62, label %63, label %79
63: ; preds = %60
%64 = call i64 @malloc(i32 4)
%65 = inttoptr i64 %64 to i32*
%66 = getelementptr inbounds [5 x i32*], [5 x i32*]* %6, i64 0, i64 0
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32*, i32** %66, i64 %68
store i32* %65, i32** %69
%70 = load i32, i32* %9
%71 = getelementptr inbounds [5 x i32*], [5 x i32*]* %6, i64 0, i64 0
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32*, i32** %71, i64 %73
%75 = load i32*, i32** %74
store i32 %70, i32* %75
br label %76
76: ; preds = %63
%77 = load i32, i32* %9
%78 = add nsw i32 %77, 1
store i32 %78, i32* %9
br label %60
79: ; preds = %60
%80 = bitcast [5 x i32*]* %8 to i32***
%81 = getelementptr inbounds [5 x i32*], [5 x i32*]* %8, i64 0, i64 0
%82 = getelementptr inbounds [5 x i32*], [5 x i32*]* %8, i64 0, i64 0
%83 = load i32*, i32** %82
%84 = getelementptr inbounds i32, i32* %83, i64 0
%85 = getelementptr inbounds [5 x i32*], [5 x i32*]* %8, i64 0, i64 0
%86 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32*** %80, i32** %81, i32* %84, i32** %85)
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
@.str = [50 x i8] c"&arr2= %p\0A&arr2[0]= %p\0A&arrr2[0][0]= %p\0Aarr2= %p\0A\00"
define i32 @main() {
%1 = alloca [5 x i32*]
%2 = tail call i64 @malloc(i32 20)
%3 = inttoptr i64 %2 to i32*
%4 = inttoptr i64 %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %3, i64 4
store i32 5, i32* %5
%6 = tail call i64 @malloc(i32 20)
%7 = inttoptr i64 %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %7
store i32 5, i32* %5
%8 = tail call i64 @malloc(i32 4)
%9 = inttoptr i64 %8 to i32*
store i32 0, i32* %9
%10 = tail call i64 @malloc(i32 4)
%11 = inttoptr i64 %10 to i32*
store i32 1, i32* %11
%12 = tail call i64 @malloc(i32 4)
%13 = inttoptr i64 %12 to i32*
store i32 2, i32* %13
%14 = tail call i64 @malloc(i32 4)
%15 = inttoptr i64 %14 to i32*
store i32 3, i32* %15
%16 = tail call i64 @malloc(i32 4)
%17 = inttoptr i64 %16 to i32*
store i32 4, i32* %17
%18 = bitcast [5 x i32*]* %1 to i8*
%19 = tail call i64 @malloc(i32 4)
%20 = inttoptr i64 %19 to i32*
store i32 0, i32* %20
%21 = tail call i64 @malloc(i32 4)
%22 = inttoptr i64 %21 to i32*
store i32 1, i32* %22
%23 = tail call i64 @malloc(i32 4)
%24 = inttoptr i64 %23 to i32*
store i32 2, i32* %24
%25 = tail call i64 @malloc(i32 4)
%26 = inttoptr i64 %25 to i32*
store i32 3, i32* %26
%27 = tail call i64 @malloc(i32 4)
%28 = inttoptr i64 %27 to i32*
store i32 4, i32* %28
%29 = bitcast [5 x i32*]* %1 to i32***
%30 = getelementptr inbounds [5 x i32*], [5 x i32*]* %1, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32*** %29, i32** %30, i32* undef, i32** %30)
ret i32 0
}