#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*/ printf(char *);
int fixDilation(double dilation) {
  int dil;
  if (dilation < 0) {
    printf("Negative dilation does not make sense\n");
    return -1;
  }
  if (dilation < 1.0 && dilation > 0.0) {
    dil = (int)((1 / dilation) * 1000.0);
    dil = dil * -1;
  } else if (dilation == 1.0 || dilation == -1.0) {
    dil = 0;
  } else {
    dil = (int)(dilation * 1000.0);
  }
  return dil;
}


x86 assembly (clang, -O0):
<fixDilation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1143 <fixDilation+0x33>
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fe <fixDilation+0xee>
movsd  0xeb5(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1194 <fixDilation+0x84>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1194 <fixDilation+0x84>
movsd  0xe90(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  0xe93(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11f8 <fixDilation+0xe8>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b6 <fixDilation+0xa6>
jp     11b6 <fixDilation+0xa6>
jmp    11d3 <fixDilation+0xc3>
movsd  -0x10(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11df <fixDilation+0xcf>
jp     11df <fixDilation+0xcf>
movl   $0x0,-0x14(%rbp)
jmp    11f3 <fixDilation+0xe3>
movsd  0xe29(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
jmp    11f8 <fixDilation+0xe8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixDilation>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    112e <fixDilation+0x1e>
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
movsd  0xeca(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115a <fixDilation+0x4a>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jbe    115a <fixDilation+0x4a>
divsd  %xmm0,%xmm1
mulsd  0xebe(%rip),%xmm1
cvttsd2si %xmm1,%eax
neg    %eax
pop    %rcx
ret
xor    %eax,%eax
ucomisd 0xe9c(%rip),%xmm0
jne    1168 <fixDilation+0x58>
jnp    1180 <fixDilation+0x70>
ucomisd 0xe98(%rip),%xmm0
jne    1174 <fixDilation+0x64>
jnp    1180 <fixDilation+0x70>
mulsd  0xe94(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Negative dilation does not make sense\0A\00"
define i32 @fixDilation(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %36
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp olt double %10, 1.000000e+00
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load double, double* %3
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load double, double* %3
%17 = fdiv double 1.000000e+00, %16
%18 = fmul double %17, 1.000000e+03
%19 = fptosi double %18 to i32
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, -1
store i32 %21, i32* %4
br label %34
22: ; preds = %12, %9
%23 = load double, double* %3
%24 = fcmp oeq double %23, 1.000000e+00
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load double, double* %3
%27 = fcmp oeq double %26, -1.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %25, %22
store i32 0, i32* %4
br label %33
29: ; preds = %25
%30 = load double, double* %3
%31 = fmul double %30, 1.000000e+03
%32 = fptosi double %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %29, %28
br label %34
34: ; preds = %33, %15
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %36
36: ; preds = %34, %7
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
@str = [38 x i8] c"Negative dilation does not make sense\00"
define i32 @fixDilation(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %21
5: ; preds = %1
%6 = fcmp olt double %0, 1.000000e+00
%7 = fcmp ogt double %0, 0.000000e+00
%8 = and i1 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = fdiv double 1.000000e+00, %0
%11 = fmul double %10, 1.000000e+03
%12 = fptosi double %11 to i32
%13 = sub nsw i32 0, %12
br label %21
14: ; preds = %5
%15 = fcmp oeq double %0, 1.000000e+00
%16 = fcmp oeq double %0, -1.000000e+00
%17 = or i1 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = fmul double %0, 1.000000e+03
%20 = fptosi double %19 to i32
br label %21
21: ; preds = %9, %18, %14, %3
%22 = phi i32 [ -1, %3 ], [ %13, %9 ], [ %20, %18 ], [ 0, %14 ]
ret i32 %22
}