#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 */
float __truncdfsf2(double);
int /*<<< orphan*/ printf(char *, double, float, float);
int test__truncdfsf2(double a) {
  float actual = __truncdfsf2(a);
  float expected = a;
  if (actual != expected) {
    printf("error in test__truncdfsf2(%lf) = %f, "
           "expected %f\n",
           a, actual, expected);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test__truncdfsf2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1190 <__truncdfsf2>
movss  %xmm0,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    1154 <test__truncdfsf2+0x44>
jp     1154 <test__truncdfsf2+0x44>
jmp    117b <test__truncdfsf2+0x6b>
movsd  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1182 <test__truncdfsf2+0x72>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
nopl   0x0(%rax,%rax,1)

x86 assembly (clang, -O2):
<test__truncdfsf2>:
push   %rax
movsd  %xmm0,(%rsp)
call   1150 <__truncdfsf2>
movaps %xmm0,%xmm1
movsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm2
ucomiss %xmm2,%xmm1
jne    112e <test__truncdfsf2+0x1e>
jnp    1141 <test__truncdfsf2+0x31>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
cs nopw 0x0(%rax,%rax,1)
nop

LLVM IR (-O0):
@.str = [50 x i8] c"error in test__truncdfsf2(%lf) = %f, expected %f\0A\00"
define i32 @test__truncdfsf2(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca float
%5 = alloca float
store double %0, double* %3
%6 = load double, double* %3
%7 = call float @__truncdfsf2(double %6)
store float %7, float* %4
%8 = load double, double* %3
%9 = fptrunc double %8 to float
store float %9, float* %5
%10 = load float, float* %4
%11 = load float, float* %5
%12 = fcmp une float %10, %11
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load double, double* %3
%15 = load float, float* %4
%16 = load float, float* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %14, float %15, float %16)
store i32 1, i32* %2
br label %19
18: ; preds = %1
store i32 0, i32* %2
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [50 x i8] c"error in test__truncdfsf2(%lf) = %f, expected %f\0A\00"
define i32 @test__truncdfsf2(double %0) {
%2 = tail call float @__truncdfsf2(double %0)
%3 = fptrunc double %0 to float
%4 = fcmp une float %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %0, float %2, float %3)
br label %7
7: ; preds = %1, %5
%8 = phi i32 [ 1, %5 ], [ 0, %1 ]
ret i32 %8
}