int iw_is_valid_density(double density_x, double density_y, int density_code) {
  if (density_x < 0.0001 || density_y < 0.0001)
    return 0;
  if (density_x > 10000000.0 || density_y > 10000000.0)
    return 0;
  if (density_x / 10.0 > density_y)
    return 0;
  if (density_y / 10.0 > density_x)
    return 0;
  if (density_code != 1 && density_code != 2)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<iw_is_valid_density>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  0xee7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1137 <iw_is_valid_density+0x37>
movsd  0xed4(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1143 <iw_is_valid_density+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <iw_is_valid_density+0xf4>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1171 <iw_is_valid_density+0x71>
movsd  -0x18(%rbp),%xmm0
movsd  0xea1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117d <iw_is_valid_density+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <iw_is_valid_density+0xf4>
movsd  -0x10(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a5 <iw_is_valid_density+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <iw_is_valid_density+0xf4>
movsd  -0x18(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11cd <iw_is_valid_density+0xcd>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <iw_is_valid_density+0xf4>
cmpl   $0x1,-0x1c(%rbp)
je     11ed <iw_is_valid_density+0xed>
cmpl   $0x2,-0x1c(%rbp)
je     11ed <iw_is_valid_density+0xed>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <iw_is_valid_density+0xf4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_is_valid_density>:
xor    %eax,%eax
movsd  0xef6(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     115f <iw_is_valid_density+0x5f>
ucomisd %xmm1,%xmm2
ja     115f <iw_is_valid_density+0x5f>
movapd %xmm1,%xmm2
unpcklpd %xmm0,%xmm2
divpd  0xeea(%rip),%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm1,%xmm3
cmpltpd %xmm2,%xmm3
movmskpd %xmm3,%ecx
test   $0x1,%cl
jne    115f <iw_is_valid_density+0x5f>
shr    %cl
jne    115f <iw_is_valid_density+0x5f>
ucomisd 0xec0(%rip),%xmm0
ja     115f <iw_is_valid_density+0x5f>
ucomisd 0xeb6(%rip),%xmm1
ja     115f <iw_is_valid_density+0x5f>
add    $0xffffffff,%edi
xor    %eax,%eax
cmp    $0x2,%edi
setb   %al
ret

LLVM IR (-O0):
define i32 @iw_is_valid_density(double %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
%8 = load double, double* %5
%9 = fcmp olt double %8, 1.000000e-04
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load double, double* %6
%12 = fcmp olt double %11, 1.000000e-04
br i1 %12, label %13, label %14
13: ; preds = %10, %3
store i32 0, i32* %4
br label %41
14: ; preds = %10
%15 = load double, double* %5
%16 = fcmp ogt double %15, 1.000000e+07
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load double, double* %6
%19 = fcmp ogt double %18, 1.000000e+07
br i1 %19, label %20, label %21
20: ; preds = %17, %14
store i32 0, i32* %4
br label %41
21: ; preds = %17
%22 = load double, double* %5
%23 = fdiv double %22, 1.000000e+01
%24 = load double, double* %6
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %4
br label %41
27: ; preds = %21
%28 = load double, double* %6
%29 = fdiv double %28, 1.000000e+01
%30 = load double, double* %5
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %4
br label %41
33: ; preds = %27
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 2
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 0, i32* %4
br label %41
40: ; preds = %36, %33
store i32 1, i32* %4
br label %41
41: ; preds = %40, %39, %32, %26, %20, %13
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @iw_is_valid_density(double %0, double %1, i32 %2) {
%4 = fcmp olt double %0, 1.000000e-04
%5 = fcmp olt double %1, 1.000000e-04
%6 = or i1 %4, %5
br i1 %6, label %25, label %7
7: ; preds = %3
%8 = fcmp ogt double %0, 1.000000e+07
%9 = fcmp ogt double %1, 1.000000e+07
%10 = or i1 %8, %9
%11 = insertelement <2 x double> poison, double %1, i64 0
%12 = insertelement <2 x double> %11, double %0, i64 1
%13 = fdiv <2 x double> %12, <double 1.000000e+01, double 1.000000e+01>
%14 = insertelement <2 x double> poison, double %0, i64 0
%15 = insertelement <2 x double> %14, double %1, i64 1
%16 = fcmp ogt <2 x double> %13, %15
%17 = extractelement <2 x i1> %16, i64 1
%18 = or i1 %17, %10
%19 = extractelement <2 x i1> %16, i64 0
%20 = or i1 %19, %18
br i1 %20, label %25, label %21
21: ; preds = %7
%22 = add i32 %2, -1
%23 = icmp ult i32 %22, 2
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %7, %3
%26 = phi i32 [ 0, %3 ], [ 0, %7 ], [ %24, %21 ]
ret i32 %26
}