#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 pow(double, int);
int deadband(int stick) {
  const int db = 7;
  int astick = abs(stick);
  int ret = 0;
  if (astick > db) {
    astick = pow(1.1, astick / 1.5);
    if (astick > 127)
      astick = 127;
    if (stick < 0)
      astick *= -1;
    ret = astick;
  }
  return ret;
}


x86 assembly (clang, -O0):
<deadband>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0xc(%rbp)
jle    119b <deadband+0x7b>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe95(%rip),%xmm0
call   1040 <pow@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jle    1184 <deadband+0x64>
movl   $0x7f,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1195 <deadband+0x75>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deadband>:
mov    %edi,%ecx
neg    %ecx
cmovs  %edi,%ecx
xor    %eax,%eax
cmp    $0x8,%ecx
jb     1153 <deadband+0x43>
push   %rbx
mov    %edi,%ebx
cvtsi2sd %ecx,%xmm0
divsd  0xed3(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xecf(%rip),%xmm0
call   1030 <pow@plt>
cmp    $0x7f,%eax
mov    $0x7f,%ecx
cmovl  %eax,%ecx
mov    %ecx,%eax
neg    %eax
test   %ebx,%ebx
cmovns %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @deadband(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 7, i32* %3
%6 = load i32, i32* %2
%7 = call i32 @abs(i32 %6)
store i32 %7, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 7
br i1 %9, label %10, label %27
10: ; preds = %1
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 1.500000e+00
%14 = fptosi double %13 to i32
%15 = call i32 @pow(double 1.100000e+00, i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 127
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 127, i32* %4
br label %19
19: ; preds = %18, %10
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %4
%24 = mul nsw i32 %23, -1
store i32 %24, i32* %4
br label %25
25: ; preds = %22, %19
%26 = load i32, i32* %4
store i32 %26, i32* %5
br label %27
27: ; preds = %25, %1
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @deadband(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%3 = icmp ugt i32 %2, 7
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = sitofp i32 %2 to double
%6 = fdiv double %5, 1.500000e+00
%7 = fptosi double %6 to i32
%8 = tail call i32 @pow(double 1.100000e+00, i32 %7)
%9 = icmp slt i32 %8, 127
%10 = select i1 %9, i32 %8, i32 127
%11 = icmp slt i32 %0, 0
%12 = sub nsw i32 0, %10
%13 = select i1 %11, i32 %12, i32 %10
br label %14
14: ; preds = %4, %1
%15 = phi i32 [ %13, %4 ], [ 0, %1 ]
ret i32 %15
}