#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_int_part(double *, int);
void test_get_int_part() {
  double array[] = {1.2, 2.718, 3.1412, 5.6};
  double expected[] = {1, 2, 3, 5};
  int length = sizeof(array) / sizeof(double);
  double *int_part = get_int_part(array, length);
  for (int i = 0; i < length; i++) {
    assert(int_part[i] == expected[i]);
  }
}


x86 assembly (clang, -O0):
<test_get_int_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec2(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xebf(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x44(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1040 <get_int_part@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11e1 <test_get_int_part+0xc1>
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x54(%rbp),%rax
ucomisd -0x40(%rbp,%rax,8),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    119e <test_get_int_part+0x7e>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_int_part>:
push   %rbx
sub    $0x20,%rsp
movaps 0xf04(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
call   1040 <get_int_part@plt>
mov    %rax,%rbx
movsd  0xeac(%rip),%xmm0
cmpeqsd (%rax),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1030 <assert@plt>
movsd  0xe9a(%rip),%xmm0
cmpeqsd 0x8(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1030 <assert@plt>
movsd  0xe87(%rip),%xmm0
cmpeqsd 0x10(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1030 <assert@plt>
movsd  0xe74(%rip),%xmm0
cmpeqsd 0x18(%rbx),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_get_int_part.array = [4 x double] [double 1.200000e+00, double 2.718000e+00, double 3.141200e+00, double 5.600000e+00]
@__const.test_get_int_part.expected = [4 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 5.000000e+00]
define void @test_get_int_part() {
%1 = alloca [4 x double]
%2 = alloca [4 x double]
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = bitcast [4 x double]* %1 to i8*
%7 = bitcast [4 x double]* %2 to i8*
store i32 4, i32* %3
%8 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%9 = load i32, i32* %3
%10 = call double* @get_int_part(double* %8, i32 %9)
store double* %10, double** %4
store i32 0, i32* %5
br label %11
11: ; preds = %28, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load double*, double** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 %22
%24 = load double, double* %23
%25 = fcmp oeq double %20, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
br label %28
28: ; preds = %15
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %11
31: ; preds = %11
ret void
}

LLVM IR (-O2):
@__const.test_get_int_part.array = [4 x double] [double 1.200000e+00, double 2.718000e+00, double 3.141200e+00, double 5.600000e+00]
define void @test_get_int_part() {
%1 = alloca [4 x double]
%2 = bitcast [4 x double]* %1 to i8*
%3 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%4 = call double* @get_int_part(double* %3, i32 4)
%5 = load double, double* %4
%6 = fcmp oeq double %5, 1.000000e+00
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds double, double* %4, i64 1
%10 = load double, double* %9
%11 = fcmp oeq double %10, 2.000000e+00
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds double, double* %4, i64 2
%15 = load double, double* %14
%16 = fcmp oeq double %15, 3.000000e+00
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds double, double* %4, i64 3
%20 = load double, double* %19
%21 = fcmp oeq double %20, 5.000000e+00
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret void
}