#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 /*<<< orphan*/ i2c_Write(int, int, char *, int);
int readADC(int inputNum) {
  char d[3];
  int returnable;
  char reading[2];
  switch (inputNum) {
  case 0:
    d[0] = 0x00;
    i2c_Write(0b1001000, 1, d, 1);
    i2c_Write(0b1001000, 0, reading, 2);
    returnable = (reading[0] & 0x00FF) << 8;
    returnable = returnable | (reading[1] & 0x00FF);
    returnable = (returnable & 0x0FFF) >> 4;
    d[0] = 0x01;
    d[1] = (0x5483 & 0xFF00) >> 8;
    d[2] = (0x5483 & 0x00FF) >> 0;
    i2c_Write(0b1001000, 1, d, 3);
    break;
  case 1:
    d[0] = 0x00;
    i2c_Write(0b1001000, 1, d, 1);
    i2c_Write(0b1001000, 0, reading, 2);
    returnable = (reading[0] & 0x00FF) << 8;
    returnable = returnable | (reading[1] & 0x00FF);
    returnable = (returnable & 0x0FFF) >> 4;
    d[0] = 0x01;
    d[1] = (0x6483 & 0xFF00) >> 8;
    d[2] = (0x6483 & 0x00FF) >> 0;
    i2c_Write(0b1001000, 1, d, 3);
    break;
  case 2:
    d[0] = 0x00;
    i2c_Write(0b1001000, 1, d, 1);
    i2c_Write(0b1001000, 0, reading, 2);
    returnable = (reading[0] & 0x00FF) << 8;
    returnable = returnable | (reading[1] & 0x00FF);
    returnable = (returnable & 0x0FFF) >> 4;
    d[0] = 0x01;
    d[1] = (0x7483 & 0xFF00) >> 8;
    d[2] = (0x7483 & 0x00FF) >> 0;
    i2c_Write(0b1001000, 1, d, 3);
    break;
  case 3:
    d[0] = 0x00;
    i2c_Write(0b1001000, 1, d, 1);
    i2c_Write(0b1001000, 0, reading, 2);
    returnable = (reading[0] & 0x00FF) << 8;
    returnable = returnable | (reading[1] & 0x00FF);
    returnable = (returnable & 0x0FFF) >> 4;
    d[0] = 0x01;
    d[1] = (0x4483 & 0xFF00) >> 8;
    d[2] = (0x4483 & 0x00FF) >> 0;
    i2c_Write(0b1001000, 1, d, 3);
    break;
  }
  returnable = (int)((3300.0 / 4095.0) * returnable);
  return returnable;
}


