#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*/ linear_search(double, unsigned int *);
void search_PWM(double R1_thrust, double R2_thrust, double R3_thrust,
                double R4_thrust, unsigned int *pwm1, unsigned int *pwm2,
                unsigned int *pwm3, unsigned int *pwm4) {
  if (R1_thrust != 0) {
    linear_search(R1_thrust, pwm1);
  } else {
    *pwm1 = 0;
  }
  if (R2_thrust != 0) {
    linear_search(R2_thrust, pwm2);
  } else {
    *pwm2 = 0;
  }
  if (R3_thrust != 0) {
    linear_search(R3_thrust, pwm3);
  } else {
    *pwm3 = 0;
  }
  if (R4_thrust != 0) {
    linear_search(R4_thrust, pwm4);
  } else {
    *pwm4 = 0;
  }
}


x86 assembly (clang, -O0):
<search_PWM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <search_PWM+0x49>
jp     1159 <search_PWM+0x49>
jmp    116c <search_PWM+0x5c>
movsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%rdi
call   1030 <linear_search@plt>
jmp    1176 <search_PWM+0x66>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1193 <search_PWM+0x83>
jp     1193 <search_PWM+0x83>
jmp    11a6 <search_PWM+0x96>
movsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rdi
call   1030 <linear_search@plt>
jmp    11b0 <search_PWM+0xa0>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11cd <search_PWM+0xbd>
jp     11cd <search_PWM+0xbd>
jmp    11e0 <search_PWM+0xd0>
movsd  -0x18(%rbp),%xmm0
mov    -0x38(%rbp),%rdi
call   1030 <linear_search@plt>
jmp    11ea <search_PWM+0xda>
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1207 <search_PWM+0xf7>
jp     1207 <search_PWM+0xf7>
jmp    121a <search_PWM+0x10a>
movsd  -0x20(%rbp),%xmm0
mov    -0x40(%rbp),%rdi
call   1030 <linear_search@plt>
jmp    1224 <search_PWM+0x114>
mov    -0x40(%rbp),%rax
movl   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_PWM>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    113a <search_PWM+0x2a>
jnp    114d <search_PWM+0x3d>
movsd  %xmm1,0x8(%rsp)
call   1030 <linear_search@plt>
movsd  0x8(%rsp),%xmm1
jmp    1153 <search_PWM+0x43>
movl   $0x0,(%rdi)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    115f <search_PWM+0x4f>
jnp    116d <search_PWM+0x5d>
movapd %xmm1,%xmm0
mov    %rbx,%rdi
call   1030 <linear_search@plt>
jmp    1173 <search_PWM+0x63>
movl   $0x0,(%rbx)
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jne    1185 <search_PWM+0x75>
jnp    118f <search_PWM+0x7f>
mov    %r15,%rdi
call   1030 <linear_search@plt>
jmp    1196 <search_PWM+0x86>
movl   $0x0,(%r15)
xorpd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jne    11a8 <search_PWM+0x98>
jnp    11b9 <search_PWM+0xa9>
mov    %r14,%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <linear_search@plt>
movl   $0x0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @search_PWM(double %0, double %1, double %2, double %3, i32* %4, i32* %5, i32* %6, i32* %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
store i32* %7, i32** %16
%17 = load double, double* %9
%18 = fcmp une double %17, 0.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %8
%20 = load double, double* %9
%21 = load i32*, i32** %13
%22 = call i32 @linear_search(double %20, i32* %21)
br label %25
23: ; preds = %8
%24 = load i32*, i32** %13
store i32 0, i32* %24
br label %25
25: ; preds = %23, %19
%26 = load double, double* %10
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load double, double* %10
%30 = load i32*, i32** %14
%31 = call i32 @linear_search(double %29, i32* %30)
br label %34
32: ; preds = %25
%33 = load i32*, i32** %14
store i32 0, i32* %33
br label %34
34: ; preds = %32, %28
%35 = load double, double* %11
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load double, double* %11
%39 = load i32*, i32** %15
%40 = call i32 @linear_search(double %38, i32* %39)
br label %43
41: ; preds = %34
%42 = load i32*, i32** %15
store i32 0, i32* %42
br label %43
43: ; preds = %41, %37
%44 = load double, double* %12
%45 = fcmp une double %44, 0.000000e+00
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load double, double* %12
%48 = load i32*, i32** %16
%49 = call i32 @linear_search(double %47, i32* %48)
br label %52
50: ; preds = %43
%51 = load i32*, i32** %16
store i32 0, i32* %51
br label %52
52: ; preds = %50, %46
ret void
}

LLVM IR (-O2):
define void @search_PWM(double %0, double %1, double %2, double %3, i32* %4, i32* %5, i32* %6, i32* %7) {
%9 = fcmp une double %0, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @linear_search(double %0, i32* %4)
br label %13
12: ; preds = %8
store i32 0, i32* %4
br label %13
13: ; preds = %12, %10
%14 = fcmp une double %1, 0.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @linear_search(double %1, i32* %5)
br label %18
17: ; preds = %13
store i32 0, i32* %5
br label %18
18: ; preds = %17, %15
%19 = fcmp une double %2, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = tail call i32 @linear_search(double %2, i32* %6)
br label %23
22: ; preds = %18
store i32 0, i32* %6
br label %23
23: ; preds = %22, %20
%24 = fcmp une double %3, 0.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 @linear_search(double %3, i32* %7)
br label %28
27: ; preds = %23
store i32 0, i32* %7
br label %28
28: ; preds = %27, %25
ret void
}