unsigned int amplitude2signal(int input) {
  if (input > 16000) {
    return (0x0001);
  } else if (input > 8000) {
    return (0x0002U);
  } else if (input > 4000) {
    return (0x0004U);
  } else if (input > 2000) {
    return (0x0008U);
  } else if (input > 1000) {
    return (0x0010U);
  } else if (input > 500) {
    return (0x0020U);
  } else if (input > 250) {
    return (0x0040U);
  } else if (input >= 0) {
    return (0x0080U);
  } else if (input < -16000) {
    return (0x8000U);
  } else if (input < -8000) {
    return (0x4000U);
  } else if (input < -4000) {
    return (0x2000U);
  } else if (input < -2000) {
    return (0x1000U);
  } else if (input < -1000) {
    return (0x0800U);
  } else if (input < -500) {
    return (0x0400U);
  } else if (input < -250) {
    return (0x0200U);
  } else {
    return (0x0100);
  }
}


x86 assembly (clang, -O0):
<amplitude2signal>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x3e80,-0x8(%rbp)
jle    1120 <amplitude2signal+0x20>
movl   $0x1,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0x1f40,-0x8(%rbp)
jle    1139 <amplitude2signal+0x39>
movl   $0x2,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfa0,-0x8(%rbp)
jle    1152 <amplitude2signal+0x52>
movl   $0x4,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0x7d0,-0x8(%rbp)
jle    116b <amplitude2signal+0x6b>
movl   $0x8,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0x3e8,-0x8(%rbp)
jle    1184 <amplitude2signal+0x84>
movl   $0x10,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0x1f4,-0x8(%rbp)
jle    119d <amplitude2signal+0x9d>
movl   $0x20,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfa,-0x8(%rbp)
jle    11b6 <amplitude2signal+0xb6>
movl   $0x40,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0x0,-0x8(%rbp)
jl     11cc <amplitude2signal+0xcc>
movl   $0x80,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xffffc180,-0x8(%rbp)
jge    11e5 <amplitude2signal+0xe5>
movl   $0x8000,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xffffe0c0,-0x8(%rbp)
jge    11fe <amplitude2signal+0xfe>
movl   $0x4000,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfffff060,-0x8(%rbp)
jge    1217 <amplitude2signal+0x117>
movl   $0x2000,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfffff830,-0x8(%rbp)
jge    1230 <amplitude2signal+0x130>
movl   $0x1000,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfffffc18,-0x8(%rbp)
jge    1249 <amplitude2signal+0x149>
movl   $0x800,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xfffffe0c,-0x8(%rbp)
jge    1262 <amplitude2signal+0x162>
movl   $0x400,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
cmpl   $0xffffff06,-0x8(%rbp)
jge    127b <amplitude2signal+0x17b>
movl   $0x200,-0x4(%rbp)
jmp    1282 <amplitude2signal+0x182>
movl   $0x100,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<amplitude2signal>:
mov    $0x1,%eax
cmp    $0x3e80,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x2,%eax
cmp    $0x1f40,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x4,%eax
cmp    $0xfa0,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x8,%eax
cmp    $0x7d0,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x10,%eax
cmp    $0x3e8,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x20,%eax
cmp    $0x1f4,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x40,%eax
cmp    $0xfa,%edi
jg     11d9 <amplitude2signal+0xd9>
mov    $0x80,%eax
test   %edi,%edi
jns    11d9 <amplitude2signal+0xd9>
mov    $0x8000,%eax
cmp    $0xffffc180,%edi
jb     11d9 <amplitude2signal+0xd9>
mov    $0x4000,%eax
cmp    $0xffffe0c0,%edi
jb     11d9 <amplitude2signal+0xd9>
mov    $0x2000,%eax
cmp    $0xfffff060,%edi
jb     11d9 <amplitude2signal+0xd9>
mov    $0x1000,%eax
cmp    $0xfffff830,%edi
jb     11d9 <amplitude2signal+0xd9>
mov    $0x800,%eax
cmp    $0xfffffc18,%edi
jb     11d9 <amplitude2signal+0xd9>
mov    $0x400,%eax
cmp    $0xfffffe0c,%edi
jb     11d9 <amplitude2signal+0xd9>
xor    %eax,%eax
cmp    $0xffffff06,%edi
setb   %al
shl    $0x8,%eax
add    $0x100,%eax
ret