x86 assembly (clang, -O0):
<readADC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1353 <readADC+0x243>
mov    -0x18(%rbp),%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,-0x7(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <i2c_Write@plt>
lea    -0xe(%rbp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movsbl -0xe(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0xd(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
sar    $0x4,%eax
mov    %eax,-0xc(%rbp)
movb   $0x1,-0x7(%rbp)
movb   $0x54,-0x6(%rbp)
movb   $0x83,-0x5(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1030 <i2c_Write@plt>
jmp    1353 <readADC+0x243>
movb   $0x0,-0x7(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <i2c_Write@plt>
lea    -0xe(%rbp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movsbl -0xe(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0xd(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
sar    $0x4,%eax
mov    %eax,-0xc(%rbp)
movb   $0x1,-0x7(%rbp)
movb   $0x64,-0x6(%rbp)
movb   $0x83,-0x5(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1030 <i2c_Write@plt>
jmp    1353 <readADC+0x243>
movb   $0x0,-0x7(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <i2c_Write@plt>
lea    -0xe(%rbp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movsbl -0xe(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0xd(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
sar    $0x4,%eax
mov    %eax,-0xc(%rbp)
movb   $0x1,-0x7(%rbp)
movb   $0x74,-0x6(%rbp)
movb   $0x83,-0x5(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1030 <i2c_Write@plt>
jmp    1353 <readADC+0x243>
movb   $0x0,-0x7(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%ecx
mov    %ecx,%esi
call   1030 <i2c_Write@plt>
lea    -0xe(%rbp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movsbl -0xe(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0xd(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
sar    $0x4,%eax
mov    %eax,-0xc(%rbp)
movb   $0x1,-0x7(%rbp)
movb   $0x44,-0x6(%rbp)
movb   $0x83,-0x5(%rbp)
lea    -0x7(%rbp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1030 <i2c_Write@plt>
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xca0(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readADC>:
cmp    $0x3,%edi
ja     117e <readADC+0x6e>
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
lea    0xee5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x0,0xd(%rsp)
lea    0xd(%rsp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x1,%ecx
call   1030 <i2c_Write@plt>
lea    0xb(%rsp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movzbl 0xb(%rsp),%ebx
movzbl 0xc(%rsp),%eax
and    $0xf,%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movb   $0x1,0xd(%rsp)
mov    $0x54,%al
jmp    126f <readADC+0x15f>
xor    %eax,%eax
ret
movb   $0x0,0xd(%rsp)
lea    0xd(%rsp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x1,%ecx
call   1030 <i2c_Write@plt>
lea    0xb(%rsp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movzbl 0xb(%rsp),%ebx
movzbl 0xc(%rsp),%eax
and    $0xf,%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movb   $0x1,0xd(%rsp)
mov    $0x64,%al
jmp    126f <readADC+0x15f>
movb   $0x0,0xd(%rsp)
lea    0xd(%rsp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x1,%ecx
call   1030 <i2c_Write@plt>
lea    0xb(%rsp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movzbl 0xb(%rsp),%ebx
movzbl 0xc(%rsp),%eax
and    $0xf,%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movb   $0x1,0xd(%rsp)
mov    $0x74,%al
jmp    126f <readADC+0x15f>
movb   $0x0,0xd(%rsp)
lea    0xd(%rsp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x1,%ecx
call   1030 <i2c_Write@plt>
lea    0xb(%rsp),%rdx
mov    $0x48,%edi
xor    %esi,%esi
mov    $0x2,%ecx
call   1030 <i2c_Write@plt>
movzbl 0xb(%rsp),%ebx
movzbl 0xc(%rsp),%eax
and    $0xf,%ebx
shl    $0x8,%ebx
or     %eax,%ebx
movb   $0x1,0xd(%rsp)
mov    $0x44,%al
shr    $0x4,%ebx
mov    %al,0xe(%rsp)
movb   $0x83,0xf(%rsp)
lea    0xd(%rsp),%rdx
mov    $0x48,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1030 <i2c_Write@plt>
cvtsi2sd %ebx,%xmm0
mulsd  0xd60(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @readADC(i32 %0) {
%2 = alloca i32
%3 = alloca [3 x i8]
%4 = alloca i32
%5 = alloca [2 x i8]
store i32 %0, i32* %2
%6 = load i32, i32* %2
switch i32 %6, label %107 [
i32 0, label %7
i32 1, label %32
i32 2, label %57
i32 3, label %82
]
7: ; preds = %1
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 0, i8* %8
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%10 = call i32 @i2c_Write(i32 72, i32 1, i8* %9, i32 1)
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%12 = call i32 @i2c_Write(i32 72, i32 0, i8* %11, i32 2)
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = and i32 %15, 255
%17 = shl i32 %16, 8
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = and i32 %21, 255
%23 = or i32 %18, %22
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = and i32 %24, 4095
%26 = ashr i32 %25, 4
store i32 %26, i32* %4
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 1, i8* %27
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 84, i8* %28
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 -125, i8* %29
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%31 = call i32 @i2c_Write(i32 72, i32 1, i8* %30, i32 3)
br label %107
32: ; preds = %1
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 0, i8* %33
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%35 = call i32 @i2c_Write(i32 72, i32 1, i8* %34, i32 1)
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%37 = call i32 @i2c_Write(i32 72, i32 0, i8* %36, i32 2)
%38 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = and i32 %40, 255
%42 = shl i32 %41, 8
store i32 %42, i32* %4
%43 = load i32, i32* %4
%44 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = and i32 %46, 255
%48 = or i32 %43, %47
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = and i32 %49, 4095
%51 = ashr i32 %50, 4
store i32 %51, i32* %4
%52 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 1, i8* %52
%53 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 100, i8* %53
%54 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 -125, i8* %54
%55 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%56 = call i32 @i2c_Write(i32 72, i32 1, i8* %55, i32 3)
br label %107
57: ; preds = %1
%58 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 0, i8* %58
%59 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%60 = call i32 @i2c_Write(i32 72, i32 1, i8* %59, i32 1)
%61 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%62 = call i32 @i2c_Write(i32 72, i32 0, i8* %61, i32 2)
%63 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = and i32 %65, 255
%67 = shl i32 %66, 8
store i32 %67, i32* %4
%68 = load i32, i32* %4
%69 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = and i32 %71, 255
%73 = or i32 %68, %72
store i32 %73, i32* %4
%74 = load i32, i32* %4
%75 = and i32 %74, 4095
%76 = ashr i32 %75, 4
store i32 %76, i32* %4
%77 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 1, i8* %77
%78 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 116, i8* %78
%79 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 -125, i8* %79
%80 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%81 = call i32 @i2c_Write(i32 72, i32 1, i8* %80, i32 3)
br label %107
82: ; preds = %1
%83 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 0, i8* %83
%84 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%85 = call i32 @i2c_Write(i32 72, i32 1, i8* %84, i32 1)
%86 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%87 = call i32 @i2c_Write(i32 72, i32 0, i8* %86, i32 2)
%88 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = and i32 %90, 255
%92 = shl i32 %91, 8
store i32 %92, i32* %4
%93 = load i32, i32* %4
%94 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = and i32 %96, 255
%98 = or i32 %93, %97
store i32 %98, i32* %4
%99 = load i32, i32* %4
%100 = and i32 %99, 4095
%101 = ashr i32 %100, 4
store i32 %101, i32* %4
%102 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 1, i8* %102
%103 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 68, i8* %103
%104 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 -125, i8* %104
%105 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%106 = call i32 @i2c_Write(i32 72, i32 1, i8* %105, i32 3)
br label %107
107: ; preds = %1, %82, %57, %32, %7
%108 = load i32, i32* %4
%109 = sitofp i32 %108 to double
%110 = fmul double 0x3FE9C99C99C99C9A, %109
%111 = fptosi double %110 to i32
store i32 %111, i32* %4
%112 = load i32, i32* %4
ret i32 %112
}

LLVM IR (-O2):
define i32 @readADC(i32 %0) {
%2 = alloca [3 x i8]
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
switch i32 %0, label %60 [
i32 0, label %6
i32 1, label %17
i32 2, label %28
i32 3, label %39
]
6: ; preds = %1
store i8 0, i8* %4
%7 = call i32 @i2c_Write(i32 72, i32 1, i8* %4, i32 1)
%8 = call i32 @i2c_Write(i32 72, i32 0, i8* %5, i32 2)
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = shl nuw nsw i32 %10, 8
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = and i32 %11, 3840
%16 = or i32 %15, %14
store i8 1, i8* %4
br label %50
17: ; preds = %1
store i8 0, i8* %4
%18 = call i32 @i2c_Write(i32 72, i32 1, i8* %4, i32 1)
%19 = call i32 @i2c_Write(i32 72, i32 0, i8* %5, i32 2)
%20 = load i8, i8* %5
%21 = zext i8 %20 to i32
%22 = shl nuw nsw i32 %21, 8
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = and i32 %22, 3840
%27 = or i32 %26, %25
store i8 1, i8* %4
br label %50
28: ; preds = %1
store i8 0, i8* %4
%29 = call i32 @i2c_Write(i32 72, i32 1, i8* %4, i32 1)
%30 = call i32 @i2c_Write(i32 72, i32 0, i8* %5, i32 2)
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = shl nuw nsw i32 %32, 8
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = and i32 %33, 3840
%38 = or i32 %37, %36
store i8 1, i8* %4
br label %50
39: ; preds = %1
store i8 0, i8* %4
%40 = call i32 @i2c_Write(i32 72, i32 1, i8* %4, i32 1)
%41 = call i32 @i2c_Write(i32 72, i32 0, i8* %5, i32 2)
%42 = load i8, i8* %5
%43 = zext i8 %42 to i32
%44 = shl nuw nsw i32 %43, 8
%45 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = and i32 %44, 3840
%49 = or i32 %48, %47
store i8 1, i8* %4
br label %50
50: ; preds = %6, %17, %28, %39
%51 = phi i8 [ 68, %39 ], [ 116, %28 ], [ 100, %17 ], [ 84, %6 ]
%52 = phi i32 [ %49, %39 ], [ %38, %28 ], [ %27, %17 ], [ %16, %6 ]
%53 = lshr i32 %52, 4
%54 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 %51, i8* %54
%55 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 -125, i8* %55
%56 = call i32 @i2c_Write(i32 72, i32 1, i8* %4, i32 3)
%57 = sitofp i32 %53 to double
%58 = fmul double %57, 0x3FE9C99C99C99C9A
%59 = fptosi double %58 to i32
br label %60
60: ; preds = %50, %1
%61 = phi i32 [ 0, %1 ], [ %59, %50 ]
ret i32 %61
}