#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 abs(int);
int toPercent(int, int);
int applyThingsNStuff(int joyValue, int threshold, int throttle) {
  int trueValue;
  if (toPercent(joyValue, 124) < throttle && abs(joyValue) > threshold) {
    trueValue = joyValue;
  } else if (toPercent(joyValue, 124) >= throttle &&
             abs(joyValue) > threshold) {
    trueValue = joyValue * (throttle / 100);
  } else if (abs(joyValue) < threshold) {
    trueValue = 0;
  }
  return trueValue;
}


x86 assembly (clang, -O0):
<applyThingsNStuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x7c,%esi
call   1030 <toPercent@plt>
cmp    -0xc(%rbp),%eax
jge    1163 <applyThingsNStuff+0x43>
mov    -0x4(%rbp),%edi
call   1040 <abs@plt>
cmp    -0x8(%rbp),%eax
jle    1163 <applyThingsNStuff+0x43>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11cd <applyThingsNStuff+0xad>
mov    -0x4(%rbp),%edi
mov    $0x7c,%esi
call   1030 <toPercent@plt>
cmp    -0xc(%rbp),%eax
jl     11ab <applyThingsNStuff+0x8b>
mov    -0x4(%rbp),%edi
call   1040 <abs@plt>
cmp    -0x8(%rbp),%eax
jle    11ab <applyThingsNStuff+0x8b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11c8 <applyThingsNStuff+0xa8>
mov    -0x4(%rbp),%edi
call   1040 <abs@plt>
cmp    -0x8(%rbp),%eax
jge    11c3 <applyThingsNStuff+0xa3>
movl   $0x0,-0x10(%rbp)
jmp    11c8 <applyThingsNStuff+0xa8>
jmp    11cd <applyThingsNStuff+0xad>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<applyThingsNStuff>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x7c,%esi
call   1030 <toPercent@plt>
mov    %ebp,%ebx
neg    %ebx
cmovs  %ebp,%ebx
cmp    %r15d,%eax
jge    113e <applyThingsNStuff+0x2e>
cmp    %r14d,%ebx
jle    113e <applyThingsNStuff+0x2e>
mov    %ebp,%eax
jmp    1172 <applyThingsNStuff+0x62>
mov    %ebp,%edi
mov    $0x7c,%esi
call   1030 <toPercent@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %r15d,%ecx
jl     1172 <applyThingsNStuff+0x62>
cmp    %r14d,%ebx
jle    1172 <applyThingsNStuff+0x62>
movslq %r15d,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @applyThingsNStuff(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = call i32 @toPercent(i32 %8, i32 124)
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* %4
%14 = call i32 @abs(i32 %13)
%15 = load i32, i32* %5
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = load i32, i32* %4
store i32 %18, i32* %7
br label %42
19: ; preds = %12, %3
%20 = load i32, i32* %4
%21 = call i32 @toPercent(i32 %20, i32 124)
%22 = load i32, i32* %6
%23 = icmp sge i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i32, i32* %4
%26 = call i32 @abs(i32 %25)
%27 = load i32, i32* %5
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %4
%31 = load i32, i32* %6
%32 = sdiv i32 %31, 100
%33 = mul nsw i32 %30, %32
store i32 %33, i32* %7
br label %41
34: ; preds = %24, %19
%35 = load i32, i32* %4
%36 = call i32 @abs(i32 %35)
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 0, i32* %7
br label %40
40: ; preds = %39, %34
br label %41
41: ; preds = %40, %29
br label %42
42: ; preds = %41, %17
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @applyThingsNStuff(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @toPercent(i32 %0, i32 124)
%5 = icmp slt i32 %4, %2
%6 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%7 = icmp sgt i32 %6, %1
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %16, label %9
9: ; preds = %3
%10 = tail call i32 @toPercent(i32 %0, i32 124)
%11 = icmp sge i32 %10, %2
%12 = select i1 %11, i1 %7, i1 false
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = sdiv i32 %2, 100
%15 = mul nsw i32 %14, %0
br label %16
16: ; preds = %9, %3, %13
%17 = phi i32 [ %15, %13 ], [ %0, %3 ], [ 0, %9 ]
ret i32 %17
}