#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*/ warning(char *);
int divd(double x, double y, double min, double max, int needconst) {
  int cond;
  if (x < 0)
    x = -x;
  if (y < 0)
    y = -y;
  cond = y != 0 && !(y < 1 && x > max * y);
  if (!cond && needconst) {
    warning("overflow in constant expression\n");
    cond = 1;
  }
  return cond;
}


x86 assembly (clang, -O0):
<divd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    115e <divd+0x4e>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    118d <divd+0x7d>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
jne    11af <divd+0x9f>
jp     11af <divd+0x9f>
jmp    11e8 <divd+0xd8>
xor    %eax,%eax
movsd  0xe47(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x2a(%rbp)
jbe    11e0 <divd+0xd0>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
xor    $0xff,%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    121a <divd+0x10a>
cmpl   $0x0,-0x24(%rbp)
je     121a <divd+0x10a>
lea    0xdfa(%rip),%rdi
call   1030 <warning@plt>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divd>:
push   %rax
movapd 0xee7(%rip),%xmm5
xorpd  %xmm1,%xmm5
xorpd  %xmm4,%xmm4
movapd %xmm1,%xmm2
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm5
andnpd %xmm1,%xmm2
orpd   %xmm5,%xmm2
ucomisd %xmm4,%xmm2
jne    113e <divd+0x2e>
jnp    1184 <divd+0x74>
movapd 0xeba(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd %xmm0,%xmm5
cmpltsd %xmm4,%xmm5
andpd  %xmm5,%xmm1
andnpd %xmm0,%xmm5
movsd  0xead(%rip),%xmm0
ucomisd %xmm2,%xmm0
setbe  %al
orpd   %xmm1,%xmm5
mulsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm5
setbe  %cl
or     %al,%cl
movzbl %cl,%eax
test   %edi,%edi
jne    118a <divd+0x7a>
pop    %rcx
ret
xor    %eax,%eax
test   %edi,%edi
je     1182 <divd+0x72>
test   %eax,%eax
jne    1182 <divd+0x72>
lea    0xe83(%rip),%rdi
call   1030 <warning@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"overflow in constant expression\0A\00"
define i32 @divd(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%12 = load double, double* %6
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load double, double* %6
%16 = fneg double %15
store double %16, double* %6
br label %17
17: ; preds = %14, %5
%18 = load double, double* %7
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load double, double* %7
%22 = fneg double %21
store double %22, double* %7
br label %23
23: ; preds = %20, %17
%24 = load double, double* %7
%25 = fcmp une double %24, 0.000000e+00
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load double, double* %7
%28 = fcmp olt double %27, 1.000000e+00
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load double, double* %6
%31 = load double, double* %9
%32 = load double, double* %7
%33 = fmul double %31, %32
%34 = fcmp ogt double %30, %33
br label %35
35: ; preds = %29, %26
%36 = phi i1 [ false, %26 ], [ %34, %29 ]
%37 = xor i1 %36, true
br label %38
38: ; preds = %35, %23
%39 = phi i1 [ false, %23 ], [ %37, %35 ]
%40 = zext i1 %39 to i32
store i32 %40, i32* %11
%41 = load i32, i32* %11
%42 = icmp ne i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = load i32, i32* %10
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @warning(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %11
br label %48
48: ; preds = %46, %43, %38
%49 = load i32, i32* %11
ret i32 %49
}

LLVM IR (-O2):
@.str = [33 x i8] c"overflow in constant expression\0A\00"
define i32 @divd(double %0, double %1, double %2, double %3, i32 %4) {
%6 = fcmp olt double %1, 0.000000e+00
%7 = fneg double %1
%8 = select i1 %6, double %7, double %1
%9 = fcmp une double %8, 0.000000e+00
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = fcmp olt double %0, 0.000000e+00
%12 = fneg double %0
%13 = select i1 %11, double %12, double %0
%14 = fcmp uge double %8, 1.000000e+00
%15 = fmul double %8, %3
%16 = fcmp ule double %13, %15
%17 = or i1 %14, %16
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %10, %5
%20 = phi i32 [ 0, %5 ], [ %18, %10 ]
%21 = icmp eq i32 %20, 0
%22 = icmp ne i32 %4, 0
%23 = and i1 %22, %21
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 @warning(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = phi i32 [ 1, %24 ], [ %20, %19 ]
ret i32 %27
}