#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 curve(int relxy) {
  int ax = abs(relxy);
  int sgn = relxy < 0 ? -1 : 1;
  int mv = 1;
  if (ax > 100)
    mv = 10;
  else if (ax > 65)
    mv = 7;
  else if (ax > 35)
    mv = 5;
  else if (ax > 15)
    mv = 2;
  return mv * sgn;
}


x86 assembly (clang, -O0):
<curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x64,-0x8(%rbp)
jle    1159 <curve+0x49>
movl   $0xa,-0x10(%rbp)
jmp    11a5 <curve+0x95>
cmpl   $0x41,-0x8(%rbp)
jle    116f <curve+0x5f>
movl   $0x7,-0x10(%rbp)
jmp    11a0 <curve+0x90>
cmpl   $0x23,-0x8(%rbp)
jle    1185 <curve+0x75>
movl   $0x5,-0x10(%rbp)
jmp    119b <curve+0x8b>
cmpl   $0xf,-0x8(%rbp)
jle    1196 <curve+0x86>
movl   $0x2,-0x10(%rbp)
jmp    119b <curve+0x8b>
jmp    11a0 <curve+0x90>
jmp    11a5 <curve+0x95>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curve>:
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
mov    $0xa,%ecx
cmp    $0x64,%eax
ja     1130 <curve+0x30>
mov    $0x7,%ecx
cmp    $0x41,%eax
ja     1130 <curve+0x30>
mov    $0x5,%ecx
cmp    $0x23,%eax
ja     1130 <curve+0x30>
cmp    $0x10,%eax
mov    $0x1,%ecx
sbb    $0xffffffff,%ecx
mov    %ecx,%eax
neg    %eax
test   %edi,%edi
cmovns %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @curve(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%3 = icmp ugt i32 %2, 100
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = icmp ugt i32 %2, 65
br i1 %5, label %11, label %6
6: ; preds = %4
%7 = icmp ugt i32 %2, 35
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = icmp ugt i32 %2, 15
%10 = select i1 %9, i32 2, i32 1
br label %11
11: ; preds = %8, %6, %4, %1
%12 = phi i32 [ 10, %1 ], [ 7, %4 ], [ 5, %6 ], [ %10, %8 ]
%13 = icmp sgt i32 %0, -1
%14 = sub nsw i32 0, %12
%15 = select i1 %13, i32 %12, i32 %14
ret i32 %15
}