#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 */
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, double);
int scanf(char *, int *, int *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc < 3) {
    usage();
    exit(EXIT_SUCCESS);
  }
  int i;
  int16_t adc[8];
  if (scanf("%x %x %x %x %x %x %x", &adc[0], &adc[1], &adc[2], &adc[3], &adc[4],
            &adc[5], &adc[6], &adc[7]) < 4) {
    fprintf(stderr, "The Input value might be corrupted");
    exit(EXIT_FAILURE);
  }
  int16_t R1000 = atoi(argv[1]);
  for (i = 2; i < argc; i++) {
    int16_t adc_counter = atoi(argv[i]);
    if (adc_counter > 7) {
      usage();
      exit(EXIT_FAILURE);
    }
    double R2K2 = R1000 * (2048.0 - adc[adc_counter]) / adc[adc_counter];
    printf("%d: %.0f\n", adc_counter, R2K2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1195 <main+0x35>
mov    $0x0,%al
call   1050 <usage@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x40(%rbp),%rsi
lea    -0x40(%rbp),%rdx
add    $0x4,%rdx
lea    -0x40(%rbp),%rcx
add    $0x8,%rcx
lea    -0x40(%rbp),%r8
add    $0xc,%r8
lea    -0x40(%rbp),%r9
add    $0x10,%r9
lea    -0x40(%rbp),%r11
add    $0x14,%r11
lea    -0x40(%rbp),%r10
add    $0x18,%r10
lea    -0x40(%rbp),%rax
add    $0x1c,%rax
lea    0xe30(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <scanf@plt>
cmp    $0x4,%eax
jge    1217 <main+0xb7>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x44(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c1 <main+0x161>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x7,-0x48(%rbp)
jle    126d <main+0x10d>
mov    $0x0,%al
call   1050 <usage@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cvtsi2sdl -0x44(%rbp),%xmm0
movslq -0x48(%rbp),%rax
cvtsi2sdl -0x40(%rbp,%rax,4),%xmm2
movsd  0xd7c(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movslq -0x48(%rbp),%rax
cvtsi2sdl -0x40(%rbp,%rax,4),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x48(%rbp),%esi
movsd  -0x50(%rbp),%xmm0
lea    0xd92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122e <main+0xce>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jle    1254 <main+0xf4>
mov    %rsi,%r15
mov    %edi,%ebp
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x10(%rsp),%r9
lea    0x14(%rsp),%r10
lea    0x18(%rsp),%rbx
lea    0x1c(%rsp),%rax
sub    $0x8,%rsp
lea    0xe62(%rip),%rdi
lea    0x8(%rsp),%rsi
push   %rax
push   %rbx
push   %r10
call   1060 <scanf@plt>
add    $0x20,%rsp
cmp    $0x3,%eax
jle    1269 <main+0x109>
mov    0x8(%r15),%rdi
call   1070 <atoi@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %ebp,%ebp
mov    $0x2,%ebx
lea    0xe5e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1070 <atoi@plt>
cmp    $0x8,%eax
jge    123f <main+0xdf>
movslq %eax,%rcx
xorps  %xmm1,%xmm1
cvtsi2sdl (%rsp,%rcx,4),%xmm1
movsd  0xdef(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11f0 <main+0x90>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1246 <main+0xe6>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [21 x i8] c"%x %x %x %x %x %x %x\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"The Input value might be corrupted\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%d: %.0f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 (...) @usage()
%15 = load i32, i32* @EXIT_SUCCESS
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 2
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 3
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 4
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 5
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 6
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 7
%26 = call i32 @scanf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32* %18, i32* %19, i32* %20, i32* %21, i32* %22, i32* %23, i32* %24, i32* %25)
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %33
28: ; preds = %17
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %17
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %8
store i32 2, i32* %6
br label %38
38: ; preds = %74, %33
%39 = load i32, i32* %6
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %77
42: ; preds = %38
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @atoi(i8* %47)
store i32 %48, i32* %9
%49 = load i32, i32* %9
%50 = icmp sgt i32 %49, 7
br i1 %50, label %51, label %55
51: ; preds = %42
%52 = call i32 (...) @usage()
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %42
%56 = load i32, i32* %8
%57 = sitofp i32 %56 to double
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = sitofp i32 %61 to double
%63 = fsub double 2.048000e+03, %62
%64 = fmul double %57, %63
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = sitofp i32 %68 to double
%70 = fdiv double %64, %69
store double %70, double* %10
%71 = load i32, i32* %9
%72 = load double, double* %10
%73 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %71, double %72)
br label %74
74: ; preds = %55
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %38
77: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [21 x i8] c"%x %x %x %x %x %x %x\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"The Input value might be corrupted\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"%d: %.0f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 (...) @usage()
%7 = load i32, i32* @EXIT_SUCCESS
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = bitcast [8 x i32]* %3 to i8*
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%19 = call i32 @scanf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16, i32* %17, i32* %18)
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %26
21: ; preds = %9
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %9
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = sitofp i32 %29 to double
%31 = zext i32 %0 to i64
br label %32
32: ; preds = %26, %42
%33 = phi i64 [ 2, %26 ], [ %51, %42 ]
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
%37 = icmp sgt i32 %36, 7
br i1 %37, label %38, label %42
38: ; preds = %32
%39 = call i32 (...) @usage()
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %32
%43 = sext i32 %36 to i64
%44 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = sitofp i32 %45 to double
%47 = fsub double 2.048000e+03, %46
%48 = fmul double %47, %30
%49 = fdiv double %48, %46
%50 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %36, double %49)
%51 = add nuw nsw i64 %33, 1
%52 = icmp eq i64 %51, %31
br i1 %52, label %53, label %32
53: ; preds = %42
ret i32 0
}