LLVM IR (-O0):
define i32 @amplitude2signal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sgt i32 %4, 16000
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %64
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 8000
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %2
br label %64
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 4000
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 4, i32* %2
br label %64
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 2000
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 8, i32* %2
br label %64
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 1000
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 16, i32* %2
br label %64
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 500
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 32, i32* %2
br label %64
27: ; preds = %23
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 250
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 64, i32* %2
br label %64
31: ; preds = %27
%32 = load i32, i32* %3
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 128, i32* %2
br label %64
35: ; preds = %31
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, -16000
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 32768, i32* %2
br label %64
39: ; preds = %35
%40 = load i32, i32* %3
%41 = icmp slt i32 %40, -8000
br i1 %41, label %42, label %43
42: ; preds = %39
store i32 16384, i32* %2
br label %64
43: ; preds = %39
%44 = load i32, i32* %3
%45 = icmp slt i32 %44, -4000
br i1 %45, label %46, label %47
46: ; preds = %43
store i32 8192, i32* %2
br label %64
47: ; preds = %43
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, -2000
br i1 %49, label %50, label %51
50: ; preds = %47
store i32 4096, i32* %2
br label %64
51: ; preds = %47
%52 = load i32, i32* %3
%53 = icmp slt i32 %52, -1000
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 2048, i32* %2
br label %64
55: ; preds = %51
%56 = load i32, i32* %3
%57 = icmp slt i32 %56, -500
br i1 %57, label %58, label %59
58: ; preds = %55
store i32 1024, i32* %2
br label %64
59: ; preds = %55
%60 = load i32, i32* %3
%61 = icmp slt i32 %60, -250
br i1 %61, label %62, label %63
62: ; preds = %59
store i32 512, i32* %2
br label %64
63: ; preds = %59
store i32 256, i32* %2
br label %64
64: ; preds = %63, %62, %58, %54, %50, %46, %42, %38, %34, %30, %26, %22, %18, %14, %10, %6
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
define i32 @amplitude2signal(i32 %0) {
%2 = icmp sgt i32 %0, 16000
br i1 %2, label %32, label %3
3: ; preds = %1
%4 = icmp sgt i32 %0, 8000
br i1 %4, label %32, label %5
5: ; preds = %3
%6 = icmp sgt i32 %0, 4000
br i1 %6, label %32, label %7
7: ; preds = %5
%8 = icmp sgt i32 %0, 2000
br i1 %8, label %32, label %9
9: ; preds = %7
%10 = icmp sgt i32 %0, 1000
br i1 %10, label %32, label %11
11: ; preds = %9
%12 = icmp sgt i32 %0, 500
br i1 %12, label %32, label %13
13: ; preds = %11
%14 = icmp sgt i32 %0, 250
br i1 %14, label %32, label %15
15: ; preds = %13
%16 = icmp sgt i32 %0, -1
br i1 %16, label %32, label %17
17: ; preds = %15
%18 = icmp ult i32 %0, -16000
br i1 %18, label %32, label %19
19: ; preds = %17
%20 = icmp ult i32 %0, -8000
br i1 %20, label %32, label %21
21: ; preds = %19
%22 = icmp ult i32 %0, -4000
br i1 %22, label %32, label %23
23: ; preds = %21
%24 = icmp ult i32 %0, -2000
br i1 %24, label %32, label %25
25: ; preds = %23
%26 = icmp ult i32 %0, -1000
br i1 %26, label %32, label %27
27: ; preds = %25
%28 = icmp ult i32 %0, -500
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = icmp ult i32 %0, -250
%31 = select i1 %30, i32 512, i32 256
br label %32
32: ; preds = %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3, %1
%33 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 4, %5 ], [ 8, %7 ], [ 16, %9 ], [ 32, %11 ], [ 64, %13 ], [ 128, %15 ], [ 32768, %17 ], [ 16384, %19 ], [ 8192, %21 ], [ 4096, %23 ], [ 2048, %25 ], [ 1024, %27 ], [ %31, %29 ]
ret i32 %33
}