#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 rc_send_servo_pulse_us(int, float);
int rc_send_oneshot_pulse_normalized(int ch, float input) {
  if (ch < 1 || ch > 8) {
    printf("ERROR: Servo Channel must be between 1&%d\n", 8);
    return -1;
  }
  if (input < -0.1 || input > 1.0) {
    printf("ERROR: normalized input must be between 0 & 1\n");
    return -1;
  }
  float micros = 125.0 + (input * 125.0);
  return rc_send_servo_pulse_us(ch, micros);
}


x86 assembly (clang, -O0):
<rc_send_oneshot_pulse_normalized>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1144 <rc_send_oneshot_pulse_normalized+0x24>
cmpl   $0x8,-0x8(%rbp)
jle    1163 <rc_send_oneshot_pulse_normalized+0x43>
lea    0xecd(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <rc_send_oneshot_pulse_normalized+0xc5>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1199 <rc_send_oneshot_pulse_normalized+0x79>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b3 <rc_send_oneshot_pulse_normalized+0x93>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <rc_send_oneshot_pulse_normalized+0xc5>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4c(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
movss  -0x10(%rbp),%xmm0
call   1040 <rc_send_servo_pulse_us@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_send_oneshot_pulse_normalized>:
push   %rax
lea    -0x9(%rdi),%eax
cmp    $0xfffffff7,%eax
ja     114e <rc_send_oneshot_pulse_normalized+0x1e>
lea    0xed8(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118f <rc_send_oneshot_pulse_normalized+0x5f>
ucomiss 0xeab(%rip),%xmm0
ja     1183 <rc_send_oneshot_pulse_normalized+0x53>
cvtss2sd %xmm0,%xmm0
movsd  0xea5(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1183 <rc_send_oneshot_pulse_normalized+0x53>
movsd  0xe9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
jmp    1050 <rc_send_servo_pulse_us@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"ERROR: Servo Channel must be between 1&%d\0A\00"
@.str.1 = [47 x i8] c"ERROR: normalized input must be between 0 & 1\0A\00"
define i32 @rc_send_oneshot_pulse_normalized(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 %0, i32* %4
store float %1, float* %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 8
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 8)
store i32 -1, i32* %3
br label %32
14: ; preds = %9
%15 = load float, float* %5
%16 = fpext float %15 to double
%17 = fcmp olt double %16, -1.000000e-01
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load float, float* %5
%20 = fpext float %19 to double
%21 = fcmp ogt double %20, 1.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %18, %14
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
24: ; preds = %18
%25 = load float, float* %5
%26 = fpext float %25 to double
%27 = call double @llvm.fmuladd.f64(double %26, double 1.250000e+02, double 1.250000e+02)
%28 = fptrunc double %27 to float
store float %28, float* %6
%29 = load i32, i32* %4
%30 = load float, float* %6
%31 = call i32 @rc_send_servo_pulse_us(i32 %29, float %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %22, %12
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [43 x i8] c"ERROR: Servo Channel must be between 1&%d\0A\00"
@str = [46 x i8] c"ERROR: normalized input must be between 0 & 1\00"
define i32 @rc_send_oneshot_pulse_normalized(i32 %0, float %1) {
%3 = add i32 %0, -9
%4 = icmp ult i32 %3, -8
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 8)
br label %18
7: ; preds = %2
%8 = fpext float %1 to double
%9 = fcmp olt double %8, -1.000000e-01
%10 = fcmp ogt float %1, 1.000000e+00
%11 = or i1 %10, %9
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %18
14: ; preds = %7
%15 = tail call double @llvm.fmuladd.f64(double %8, double 1.250000e+02, double 1.250000e+02)
%16 = fptrunc double %15 to float
%17 = tail call i32 @rc_send_servo_pulse_us(i32 %0, float %16)
br label %18
18: ; preds = %14, %12, %5
%19 = phi i32 [ -1, %5 ], [ -1, %12 ], [ %17, %14 ]
ret i32 %19
}