#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);
int /*<<< orphan*/ init_double(void *);
void *my_alloc(int);
void test_double() {
  void *pv = my_alloc(sizeof(double) * 2);
  init_double(pv);
  double *pd = (double *)pv;
  assertTrue("pd[0] == 3.145", pd[0] == 3.145);
  assertTrue("pd[1] == 42.0", pd[1] == 42.0);
}


x86 assembly (clang, -O0):
<test_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x10,%edi
call   1030 <my_alloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <init_double@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xea1(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe91(%rip),%rdi
call   1040 <assertTrue@plt>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xe6b(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%esi
lea    0xe72(%rip),%rdi
call   1040 <assertTrue@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double>:
push   %rbx
mov    $0x10,%edi
call   1030 <my_alloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <init_double@plt>
movsd  0xeb2(%rip),%xmm0
cmpeqsd (%rbx),%xmm0
movq   %xmm0,%rsi
and    $0x1,%esi
lea    0xeae(%rip),%rdi
call   1040 <assertTrue@plt>
movsd  0xe99(%rip),%xmm0
cmpeqsd 0x8(%rbx),%xmm0
movq   %xmm0,%rsi
and    $0x1,%esi
lea    0xe9b(%rip),%rdi
pop    %rbx
jmp    1040 <assertTrue@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"pd[0] == 3.145\00"
@.str.1 = [14 x i8] c"pd[1] == 42.0\00"
define void @test_double() {
%1 = alloca i8*
%2 = alloca double*
%3 = call i8* @my_alloc(i32 16)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = call i32 @init_double(i8* %4)
%6 = load i8*, i8** %1
%7 = bitcast i8* %6 to double*
store double* %7, double** %2
%8 = load double*, double** %2
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = fcmp oeq double %10, 3.145000e+00
%12 = zext i1 %11 to i32
%13 = call i32 @assertTrue(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load double*, double** %2
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = fcmp oeq double %16, 4.200000e+01
%18 = zext i1 %17 to i32
%19 = call i32 @assertTrue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"pd[0] == 3.145\00"
@.str.1 = [14 x i8] c"pd[1] == 42.0\00"
define void @test_double() {
%1 = tail call i8* @my_alloc(i32 16)
%2 = tail call i32 @init_double(i8* %1)
%3 = bitcast i8* %1 to double*
%4 = load double, double* %3
%5 = fcmp oeq double %4, 3.145000e+00
%6 = zext i1 %5 to i32
%7 = tail call i32 @assertTrue(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds i8, i8* %1, i64 8
%9 = bitcast i8* %8 to double*
%10 = load double, double* %9
%11 = fcmp oeq double %10, 4.200000e+01
%12 = zext i1 %11 to i32
%13 = tail call i32 @assertTrue(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret void
}