#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 */
unsigned int AnalogRead_Mean2PC0();
unsigned int AnalogRead_PC1();
unsigned int AnalogRead_PC2();
unsigned char getPitch(unsigned char sensorNum, unsigned char minCalVal) {
  unsigned int sensorVal = 0;
  switch (sensorNum) {
  case (1):
    sensorVal = AnalogRead_Mean2PC0();
    break;
  case (2):
    sensorVal = AnalogRead_PC1();
    break;
  case (3):
    sensorVal = AnalogRead_PC2();
    break;
  }
  sensorVal = sensorVal - minCalVal;
  if (sensorVal < 0) {
    return 0;
  } else if (sensorVal > 969) {
    return 29;
  } else if (sensorVal > 755) {
    return 28;
  } else if (sensorVal > 588) {
    return 27;
  } else if (sensorVal > 459) {
    return 26;
  } else if (sensorVal > 358) {
    return 25;
  } else if (sensorVal > 279) {
    return 24;
  } else if (sensorVal > 217) {
    return 23;
  } else if (sensorVal > 170) {
    return 22;
  } else if (sensorVal > 132) {
    return 21;
  } else if (sensorVal > 104) {
    return 20;
  } else if (sensorVal > 81) {
    return 19;
  } else if (sensorVal > 63) {
    return 18;
  } else if (sensorVal > 50) {
    return 17;
  } else if (sensorVal > 39) {
    return 16;
  } else if (sensorVal > 31) {
    return 15;
  } else if (sensorVal > 24) {
    return 14;
  } else if (sensorVal > 19) {
    return 13;
  } else if (sensorVal > 15) {
    return 12;
  } else if (sensorVal > 12) {
    return 11;
  } else if (sensorVal > 9) {
    return 10;
  } else if (sensorVal < 10) {
    return sensorVal;
  }
}


