#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*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double, double);
void test8() {
  int px = (int)malloc(120);
  *(double *)px = 8.8;
  *(double *)(px + 8) = 9.9;
  printf("Testing read/write (double*): %g %g\n", *(double *)px,
         *(double *)(px + 8));
  free((void *)px);
}


x86 assembly (clang, -O0):
<test8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x78,%edi
call   1050 <malloc@plt>
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movsd  0xeb7(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,(%rax)
movslq -0x4(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
movsd  (%rax),%xmm1
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
movslq -0x4(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test8>:
push   %rbx
mov    $0x78,%edi
call   1050 <malloc@plt>
movslq %eax,%rbx
movabs $0x402199999999999a,%rax
99 21 40
mov    %rax,(%rbx)
lea    0x8(%rbx),%eax
cltq
movabs $0x4023cccccccccccd,%rcx
cc 23 40
mov    %rcx,(%rax)
movsd  (%rbx),%xmm0
lea    0xea0(%rip),%rdi
movsd  0xe90(%rip),%xmm1
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Testing read/write (double*): %g %g\0A\00"
define void @test8() {
%1 = alloca i32
%2 = call i64 @malloc(i32 120)
%3 = trunc i64 %2 to i32
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to double*
store double 8.800000e+00, double* %6
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 8
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to double*
store double 9.900000e+00, double* %10
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to double*
%14 = load double, double* %13
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 8
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to double*
%19 = load double, double* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double %14, double %19)
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
%24 = call i32 @free(i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"Testing read/write (double*): %g %g\0A\00"
define void @test8() {
%1 = tail call i64 @malloc(i32 120)
%2 = shl i64 %1, 32
%3 = ashr exact i64 %2, 32
%4 = inttoptr i64 %3 to double*
store double 8.800000e+00, double* %4
%5 = add i64 %2, 34359738368
%6 = ashr exact i64 %5, 32
%7 = inttoptr i64 %6 to double*
store double 9.900000e+00, double* %7
%8 = load double, double* %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double %8, double 9.900000e+00)
%10 = inttoptr i64 %3 to i8*
%11 = tail call i32 @free(i8* %10)
ret void
}