long b_entier(x)
double x;
{
  long val;
  if (x < 0) {
    val = -((((-x) > (double)2147483647L)          ? 2147483647L
             : ((-x) < (double)(-2147483647L - 1)) ? (-2147483647L - 1)
                                                   : (long)(-x)));
    if ((double)val != x)
      val -= 1;
  } else
    val = (((x) > (double)2147483647L)          ? 2147483647L
           : ((x) < (double)(-2147483647L - 1)) ? (-2147483647L - 1)
                                                : (long)(x));
  return val;
}


x86 assembly (clang, -O0):
<b_entier>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11f8 <b_entier+0xf8>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xec5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1153 <b_entier+0x53>
mov    $0x7fffffff,%eax
mov    %rax,-0x18(%rbp)
jmp    11be <b_entier+0xbe>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe91(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1191 <b_entier+0x91>
mov    $0xffffffff80000000,%rax
mov    %rax,-0x20(%rbp)
jmp    11b6 <b_entier+0xb6>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jne    11e7 <b_entier+0xe7>
jp     11e7 <b_entier+0xe7>
jmp    11f3 <b_entier+0xf3>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    125a <b_entier+0x15a>
movsd  -0x8(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121d <b_entier+0x11d>
mov    $0x7fffffff,%eax
mov    %rax,-0x28(%rbp)
jmp    1252 <b_entier+0x152>
movsd  0xde3(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1240 <b_entier+0x140>
mov    $0xffffffff80000000,%rax
mov    %rax,-0x30(%rbp)
jmp    124a <b_entier+0x14a>
cvttsd2si -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_entier>:
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1160 <b_entier+0x60>
ucomisd 0xefe(%rip),%xmm0
movapd 0xf06(%rip),%xmm1
xorpd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    $0xffffffff80000000,%rdx
cmovbe %rax,%rdx
movsd  0xee2(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    $0x7fffffff,%ecx
cmovbe %rdx,%rcx
mov    %rcx,%rax
neg    %rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
ucomisd %xmm0,%xmm1
jne    1159 <b_entier+0x59>
jnp    1182 <b_entier+0x82>
not    %rcx
mov    %rcx,%rax
ret
ucomisd 0xe98(%rip),%xmm0
movsd  0xe98(%rip),%xmm1
maxsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rcx
mov    $0x7fffffff,%eax
cmovbe %rcx,%rax
ret

LLVM IR (-O0):
define i64 @b_entier(double %0) {
%2 = alloca double
%3 = alloca i64
store double %0, double* %2
%4 = load double, double* %2
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %33
6: ; preds = %1
%7 = load double, double* %2
%8 = fneg double %7
%9 = fcmp ogt double %8, 0x41DFFFFFFFC00000
br i1 %9, label %10, label %11
10: ; preds = %6
br label %22
11: ; preds = %6
%12 = load double, double* %2
%13 = fneg double %12
%14 = fcmp olt double %13, 0xC1E0000000000000
br i1 %14, label %15, label %16
15: ; preds = %11
br label %20
16: ; preds = %11
%17 = load double, double* %2
%18 = fneg double %17
%19 = fptosi double %18 to i64
br label %20
20: ; preds = %16, %15
%21 = phi i64 [ -2147483648, %15 ], [ %19, %16 ]
br label %22
22: ; preds = %20, %10
%23 = phi i64 [ 2147483647, %10 ], [ %21, %20 ]
%24 = sub nsw i64 0, %23
store i64 %24, i64* %3
%25 = load i64, i64* %3
%26 = sitofp i64 %25 to double
%27 = load double, double* %2
%28 = fcmp une double %26, %27
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i64, i64* %3
%31 = sub nsw i64 %30, 1
store i64 %31, i64* %3
br label %32
32: ; preds = %29, %22
br label %48
33: ; preds = %1
%34 = load double, double* %2
%35 = fcmp ogt double %34, 0x41DFFFFFFFC00000
br i1 %35, label %36, label %37
36: ; preds = %33
br label %46
37: ; preds = %33
%38 = load double, double* %2
%39 = fcmp olt double %38, 0xC1E0000000000000
br i1 %39, label %40, label %41
40: ; preds = %37
br label %44
41: ; preds = %37
%42 = load double, double* %2
%43 = fptosi double %42 to i64
br label %44
44: ; preds = %41, %40
%45 = phi i64 [ -2147483648, %40 ], [ %43, %41 ]
br label %46
46: ; preds = %44, %36
%47 = phi i64 [ 2147483647, %36 ], [ %45, %44 ]
store i64 %47, i64* %3
br label %48
48: ; preds = %46, %32
%49 = load i64, i64* %3
ret i64 %49
}

LLVM IR (-O2):
define i64 @b_entier(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %15
3: ; preds = %1
%4 = fcmp olt double %0, 0xC1DFFFFFFFC00000
%5 = fneg double %0
%6 = fcmp ogt double %0, 0x41E0000000000000
%7 = fptosi double %5 to i64
%8 = select i1 %6, i64 -2147483648, i64 %7
%9 = select i1 %4, i64 2147483647, i64 %8
%10 = sub nsw i64 0, %9
%11 = sitofp i64 %10 to double
%12 = fcmp une double %11, %0
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = xor i64 %9, -1
br label %21
15: ; preds = %1
%16 = fcmp ogt double %0, 0x41DFFFFFFFC00000
%17 = fcmp ole double %0, 0xC1E0000000000000
%18 = select i1 %17, double 0xC1E0000000000000, double %0
%19 = fptosi double %18 to i64
%20 = select i1 %16, i64 2147483647, i64 %19
br label %21
21: ; preds = %3, %13, %15
%22 = phi i64 [ %14, %13 ], [ %10, %3 ], [ %20, %15 ]
ret i64 %22
}