x86 assembly (clang, -O0):
<getPitch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
movl   $0x0,-0x8(%rbp)
movzbl -0x2(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1182 <getPitch+0x52>
jmp    1160 <getPitch+0x30>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1191 <getPitch+0x61>
jmp    1171 <getPitch+0x41>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     11a0 <getPitch+0x70>
jmp    11aa <getPitch+0x7a>
mov    $0x0,%al
call   1040 <AnalogRead_Mean2PC0@plt>
mov    %eax,-0x8(%rbp)
jmp    11aa <getPitch+0x7a>
mov    $0x0,%al
call   1050 <AnalogRead_PC1@plt>
mov    %eax,-0x8(%rbp)
jmp    11aa <getPitch+0x7a>
mov    $0x0,%al
call   1030 <AnalogRead_PC2@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
movzbl -0x3(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jae    11c9 <getPitch+0x99>
movb   $0x0,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x3c9,-0x8(%rbp)
jbe    11df <getPitch+0xaf>
movb   $0x1d,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x2f3,-0x8(%rbp)
jbe    11f5 <getPitch+0xc5>
movb   $0x1c,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x24c,-0x8(%rbp)
jbe    120b <getPitch+0xdb>
movb   $0x1b,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x1cb,-0x8(%rbp)
jbe    1221 <getPitch+0xf1>
movb   $0x1a,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x166,-0x8(%rbp)
jbe    1237 <getPitch+0x107>
movb   $0x19,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x117,-0x8(%rbp)
jbe    124d <getPitch+0x11d>
movb   $0x18,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0xd9,-0x8(%rbp)
jbe    1263 <getPitch+0x133>
movb   $0x17,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0xaa,-0x8(%rbp)
jbe    1279 <getPitch+0x149>
movb   $0x16,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x84,-0x8(%rbp)
jbe    128f <getPitch+0x15f>
movb   $0x15,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x68,-0x8(%rbp)
jbe    12a2 <getPitch+0x172>
movb   $0x14,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x51,-0x8(%rbp)
jbe    12b5 <getPitch+0x185>
movb   $0x13,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x3f,-0x8(%rbp)
jbe    12c8 <getPitch+0x198>
movb   $0x12,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x32,-0x8(%rbp)
jbe    12db <getPitch+0x1ab>
movb   $0x11,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x27,-0x8(%rbp)
jbe    12ee <getPitch+0x1be>
movb   $0x10,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x1f,-0x8(%rbp)
jbe    1301 <getPitch+0x1d1>
movb   $0xf,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x18,-0x8(%rbp)
jbe    1314 <getPitch+0x1e4>
movb   $0xe,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x13,-0x8(%rbp)
jbe    1327 <getPitch+0x1f7>
movb   $0xd,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0xf,-0x8(%rbp)
jbe    133a <getPitch+0x20a>
movb   $0xc,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0xc,-0x8(%rbp)
jbe    134d <getPitch+0x21d>
movb   $0xb,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0x9,-0x8(%rbp)
jbe    1360 <getPitch+0x230>
movb   $0xa,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
cmpl   $0xa,-0x8(%rbp)
jae    1375 <getPitch+0x245>
mov    -0x8(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    13de <getPitch+0x2ae>
jmp    137a <getPitch+0x24a>
jmp    137f <getPitch+0x24f>
jmp    1384 <getPitch+0x254>
jmp    1389 <getPitch+0x259>
jmp    138e <getPitch+0x25e>
jmp    1393 <getPitch+0x263>
jmp    1398 <getPitch+0x268>
jmp    139d <getPitch+0x26d>
jmp    13a2 <getPitch+0x272>
jmp    13a7 <getPitch+0x277>
jmp    13ac <getPitch+0x27c>
jmp    13b1 <getPitch+0x281>
jmp    13b6 <getPitch+0x286>
jmp    13bb <getPitch+0x28b>
jmp    13c0 <getPitch+0x290>
jmp    13c5 <getPitch+0x295>
jmp    13ca <getPitch+0x29a>
jmp    13cf <getPitch+0x29f>
jmp    13d4 <getPitch+0x2a4>
jmp    13d9 <getPitch+0x2a9>
jmp    13de <getPitch+0x2ae>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPitch>:
push   %rbx
mov    %esi,%ebx
cmp    $0x3,%dil
je     1150 <getPitch+0x20>
cmp    $0x2,%dil
je     1159 <getPitch+0x29>
xor    %eax,%eax
cmp    $0x1,%dil
jne    1160 <getPitch+0x30>
xor    %eax,%eax
call   1040 <AnalogRead_Mean2PC0@plt>
jmp    1160 <getPitch+0x30>
xor    %eax,%eax
call   1030 <AnalogRead_PC2@plt>
jmp    1160 <getPitch+0x30>
xor    %eax,%eax
call   1050 <AnalogRead_PC1@plt>
movzbl %bl,%ecx
sub    %ecx,%eax
mov    $0x1d,%cl
cmp    $0x3c9,%eax
ja     1213 <getPitch+0xe3>
mov    $0x1c,%cl
cmp    $0x2f3,%eax
ja     1213 <getPitch+0xe3>
mov    $0x1b,%cl
cmp    $0x24c,%eax
ja     1213 <getPitch+0xe3>
mov    $0x1a,%cl
cmp    $0x1cb,%eax
ja     1213 <getPitch+0xe3>
mov    $0x19,%cl
cmp    $0x166,%eax
ja     1213 <getPitch+0xe3>
mov    $0x18,%cl
cmp    $0x117,%eax
ja     1213 <getPitch+0xe3>
mov    $0x17,%cl
cmp    $0xd9,%eax
ja     1213 <getPitch+0xe3>
mov    $0x16,%cl
cmp    $0xaa,%eax
ja     1213 <getPitch+0xe3>
mov    $0x15,%cl
cmp    $0x84,%eax
ja     1213 <getPitch+0xe3>
mov    $0x14,%cl
cmp    $0x68,%eax
ja     1213 <getPitch+0xe3>
mov    $0x13,%cl
cmp    $0x51,%eax
ja     1213 <getPitch+0xe3>
mov    $0x12,%cl
cmp    $0x3f,%eax
ja     1213 <getPitch+0xe3>
mov    $0x11,%cl
cmp    $0x32,%eax
ja     1213 <getPitch+0xe3>
mov    $0x10,%cl
cmp    $0x27,%eax
ja     1213 <getPitch+0xe3>
mov    $0xf,%cl
cmp    $0x1f,%eax
ja     1213 <getPitch+0xe3>
mov    $0xe,%cl
cmp    $0x18,%eax
ja     1213 <getPitch+0xe3>
mov    $0xd,%cl
cmp    $0x13,%eax
ja     1213 <getPitch+0xe3>
mov    $0xc,%cl
cmp    $0xf,%eax
ja     1213 <getPitch+0xe3>
mov    $0xb,%cl
cmp    $0xc,%eax
ja     1213 <getPitch+0xe3>
cmp    $0xa,%eax
mov    $0xa,%ecx
cmovb  %eax,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @getPitch(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i8 %0, i8* %4
store i8 %1, i8* %5
store i32 0, i32* %6
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
switch i32 %8, label %15 [
i32 1, label %9
i32 2, label %11
i32 3, label %13
]
9: ; preds = %2
%10 = call i32 (...) @AnalogRead_Mean2PC0()
store i32 %10, i32* %6
br label %15
11: ; preds = %2
%12 = call i32 (...) @AnalogRead_PC1()
store i32 %12, i32* %6
br label %15
13: ; preds = %2
%14 = call i32 (...) @AnalogRead_PC2()
store i32 %14, i32* %6
br label %15
15: ; preds = %2, %13, %11, %9
%16 = load i32, i32* %6
%17 = load i8, i8* %5
%18 = zext i8 %17 to i32
%19 = sub i32 %16, %18
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ult i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
store i8 0, i8* %3
br label %130
23: ; preds = %15
%24 = load i32, i32* %6
%25 = icmp ugt i32 %24, 969
br i1 %25, label %26, label %27
26: ; preds = %23
store i8 29, i8* %3
br label %130
27: ; preds = %23
%28 = load i32, i32* %6
%29 = icmp ugt i32 %28, 755
br i1 %29, label %30, label %31
30: ; preds = %27
store i8 28, i8* %3
br label %130
31: ; preds = %27
%32 = load i32, i32* %6
%33 = icmp ugt i32 %32, 588
br i1 %33, label %34, label %35
34: ; preds = %31
store i8 27, i8* %3
br label %130
35: ; preds = %31
%36 = load i32, i32* %6
%37 = icmp ugt i32 %36, 459
br i1 %37, label %38, label %39
38: ; preds = %35
store i8 26, i8* %3
br label %130
39: ; preds = %35
%40 = load i32, i32* %6
%41 = icmp ugt i32 %40, 358
br i1 %41, label %42, label %43
42: ; preds = %39
store i8 25, i8* %3
br label %130
43: ; preds = %39
%44 = load i32, i32* %6
%45 = icmp ugt i32 %44, 279
br i1 %45, label %46, label %47
46: ; preds = %43
store i8 24, i8* %3
br label %130
47: ; preds = %43
%48 = load i32, i32* %6
%49 = icmp ugt i32 %48, 217
br i1 %49, label %50, label %51
50: ; preds = %47
store i8 23, i8* %3
br label %130
51: ; preds = %47
%52 = load i32, i32* %6
%53 = icmp ugt i32 %52, 170
br i1 %53, label %54, label %55
54: ; preds = %51
store i8 22, i8* %3
br label %130
55: ; preds = %51
%56 = load i32, i32* %6
%57 = icmp ugt i32 %56, 132
br i1 %57, label %58, label %59
58: ; preds = %55
store i8 21, i8* %3
br label %130
59: ; preds = %55
%60 = load i32, i32* %6
%61 = icmp ugt i32 %60, 104
br i1 %61, label %62, label %63
62: ; preds = %59
store i8 20, i8* %3
br label %130
63: ; preds = %59
%64 = load i32, i32* %6
%65 = icmp ugt i32 %64, 81
br i1 %65, label %66, label %67
66: ; preds = %63
store i8 19, i8* %3
br label %130
67: ; preds = %63
%68 = load i32, i32* %6
%69 = icmp ugt i32 %68, 63
br i1 %69, label %70, label %71
70: ; preds = %67
store i8 18, i8* %3
br label %130
71: ; preds = %67
%72 = load i32, i32* %6
%73 = icmp ugt i32 %72, 50
br i1 %73, label %74, label %75
74: ; preds = %71
store i8 17, i8* %3
br label %130
75: ; preds = %71
%76 = load i32, i32* %6
%77 = icmp ugt i32 %76, 39
br i1 %77, label %78, label %79
78: ; preds = %75
store i8 16, i8* %3
br label %130
79: ; preds = %75
%80 = load i32, i32* %6
%81 = icmp ugt i32 %80, 31
br i1 %81, label %82, label %83
82: ; preds = %79
store i8 15, i8* %3
br label %130
83: ; preds = %79
%84 = load i32, i32* %6
%85 = icmp ugt i32 %84, 24
br i1 %85, label %86, label %87
86: ; preds = %83
store i8 14, i8* %3
br label %130
87: ; preds = %83
%88 = load i32, i32* %6
%89 = icmp ugt i32 %88, 19
br i1 %89, label %90, label %91
90: ; preds = %87
store i8 13, i8* %3
br label %130
91: ; preds = %87
%92 = load i32, i32* %6
%93 = icmp ugt i32 %92, 15
br i1 %93, label %94, label %95
94: ; preds = %91
store i8 12, i8* %3
br label %130
95: ; preds = %91
%96 = load i32, i32* %6
%97 = icmp ugt i32 %96, 12
br i1 %97, label %98, label %99
98: ; preds = %95
store i8 11, i8* %3
br label %130
99: ; preds = %95
%100 = load i32, i32* %6
%101 = icmp ugt i32 %100, 9
br i1 %101, label %102, label %103
102: ; preds = %99
store i8 10, i8* %3
br label %130
103: ; preds = %99
%104 = load i32, i32* %6
%105 = icmp ult i32 %104, 10
br i1 %105, label %106, label %109
106: ; preds = %103
%107 = load i32, i32* %6
%108 = trunc i32 %107 to i8
store i8 %108, i8* %3
br label %130
109: ; preds = %103
br label %110
110: ; preds = %109
br label %111
111: ; preds = %110
br label %112
112: ; preds = %111
br label %113
113: ; preds = %112
br label %114
114: ; preds = %113
br label %115
115: ; preds = %114
br label %116
116: ; preds = %115
br label %117
117: ; preds = %116
br label %118
118: ; preds = %117
br label %119
119: ; preds = %118
br label %120
120: ; preds = %119
br label %121
121: ; preds = %120
br label %122
122: ; preds = %121
br label %123
123: ; preds = %122
br label %124
124: ; preds = %123
br label %125
125: ; preds = %124
br label %126
126: ; preds = %125
br label %127
127: ; preds = %126
br label %128
128: ; preds = %127
br label %129
129: ; preds = %128
br label %130
130: ; preds = %22, %26, %30, %34, %38, %42, %46, %50, %54, %58, %62, %66, %70, %74, %78, %82, %86, %90, %94, %98, %102, %106, %129
%131 = load i8, i8* %3
ret i8 %131
}

LLVM IR (-O2):
define zeroext i8 @getPitch(i8 zeroext %0, i8 zeroext %1) {
switch i8 %0, label %9 [
i8 1, label %3
i8 2, label %5
i8 3, label %7
]
3: ; preds = %2
%4 = tail call i32 (...) @AnalogRead_Mean2PC0()
br label %9
5: ; preds = %2
%6 = tail call i32 (...) @AnalogRead_PC1()
br label %9
7: ; preds = %2
%8 = tail call i32 (...) @AnalogRead_PC2()
br label %9
9: ; preds = %2, %7, %5, %3
%10 = phi i32 [ 0, %2 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
%11 = zext i8 %1 to i32
%12 = sub i32 %10, %11
%13 = icmp ugt i32 %12, 969
br i1 %13, label %54, label %14
14: ; preds = %9
%15 = icmp ugt i32 %12, 755
br i1 %15, label %54, label %16
16: ; preds = %14
%17 = icmp ugt i32 %12, 588
br i1 %17, label %54, label %18
18: ; preds = %16
%19 = icmp ugt i32 %12, 459
br i1 %19, label %54, label %20
20: ; preds = %18
%21 = icmp ugt i32 %12, 358
br i1 %21, label %54, label %22
22: ; preds = %20
%23 = icmp ugt i32 %12, 279
br i1 %23, label %54, label %24
24: ; preds = %22
%25 = icmp ugt i32 %12, 217
br i1 %25, label %54, label %26
26: ; preds = %24
%27 = icmp ugt i32 %12, 170
br i1 %27, label %54, label %28
28: ; preds = %26
%29 = icmp ugt i32 %12, 132
br i1 %29, label %54, label %30
30: ; preds = %28
%31 = icmp ugt i32 %12, 104
br i1 %31, label %54, label %32
32: ; preds = %30
%33 = icmp ugt i32 %12, 81
br i1 %33, label %54, label %34
34: ; preds = %32
%35 = icmp ugt i32 %12, 63
br i1 %35, label %54, label %36
36: ; preds = %34
%37 = icmp ugt i32 %12, 50
br i1 %37, label %54, label %38
38: ; preds = %36
%39 = icmp ugt i32 %12, 39
br i1 %39, label %54, label %40
40: ; preds = %38
%41 = icmp ugt i32 %12, 31
br i1 %41, label %54, label %42
42: ; preds = %40
%43 = icmp ugt i32 %12, 24
br i1 %43, label %54, label %44
44: ; preds = %42
%45 = icmp ugt i32 %12, 19
br i1 %45, label %54, label %46
46: ; preds = %44
%47 = icmp ugt i32 %12, 15
br i1 %47, label %54, label %48
48: ; preds = %46
%49 = icmp ugt i32 %12, 12
br i1 %49, label %54, label %50
50: ; preds = %48
%51 = icmp ugt i32 %12, 9
%52 = trunc i32 %12 to i8
%53 = select i1 %51, i8 10, i8 %52
br label %54
54: ; preds = %50, %48, %46, %44, %42, %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %9
%55 = phi i8 [ 29, %9 ], [ 28, %14 ], [ 27, %16 ], [ 26, %18 ], [ 25, %20 ], [ 24, %22 ], [ 23, %24 ], [ 22, %26 ], [ 21, %28 ], [ 20, %30 ], [ 19, %32 ], [ 18, %34 ], [ 17, %36 ], [ 16, %38 ], [ 15, %40 ], [ 14, %42 ], [ 13, %44 ], [ 12, %46 ], [ 11, %48 ], [ %53, %50 ]
ret i8 %55
}