#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
double *get_both_parts(double *, int, double **);
int /*<<< orphan*/ printf(char *, double, double);
void test_get_both_parts() {
  double array[] = {1.2, 2.718, 3.14159, 5.6};
  double expected_int[] = {1, 2, 3, 5};
  double expected_frac[] = {0.2, 0.718, 0.14159, 0.6};
  double *frac_part;
  int length = sizeof(array) / sizeof(double);
  double *int_part = get_both_parts(array, length, &frac_part);
  for (int i = 0; i < length; i++) {
    printf("%.18lf  %.18lf\n", int_part[i], expected_int[i]);
    printf("%.18lf  %.18lf\n", frac_part[i], expected_frac[i]);
    assert(int_part[i] == expected_int[i]);
    assert(frac_part[i] == expected_frac[i]);
  }
}


x86 assembly (clang, -O0):
<test_get_both_parts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0xebe(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x48(%rbp)
movl   $0x4,-0x6c(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x6c(%rbp),%esi
lea    -0x68(%rbp),%rdx
call   1050 <get_both_parts@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    1293 <test_get_both_parts+0x163>
mov    -0x78(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x7c(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm1
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
mov    -0x68(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x7c(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm1
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
mov    -0x78(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x7c(%rbp),%rax
ucomisd -0x40(%rbp,%rax,8),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x68(%rbp),%rax
movslq -0x7c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x7c(%rbp),%rax
ucomisd -0x60(%rbp,%rax,8),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11e1 <test_get_both_parts+0xb1>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_both_parts>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    $0x4,%esi
call   1050 <get_both_parts@plt>
mov    %rax,%rbx
movsd  (%rax),%xmm0
lea    0xeef(%rip),%r14
movsd  0xe87(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
movsd  (%rax),%xmm0
movsd  0xe76(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0xe5e(%rip),%xmm0
cmpeqsd (%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rax
movsd  0xe47(%rip),%xmm0
cmpeqsd (%rax),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
movsd  0x8(%rbx),%xmm0
movsd  0xe30(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xe1e(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0xe06(%rip),%xmm0
cmpeqsd 0x8(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rax
movsd  0xdee(%rip),%xmm0
cmpeqsd 0x8(%rax),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
movsd  0x10(%rbx),%xmm0
movsd  0xdd6(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
movsd  0x10(%rax),%xmm0
movsd  0xdc4(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0xdac(%rip),%xmm0
cmpeqsd 0x10(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rax
movsd  0xd94(%rip),%xmm0
cmpeqsd 0x10(%rax),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
movsd  0x18(%rbx),%xmm0
movsd  0xd7c(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
movsd  0x18(%rax),%xmm0
movsd  0xd6a(%rip),%xmm1
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0xd52(%rip),%xmm0
cmpeqsd 0x18(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
mov    0x8(%rsp),%rax
movsd  0xd3a(%rip),%xmm0
cmpeqsd 0x18(%rax),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1040 <assert@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_get_both_parts.array = [4 x double] [double 1.200000e+00, double 2.718000e+00, double 3.141590e+00, double 5.600000e+00]
@__const.test_get_both_parts.expected_int = [4 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 5.000000e+00]
@__const.test_get_both_parts.expected_frac = [4 x double] [double 2.000000e-01, double 7.180000e-01, double 1.415900e-01, double 6.000000e-01]
@.str = [16 x i8] c"%.18lf %.18lf\0A\00"
define void @test_get_both_parts() {
%1 = alloca [4 x double]
%2 = alloca [4 x double]
%3 = alloca [4 x double]
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = bitcast [4 x double]* %1 to i8*
%9 = bitcast [4 x double]* %2 to i8*
%10 = bitcast [4 x double]* %3 to i8*
store i32 4, i32* %5
%11 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%12 = load i32, i32* %5
%13 = call double* @get_both_parts(double* %11, i32 %12, double** %4)
store double* %13, double** %6
store i32 0, i32* %7
br label %14
14: ; preds = %63, %0
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %66
18: ; preds = %14
%19 = load double*, double** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 %25
%27 = load double, double* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %23, double %27)
%29 = load double*, double** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %35
%37 = load double, double* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %33, double %37)
%39 = load double*, double** %6
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 %45
%47 = load double, double* %46
%48 = fcmp oeq double %43, %47
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load double*, double** %4
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %57
%59 = load double, double* %58
%60 = fcmp oeq double %55, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
br label %63
63: ; preds = %18
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %14
66: ; preds = %14
ret void
}

LLVM IR (-O2):
@__const.test_get_both_parts.array = [4 x double] [double 1.200000e+00, double 2.718000e+00, double 3.141590e+00, double 5.600000e+00]
@.str = [16 x i8] c"%.18lf %.18lf\0A\00"
define void @test_get_both_parts() {
%1 = alloca [4 x double]
%2 = alloca double*
%3 = bitcast [4 x double]* %1 to i8*
%4 = bitcast double** %2 to i8*
%5 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%6 = call double* @get_both_parts(double* %5, i32 4, double** %2)
%7 = load double, double* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %7, double 1.000000e+00)
%9 = load double*, double** %2
%10 = load double, double* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %10, double 2.000000e-01)
%12 = load double, double* %6
%13 = fcmp oeq double %12, 1.000000e+00
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load double*, double** %2
%17 = load double, double* %16
%18 = fcmp oeq double %17, 2.000000e-01
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds double, double* %6, i64 1
%22 = load double, double* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %22, double 2.000000e+00)
%24 = load double*, double** %2
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %26, double 7.180000e-01)
%28 = load double, double* %21
%29 = fcmp oeq double %28, 2.000000e+00
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load double*, double** %2
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = fcmp oeq double %34, 7.180000e-01
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = getelementptr inbounds double, double* %6, i64 2
%39 = load double, double* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %39, double 3.000000e+00)
%41 = load double*, double** %2
%42 = getelementptr inbounds double, double* %41, i64 2
%43 = load double, double* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %43, double 1.415900e-01)
%45 = load double, double* %38
%46 = fcmp oeq double %45, 3.000000e+00
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load double*, double** %2
%50 = getelementptr inbounds double, double* %49, i64 2
%51 = load double, double* %50
%52 = fcmp oeq double %51, 1.415900e-01
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = getelementptr inbounds double, double* %6, i64 3
%56 = load double, double* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %56, double 5.000000e+00)
%58 = load double*, double** %2
%59 = getelementptr inbounds double, double* %58, i64 3
%60 = load double, double* %59
%61 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %60, double 6.000000e-01)
%62 = load double, double* %55
%63 = fcmp oeq double %62, 5.000000e+00
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load double*, double** %2
%67 = getelementptr inbounds double, double* %66, i64 3
%68 = load double, double* %67
%69 = fcmp oeq double %68, 6.000000e-01
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
ret void
}