#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 */
long GetIntegratedMotorEncoder(int);
int /*<<< orphan*/ SetMotor(int, int);
int getJSAnalog(int, int);
void JSToMotorIME(int joystick, int channel, int motor, int inverse, long min,
                  long max) {
  long enc = GetIntegratedMotorEncoder(motor);
  SetMotor(motor, enc > min && enc < max ? (getJSAnalog(joystick, channel) *
                                            (inverse == 1 ? -1 : 1))
                                         : 0);
}


x86 assembly (clang, -O0):
<JSToMotorIME>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <GetIntegratedMotorEncoder@plt>
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    11a3 <JSToMotorIME+0x73>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11a3 <JSToMotorIME+0x73>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <getJSAnalog@plt>
mov    -0x10(%rbp),%esi
mov    $0x1,%ecx
mov    $0xffffffff,%edx
cmp    $0x1,%esi
cmove  %edx,%ecx
imul   %ecx,%eax
mov    %eax,-0x30(%rbp)
jmp    11ad <JSToMotorIME+0x7d>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    11ad <JSToMotorIME+0x7d>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1030 <SetMotor@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JSToMotorIME>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8,%rbp
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %esi,%r15d
mov    %edi,%r12d
mov    %edx,%edi
call   1040 <GetIntegratedMotorEncoder@plt>
xor    %esi,%esi
cmp    %rbp,%rax
jle    1175 <JSToMotorIME+0x45>
cmp    %r13,%rax
jge    1175 <JSToMotorIME+0x45>
mov    %r12d,%edi
mov    %r15d,%esi
call   1050 <getJSAnalog@plt>
mov    %eax,%esi
neg    %esi
cmp    $0x1,%r14d
cmovne %eax,%esi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <SetMotor@plt>

LLVM IR (-O0):
define void @JSToMotorIME(i32 %0, i32 %1, i32 %2, i32 %3, i64 %4, i64 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i64 %4, i64* %11
store i64 %5, i64* %12
%14 = load i32, i32* %9
%15 = call i64 @GetIntegratedMotorEncoder(i32 %14)
store i64 %15, i64* %13
%16 = load i32, i32* %9
%17 = load i64, i64* %13
%18 = load i64, i64* %11
%19 = icmp sgt i64 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %6
%21 = load i64, i64* %13
%22 = load i64, i64* %12
%23 = icmp slt i64 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = call i32 @getJSAnalog(i32 %25, i32 %26)
%28 = load i32, i32* %10
%29 = icmp eq i32 %28, 1
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 -1, i32 1
%32 = mul nsw i32 %27, %31
br label %34
33: ; preds = %20, %6
br label %34
34: ; preds = %33, %24
%35 = phi i32 [ %32, %24 ], [ 0, %33 ]
%36 = call i32 @SetMotor(i32 %16, i32 %35)
ret void
}

LLVM IR (-O2):
define void @JSToMotorIME(i32 %0, i32 %1, i32 %2, i32 %3, i64 %4, i64 %5) {
%7 = tail call i64 @GetIntegratedMotorEncoder(i32 %2)
%8 = icmp sgt i64 %7, %4
%9 = icmp slt i64 %7, %5
%10 = and i1 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = tail call i32 @getJSAnalog(i32 %0, i32 %1)
%13 = icmp eq i32 %3, 1
%14 = sub nsw i32 0, %12
%15 = select i1 %13, i32 %14, i32 %12
br label %16
16: ; preds = %6, %11
%17 = phi i32 [ %15, %11 ], [ 0, %6 ]
%18 = tail call i32 @SetMotor(i32 %2, i32 %17)
ret void
}