#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;
scalar_t__ adc_to_temperature(char, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double);
int scanf(char *, int *, int *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc == 1) {
    usage();
    exit(EXIT_SUCCESS);
  }
  int i;
  int16_t adc[8];
  char *calibration_file = NULL;
  if (scanf("%x %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);
  }
  i = 1;
  if (strcmp(argv[1], "-c") == 0) {
    calibration_file = argv[2];
    i += 2;
  }
  for (; i < argc; i++) {
    double average = 0;
    int values = 0;
    char *p = argv[i];
    while (*p)
      if (adc[*p - '0'] != 1023) {
        average +=
            adc_to_temperature(*p - '0', calibration_file, adc[*p - '0']);
        p++;
        values++;
      } else
        p++;
    if (average == 0) {
      fprintf(stderr, "No sensor values found\n");
      exit(EXIT_FAILURE);
    }
    average /= values;
    printf("%.2f\n", average);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a8 <main+0x38>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movq   $0x0,-0x48(%rbp)
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    0xe0d(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <scanf@plt>
cmp    $0x4,%eax
jge    1232 <main+0xc2>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    126c <main+0xfc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1271 <main+0x101>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1391 <main+0x221>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmpb   $0x0,(%rax)
je     1324 <main+0x1b4>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
cltq
cmpl   $0x3ff,-0x40(%rbp,%rax,4)
je     1313 <main+0x1a3>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    -0x48(%rbp),%rsi
mov    -0x60(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
mov    -0x40(%rbp,%rcx,4),%edx
movsbl %al,%edi
call   1080 <adc_to_temperature@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    131f <main+0x1af>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    129c <main+0x12c>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    135f <main+0x1ef>
jp     135f <main+0x1ef>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cvtsi2sdl -0x54(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xcd8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1271 <main+0x101>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
je     12f5 <main+0x185>
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x10(%rsp),%r9
lea    0x14(%rsp),%rax
lea    0x18(%rsp),%rbp
lea    0x1c(%rsp),%rbx
sub    $0x8,%rsp
lea    0xe4d(%rip),%rdi
lea    0x8(%rsp),%rsi
push   %rbx
push   %rbp
push   %rax
call   1070 <scanf@plt>
add    $0x20,%rsp
cmp    $0x3,%eax
jle    130a <main+0x19a>
mov    0x8(%r14),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fb <main+0x8b>
mov    $0x1,%eax
xor    %ebx,%ebx
cmp    %r15d,%eax
jl     120d <main+0x9d>
jmp    12c1 <main+0x151>
mov    0x10(%r14),%rbx
mov    $0x3,%eax
cmp    %r15d,%eax
jge    12c1 <main+0x151>
mov    %eax,%r13d
mov    %r15d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%r13,8),%rbp
mov    0x0(%rbp),%al
test   %al,%al
je     12d2 <main+0x162>
add    $0x1,%rbp
xorpd  %xmm0,%xmm0
xor    %r15d,%r15d
jmp    124c <main+0xdc>
nopl   0x0(%rax)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     1290 <main+0x120>
movsbq %al,%rcx
mov    -0xc0(%rsp,%rcx,4),%edx
cmp    $0x3ff,%edx
je     1240 <main+0xd0>
movsbl %al,%eax
add    $0xffffffd0,%eax
movsbl %al,%edi
mov    %rbx,%rsi
movsd  %xmm0,0x20(%rsp)
call   1080 <adc_to_temperature@plt>
movsd  0x20(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%r15d
jmp    1240 <main+0xd0>
xchg   %ax,%ax
ucomisd 0xd68(%rip),%xmm0
jne    129c <main+0x12c>
jnp    12d2 <main+0x162>
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
lea    0xdaf(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r12,%r13
jne    1220 <main+0xb0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xd64(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
jmp    12e2 <main+0x172>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [24 x i8] c"%x %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 = [3 x i8] c"-c\00"
@.str.3 = [24 x i8] c"No sensor values found\0A\00"
@.str.4 = [6 x i8] c"%.2f\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 i8*
%9 = alloca double
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = call i32 (...) @usage()
%16 = load i32, i32* @EXIT_SUCCESS
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
store i8* null, i8** %8
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 0
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 1
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 2
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 3
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 4
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 5
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 6
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 7
%27 = call i32 @scanf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %19, i32* %20, i32* %21, i32* %22, i32* %23, i32* %24, i32* %25, i32* %26)
%28 = icmp slt i32 %27, 4
br i1 %28, label %29, label %34
29: ; preds = %18
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %18
store i32 1, i32* %6
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
store i8* %43, i8** %8
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 2
store i32 %45, i32* %6
br label %46
46: ; preds = %40, %34
br label %47
47: ; preds = %111, %46
%48 = load i32, i32* %6
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %114
51: ; preds = %47
store double 0.000000e+00, double* %9
store i32 0, i32* %10
%52 = load i8**, i8*** %5
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
store i8* %56, i8** %11
br label %57
57: ; preds = %95, %51
%58 = load i8*, i8** %11
%59 = load i8, i8* %58
%60 = icmp ne i8 %59, 0
br i1 %60, label %61, label %96
61: ; preds = %57
%62 = load i8*, i8** %11
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = sub nsw i32 %64, 48
%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 = icmp ne i32 %68, 1023
br i1 %69, label %70, label %92
70: ; preds = %61
%71 = load i8*, i8** %11
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = sub nsw i32 %73, 48
%75 = trunc i32 %74 to i8
%76 = load i8*, i8** %8
%77 = load i8*, i8** %11
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = sub nsw i32 %79, 48
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [8 x i32], [8 x i32]* %7, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = call i64 @adc_to_temperature(i8 signext %75, i8* %76, i32 %83)
%85 = sitofp i64 %84 to double
%86 = load double, double* %9
%87 = fadd double %86, %85
store double %87, double* %9
%88 = load i8*, i8** %11
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %11
%90 = load i32, i32* %10
%91 = add nsw i32 %90, 1
store i32 %91, i32* %10
br label %95
92: ; preds = %61
%93 = load i8*, i8** %11
%94 = getelementptr inbounds i8, i8* %93, i32 1
store i8* %94, i8** %11
br label %95
95: ; preds = %92, %70
br label %57
96: ; preds = %57
%97 = load double, double* %9
%98 = fcmp oeq double %97, 0.000000e+00
br i1 %98, label %99, label %104
99: ; preds = %96
%100 = load i32, i32* @stderr
%101 = call i32 @fprintf(i32 %100, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %96
%105 = load i32, i32* %10
%106 = sitofp i32 %105 to double
%107 = load double, double* %9
%108 = fdiv double %107, %106
store double %108, double* %9
%109 = load double, double* %9
%110 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %109)
br label %111
111: ; preds = %104
%112 = load i32, i32* %6
%113 = add nsw i32 %112, 1
store i32 %113, i32* %6
br label %47
114: ; preds = %47
ret i32 0
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [24 x i8] c"%x %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 = [3 x i8] c"-c\00"
@.str.3 = [24 x i8] c"No sensor values found\0A\00"
@.str.4 = [6 x i8] c"%.2f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = icmp eq i32 %0, 1
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 ([24 x i8], [24 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 i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
br label %34
34: ; preds = %31, %26
%35 = phi i32 [ 3, %31 ], [ 1, %26 ]
%36 = phi i8* [ %33, %31 ], [ null, %26 ]
%37 = icmp slt i32 %35, %0
br i1 %37, label %38, label %83
38: ; preds = %34
%39 = zext i32 %35 to i64
%40 = zext i32 %0 to i64
br label %41
41: ; preds = %38, %77
%42 = phi i64 [ %39, %38 ], [ %81, %77 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %72, label %47
47: ; preds = %41, %64
%48 = phi i8 [ %68, %64 ], [ %45, %41 ]
%49 = phi i8* [ %67, %64 ], [ %44, %41 ]
%50 = phi i32 [ %66, %64 ], [ 0, %41 ]
%51 = phi double [ %65, %64 ], [ 0.000000e+00, %41 ]
%52 = sext i8 %48 to i32
%53 = add nsw i32 %52, -48
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 1023
br i1 %57, label %64, label %58
58: ; preds = %47
%59 = trunc i32 %53 to i8
%60 = call i64 @adc_to_temperature(i8 signext %59, i8* %36, i32 %56)
%61 = sitofp i64 %60 to double
%62 = fadd double %51, %61
%63 = add nsw i32 %50, 1
br label %64
64: ; preds = %47, %58
%65 = phi double [ %62, %58 ], [ %51, %47 ]
%66 = phi i32 [ %63, %58 ], [ %50, %47 ]
%67 = getelementptr inbounds i8, i8* %49, i64 1
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, 0
br i1 %69, label %70, label %47
70: ; preds = %64
%71 = fcmp oeq double %65, 0.000000e+00
br i1 %71, label %72, label %77
72: ; preds = %41, %70
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %70
%78 = sitofp i32 %66 to double
%79 = fdiv double %65, %78
%80 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %79)
%81 = add nuw nsw i64 %42, 1
%82 = icmp eq i64 %81, %40
br i1 %82, label %83, label %41
83: ; preds = %77, %34
ret i32 0
}