#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 */
typedef int uint32_t;

/* Variables and functions */
void pwm_set_duty(uint32_t *pwm, float duty) {
  if (duty == 1.0f || duty == -1.0f) {
    pwm[0x018 / 4] = pwm[0x010 / 4] - 1;
  } else {
    pwm[0x018 / 4] = pwm[0x010 / 4] * duty - 1;
  }
}


x86 assembly (clang, -O0):
<pwm_set_duty>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xee6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    112e <pwm_set_duty+0x2e>
jp     112e <pwm_set_duty+0x2e>
jmp    114a <pwm_set_duty+0x4a>
movss  -0xc(%rbp),%xmm0
movss  0xec9(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1160 <pwm_set_duty+0x60>
jp     1160 <pwm_set_duty+0x60>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
jmp    1189 <pwm_set_duty+0x89>
mov    -0x8(%rbp),%rax
cvtsi2ssl 0x10(%rax),%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe8a(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwm_set_duty>:
ucomiss 0xef9(%rip),%xmm0
mov    0x10(%rdi),%eax
jne    110e <pwm_set_duty+0xe>
jnp    1131 <pwm_set_duty+0x31>
ucomiss 0xeef(%rip),%xmm0
jne    1119 <pwm_set_duty+0x19>
jnp    1131 <pwm_set_duty+0x31>
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
addss  0xedb(%rip),%xmm1
cvttss2si %xmm1,%eax
mov    %eax,0x18(%rdi)
ret
add    $0xffffffff,%eax
mov    %eax,0x18(%rdi)
ret

LLVM IR (-O0):
define void @pwm_set_duty(i32* %0, float %1) {
%3 = alloca i32*
%4 = alloca float
store i32* %0, i32** %3
store float %1, float* %4
%5 = load float, float* %4
%6 = fcmp oeq float %5, 1.000000e+00
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load float, float* %4
%9 = fcmp oeq float %8, -1.000000e+00
br i1 %9, label %10, label %17
10: ; preds = %7, %2
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 4
%13 = load i32, i32* %12
%14 = sub nsw i32 %13, 1
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 6
store i32 %14, i32* %16
br label %27
17: ; preds = %7
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 4
%20 = load i32, i32* %19
%21 = sitofp i32 %20 to float
%22 = load float, float* %4
%23 = call float @llvm.fmuladd.f32(float %21, float %22, float -1.000000e+00)
%24 = fptosi float %23 to i32
%25 = load i32*, i32** %3
%26 = getelementptr inbounds i32, i32* %25, i64 6
store i32 %24, i32* %26
br label %27
27: ; preds = %17, %10
ret void
}

LLVM IR (-O2):
define void @pwm_set_duty(i32* nocapture %0, float %1) {
%3 = fcmp oeq float %1, 1.000000e+00
%4 = fcmp oeq float %1, -1.000000e+00
%5 = or i1 %3, %4
%6 = getelementptr inbounds i32, i32* %0, i64 4
%7 = load i32, i32* %6
br i1 %5, label %8, label %10
8: ; preds = %2
%9 = add nsw i32 %7, -1
br label %14
10: ; preds = %2
%11 = sitofp i32 %7 to float
%12 = tail call float @llvm.fmuladd.f32(float %11, float %1, float -1.000000e+00)
%13 = fptosi float %12 to i32
br label %14
14: ; preds = %10, %8
%15 = phi i32 [ %9, %8 ], [ %13, %10 ]
%16 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %15, i32* %16
ret void
}