int set_duty(void *motor, double dutyper) {
  int temp = 0;
  if (dutyper > 100.0)
    dutyper = 100.0;
  if (dutyper <= 0.0)
    dutyper = 0.0;
  temp = ((int)(dutyper));
  if (!set_reg((unsigned int)motor,
               (int)(((temp) * (0x61A8 - 0x30D4) / 100) + 0x30D4), 16, 0))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<set_duty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    114c <set_duty+0x3c>
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1162 <set_duty+0x52>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
imul   $0x30d4,-0x1c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x30d4,%esi
mov    $0x10,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1030 <set_reg@plt>
cmp    $0x0,%eax
jne    11aa <set_duty+0x9a>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <set_duty+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_duty>:
push   %rax
movsd  0xee7(%rip),%xmm1
minsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movapd %xmm1,%xmm2
cmplesd %xmm0,%xmm2
andnpd %xmm1,%xmm2
cvttsd2si %xmm2,%eax
imul   $0x7d,%eax,%esi
add    $0x30d4,%esi
mov    $0x10,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <set_reg@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @set_duty(i8* %0, double %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double
%6 = alloca i32
store i8* %0, i8** %4
store double %1, double* %5
store i32 0, i32* %6
%7 = load double, double* %5
%8 = fcmp ogt double %7, 1.000000e+02
br i1 %8, label %9, label %10
9: ; preds = %2
store double 1.000000e+02, double* %5
br label %10
10: ; preds = %9, %2
%11 = load double, double* %5
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %10
store double 0.000000e+00, double* %5
br label %14
14: ; preds = %13, %10
%15 = load double, double* %5
%16 = fptosi double %15 to i32
store i32 %16, i32* %6
%17 = load i8*, i8** %4
%18 = ptrtoint i8* %17 to i32
%19 = load i32, i32* %6
%20 = mul nsw i32 %19, 12500
%21 = sdiv i32 %20, 100
%22 = add nsw i32 %21, 12500
%23 = call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @set_reg to i32 (i32, i32, i32, i32, ...)*)(i32 %18, i32 %22, i32 16, i32 0)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %14
store i32 0, i32* %3
br label %27
26: ; preds = %14
store i32 1, i32* %3
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @set_duty(i8* %0, double %1) {
%3 = fcmp ogt double %1, 1.000000e+02
%4 = select i1 %3, double 1.000000e+02, double %1
%5 = fcmp ole double %4, 0.000000e+00
%6 = select i1 %5, double 0.000000e+00, double %4
%7 = fptosi double %6 to i32
%8 = ptrtoint i8* %0 to i64
%9 = trunc i64 %8 to i32
%10 = mul nsw i32 %7, 125
%11 = add nsw i32 %10, 12500
%12 = tail call i32 (i32, i32, i32, i32, ...) bitcast (i32 (...)* @set_reg to i32 (i32, i32, i32, i32, ...)*)(i32 %9, i32 %11, i32 16, i32 0)
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i32
ret i32 %14
}