#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 /*<<< orphan*/ assertTrue(char *, int);
double *malloc(int);
int /*<<< orphan*/ zero_out(double **, int);
void test_double_ptr() {
  double *p[3];
  p[0] = malloc(sizeof(double) * 10);
  p[1] = malloc(sizeof(double) * 20);
  p[2] = malloc(sizeof(double) * 30);
  p[0][0] = 41;
  p[1][1] = 42;
  p[2][2] = 43;
  zero_out(p + 1, sizeof(double *) * 2);
  assertTrue("p[0][0] == 41", p[0][0] == 41);
  ;
  assertTrue("p[1] == NULL", p[1] == NULL);
  ;
  assertTrue("p[2] == NULL", p[2] == NULL);
  ;
}


x86 assembly (clang, -O0):
<test_double_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x50,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0xf0,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
mov    $0x10,%esi
call   1050 <zero_out@plt>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe4a(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe4a(%rip),%rdi
call   1030 <assertTrue@plt>
cmpq   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe3f(%rip),%rdi
call   1030 <assertTrue@plt>
cmpq   $0x0,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe33(%rip),%rdi
call   1030 <assertTrue@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_ptr>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x50,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%rsp)
mov    $0xa0,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%r15
mov    %rax,0x8(%rsp)
mov    $0xf0,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%rsp)
movabs $0x4044800000000000,%rcx
80 44 40
mov    %rcx,(%r14)
movabs $0x4045000000000000,%rcx
mov    %rcx,0x8(%rbx)
movabs $0x4045800000000000,%rcx
80 45 40
mov    %rcx,0x10(%rax)
mov    %r15,%rdi
mov    $0x10,%esi
call   1050 <zero_out@plt>
mov    (%rsp),%rax
movsd  0xe4e(%rip),%xmm0
cmpeqsd (%rax),%xmm0
movq   %xmm0,%rsi
and    $0x1,%esi
lea    0xe42(%rip),%rdi
call   1030 <assertTrue@plt>
xor    %esi,%esi
cmpq   $0x0,0x8(%rsp)
sete   %sil
lea    0xe38(%rip),%rdi
call   1030 <assertTrue@plt>
xor    %esi,%esi
cmpq   $0x0,0x10(%rsp)
sete   %sil
lea    0xe2d(%rip),%rdi
call   1030 <assertTrue@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"p[0][0] == 41\00"
@.str.1 = [13 x i8] c"p[1] == NULL\00"
@.str.2 = [13 x i8] c"p[2] == NULL\00"
define void @test_double_ptr() {
%1 = alloca [3 x double*]
%2 = call double* @malloc(i32 80)
%3 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 0
store double* %2, double** %3
%4 = call double* @malloc(i32 160)
%5 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 1
store double* %4, double** %5
%6 = call double* @malloc(i32 240)
%7 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 2
store double* %6, double** %7
%8 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 0
%9 = load double*, double** %8
%10 = getelementptr inbounds double, double* %9, i64 0
store double 4.100000e+01, double* %10
%11 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 1
%12 = load double*, double** %11
%13 = getelementptr inbounds double, double* %12, i64 1
store double 4.200000e+01, double* %13
%14 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 2
%15 = load double*, double** %14
%16 = getelementptr inbounds double, double* %15, i64 2
store double 4.300000e+01, double* %16
%17 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 0
%18 = getelementptr inbounds double*, double** %17, i64 1
%19 = call i32 @zero_out(double** %18, i32 16)
%20 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 0
%21 = load double*, double** %20
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = fcmp oeq double %23, 4.100000e+01
%25 = zext i1 %24 to i32
%26 = call i32 @assertTrue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 1
%28 = load double*, double** %27
%29 = icmp eq double* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @assertTrue(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 2
%33 = load double*, double** %32
%34 = icmp eq double* %33, null
%35 = zext i1 %34 to i32
%36 = call i32 @assertTrue(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %35)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"p[0][0] == 41\00"
@.str.1 = [13 x i8] c"p[1] == NULL\00"
@.str.2 = [13 x i8] c"p[2] == NULL\00"
define void @test_double_ptr() {
%1 = alloca [3 x double*]
%2 = bitcast [3 x double*]* %1 to i8*
%3 = tail call double* @malloc(i32 80)
%4 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 0
store double* %3, double** %4
%5 = tail call double* @malloc(i32 160)
%6 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 1
store double* %5, double** %6
%7 = tail call double* @malloc(i32 240)
%8 = getelementptr inbounds [3 x double*], [3 x double*]* %1, i64 0, i64 2
store double* %7, double** %8
store double 4.100000e+01, double* %3
%9 = getelementptr inbounds double, double* %5, i64 1
store double 4.200000e+01, double* %9
%10 = getelementptr inbounds double, double* %7, i64 2
store double 4.300000e+01, double* %10
%11 = call i32 @zero_out(double** %6, i32 16)
%12 = load double*, double** %4
%13 = load double, double* %12
%14 = fcmp oeq double %13, 4.100000e+01
%15 = zext i1 %14 to i32
%16 = call i32 @assertTrue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load double*, double** %6
%18 = icmp eq double* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assertTrue(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load double*, double** %8
%22 = icmp eq double* %21, null
%23 = zext i1 %22 to i32
%24 = call i32 @assertTrue(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret void
}