void test4() {
  int n = 5;
  int data[] = {1, 3, 5, 7, 9};
  int *num[n];
  int **p;
  int i;
  for (i = 0; i < n; i++) {
    num[i] = &data[i];
  }
  p = num;
  for (i = 0; i < n; i++) {
    printf("%d: data = %d; num = %6X\n", i, data[i], num[i]);
    printf("%d: *p = %6X; **p = %d\n", i, *p, **p);
    p++;
  }
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x5,-0x4(%rbp)
mov    0xeeb(%rip),%eax
mov    %eax,-0x10(%rbp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1196 <test4+0x86>
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
lea    -0x20(%rbp),%rdx
shl    $0x2,%rcx
add    %rcx,%rdx
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1161 <test4+0x51>
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1211 <test4+0x101>
mov    -0x48(%rbp),%rax
mov    -0x3c(%rbp),%esi
movslq -0x3c(%rbp),%rcx
mov    -0x20(%rbp,%rcx,4),%edx
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a5 <test4+0x95>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r12
mov    0xee9(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x4(%rsp),%rbp
lea    0x8(%rsp),%r13
lea    0xecd(%rip),%r15
mov    %rsp,%r14
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%ecx
lea    0xec6(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    $0x2,%esi
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    $0x3,%esi
lea    0xc(%rsp),%rbp
mov    %rbp,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %r15,%rdi
mov    $0x4,%esi
lea    0x10(%rsp),%rbp
mov    %rbp,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rsp
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test4.data = [5 x i32] [i32 1, i32 3, i32 5, i32 7, i32 9]
@.str = [26 x i8] c"%d: data = %d; num = %6X\0A\00"
@.str.1 = [24 x i8] c"%d: *p = %6X; **p = %d\0A\00"
define void @test4() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32**
%6 = alloca i32
store i32 5, i32* %1
%7 = bitcast [5 x i32]* %2 to i8*
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32*, i64 %9
store i64 %9, i64* %4
store i32 0, i32* %6
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %6
%14 = load i32, i32* %1
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %11, i64 %21
store i32* %19, i32** %22
br label %23
23: ; preds = %16
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %12
26: ; preds = %12
store i32** %11, i32*** %5
store i32 0, i32* %6
br label %27
27: ; preds = %51, %26
%28 = load i32, i32* %6
%29 = load i32, i32* %1
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %54
31: ; preds = %27
%32 = load i32, i32* %6
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %11, i64 %38
%40 = load i32*, i32** %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %36, i32* %40)
%42 = load i32, i32* %6
%43 = load i32**, i32*** %5
%44 = load i32*, i32** %43
%45 = load i32**, i32*** %5
%46 = load i32*, i32** %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32* %44, i32 %47)
%49 = load i32**, i32*** %5
%50 = getelementptr inbounds i32*, i32** %49, i32 1
store i32** %50, i32*** %5
br label %51
51: ; preds = %31
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %27
54: ; preds = %27
%55 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@__const.test4.data = [5 x i32] [i32 1, i32 3, i32 5, i32 7, i32 9]
@.str = [26 x i8] c"%d: data = %d; num = %6X\0A\00"
@.str.1 = [24 x i8] c"%d: *p = %6X; **p = %d\0A\00"
define void @test4() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 0, i32 1, i32* %4)
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* %4, i32 %10)
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32 %12, i32* %5)
%14 = load i32, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 1, i32* %5, i32 %14)
%16 = load i32, i32* %6
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 2, i32 %16, i32* %6)
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 2, i32* %6, i32 %18)
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 3, i32 %20, i32* %7)
%22 = load i32, i32* %7
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 3, i32* %7, i32 %22)
%24 = load i32, i32* %8
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 4, i32 %24, i32* %8)
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 4, i32* %8, i32 %26)
ret void
}