#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 uint8_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ temp_data;
typedef int mode_t;

/* Variables and functions */
int O_CREAT;
int O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ log(double);
int /*<<< orphan*/ memset(char *, char, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, int *, int);
int conv_adc_temp(char *input_file, char *output_file) {
  printf("\n");
  int in_fd = 0;
  int out_fd = 0;
  char in_fn[(15) + 1];
  char out_fn[(21) + 1];
  mode_t in_mode = S_IRUSR | S_IRGRP | S_IROTH;
  mode_t out_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  int set_index = 0;
  uint8_t raw_byte_data[(4)][2];
  uint8_t comma_space[2] = {0x00, 0x00};
  uint16_t word_data[(4)] = {0x0000, 0x0000, 0x0000, 0x0000};
  float volt_data[(4)] = {0.00, 0.00, 0.00, 0.00};
  float temp_data[(4)] = {0.00, 0.00, 0.00, 0.00};
  float therm_res = 0.0;
  memset(in_fn, '\0', (15) + 1);
  memset(out_fn, '\0', (21) + 1);
  snprintf(in_fn, (15) + 1, "%s", input_file);
  snprintf(out_fn, (21) + 1, "%s", output_file);
  if ((in_fd = open(in_fn, O_RDONLY, in_mode)) < 0) {
    fprintf(stderr, "Couldn't open input file [%s].\n", in_fn);
    exit(1);
  }
  for (set_index = 0; set_index < (4); set_index++) {
    if (set_index == 0) {
      read(in_fd, raw_byte_data[set_index], 1);
      fprintf(stderr, "Skipping one byte in first temp value!\n");
      printf("Raw Byte Read: \n");
      printf("Byte 0 (MSB): [%.2X]\n", raw_byte_data[set_index][0]);
    } else {
      read(in_fd, raw_byte_data[set_index], 2);
      printf("Raw Two Bytes Read: \n");
      printf("Byte 0 (MSB): [%.2X]\n", raw_byte_data[set_index][0]);
      printf("Byte 1 (LSB): [%.2X]\n", raw_byte_data[set_index][1]);
    }
    printf("Hint: [0x7F] often means the thermistor was D/C'd.\n");
    printf("\n");
    read(in_fd, comma_space, 2);
    if ((comma_space[0] != 0x2C) || (comma_space[1] != 0x20)) {
      fprintf(stderr, "Failed comma/space validation check.\n");
      fprintf(stderr, "Raw Two Bytes Read: \n");
      fprintf(stderr, "Byte 0 (Expecting Comma [2C]): [%.2X]\n",
              comma_space[0]);
      fprintf(stderr, "Byte 1 (Expecting Space [20]): [%.2X]\n",
              comma_space[1]);
    } else {
      word_data[set_index] =
          (uint16_t)((uint16_t)(raw_byte_data[set_index][0] << 8) +
                     (uint16_t)raw_byte_data[set_index][1]);
      printf("ADC Word Reg [%d]: [%.4X]\n", set_index, word_data[set_index]);
    }
  }
  close(in_fd);
  for (set_index = 0; set_index < (4); set_index++) {
    volt_data[set_index] = word_data[set_index] * 4.096 / 32767.0;
    printf("Thermistor %d Voltage = %f Volts\n", set_index,
           volt_data[set_index]);
    therm_res = (300000) / ((((4096) - 1) / volt_data[set_index]) - 1);
    printf("Thermistor %d Calculated Resistance = %.6f Ohms\n", set_index,
           therm_res);
    temp_data[set_index] = therm_res / (10000);
    temp_data[set_index] = (float)log((double)temp_data[set_index]);
    temp_data[set_index] = temp_data[set_index] / (3892);
    temp_data[set_index] = temp_data[set_index] + (1.0 / ((25) + (273.15)));
    temp_data[set_index] = 1.0 / temp_data[set_index];
    temp_data[set_index] = temp_data[set_index] - (273.15);
    printf("Thermistor %d Calculated Temperature = %f degrees Celsius\n\n",
           set_index, temp_data[set_index]);
  }
  if ((out_fd = open(out_fn, O_WRONLY | O_CREAT | O_TRUNC, out_mode)) < 0) {
    fprintf(stderr, "Couldn't open output file [%s].\n", out_fn);
    exit(1);
  }
  for (set_index = 0; set_index < (4); set_index++) {
    write(out_fd, (uint8_t *)&temp_data[set_index],
          sizeof(temp_data[set_index]));
    comma_space[0] = 0x2C;
    comma_space[1] = 0x20;
    write(out_fd, comma_space, 2);
  }
  close(out_fd);
  return (0);
}


x86 assembly (clang, -O0):
<conv_adc_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x1070(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    0x2dd9(%rip),%rcx
or     (%rcx),%eax
mov    0x2dc8(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x54(%rbp)
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    0x2dd3(%rip),%rcx
or     (%rcx),%eax
mov    0x2db2(%rip),%rcx
or     (%rcx),%eax
mov    0x2da1(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
lea    -0x88(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc4(%rbp)
ff
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x16,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x10,%esi
lea    0xd96(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x16,%esi
lea    0xd7d(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2d09(%rip),%rax
mov    (%rax),%esi
mov    -0x54(%rbp),%edx
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    130a <conv_adc_temp+0x16a>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xd46(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    14db <conv_adc_temp+0x33b>
cmpl   $0x0,-0x5c(%rbp)
jne    1381 <conv_adc_temp+0x1e1>
mov    -0x14(%rbp),%edi
movslq -0x5c(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x5c(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%esi
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d7 <conv_adc_temp+0x237>
mov    -0x14(%rbp),%edi
movslq -0x5c(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x2,%edx
call   1080 <read@plt>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x5c(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%esi
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x5c(%rbp),%rax
mov    -0x7c(%rbp,%rax,8),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x88(%rbp),%rsi
mov    $0x2,%edx
call   1080 <read@plt>
cmpl   $0x2c,-0x88(%rbp)
jne    1421 <conv_adc_temp+0x281>
cmpl   $0x20,-0x84(%rbp)
je     148e <conv_adc_temp+0x2ee>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
lea    0xc66(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b6a(%rip),%rax
mov    (%rax),%edi
mov    -0x88(%rbp),%edx
lea    0xccf(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
mov    -0x84(%rbp),%edx
lea    0xcd9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    14c8 <conv_adc_temp+0x328>
movslq -0x5c(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%ecx
shl    $0x8,%ecx
movslq -0x5c(%rbp),%rax
add    -0x7c(%rbp,%rax,8),%ecx
movslq -0x5c(%rbp),%rax
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x5c(%rbp),%esi
movslq -0x5c(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edx
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14cd <conv_adc_temp+0x32d>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1311 <conv_adc_temp+0x171>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    16c7 <conv_adc_temp+0x527>
movslq -0x5c(%rbp),%rax
cvtsi2sdl -0xa0(%rbp,%rax,4),%xmm0
ff ff
movsd  0xb17(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xb03(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xb0(%rbp,%rax,4)
ff ff
mov    -0x5c(%rbp),%esi
movslq -0x5c(%rbp),%rax
movss  -0xb0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xc58(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movslq -0x5c(%rbp),%rax
movss  0xae0(%rip),%xmm1
divss  -0xb0(%rbp,%rax,4),%xmm1
ff ff
movss  0xacb(%rip),%xmm0
subss  %xmm0,%xmm1
movss  0xabb(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xc4(%rbp)
ff
mov    -0x5c(%rbp),%esi
movss  -0xc4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xc28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0xc4(%rbp),%xmm0
ff
movss  0xa7e(%rip),%xmm1
divss  %xmm1,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
call   10b0 <log@plt>
cvtsi2ss %rax,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
movss  0xa2c(%rip),%xmm1
divss  %xmm1,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  0x9ea(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0x9b4(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  0x97e(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x5c(%rbp),%rax
movss  %xmm0,-0xc0(%rbp,%rax,4)
ff ff
mov    -0x5c(%rbp),%esi
movslq -0x5c(%rbp),%rax
movss  -0xc0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xb3e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    14ea <conv_adc_temp+0x34a>
lea    -0x50(%rbp),%rdi
mov    0x28c6(%rip),%rax
mov    (%rax),%esi
mov    0x291d(%rip),%rax
or     (%rax),%esi
mov    0x290c(%rip),%rax
or     (%rax),%esi
mov    -0x58(%rbp),%edx
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    171f <conv_adc_temp+0x57f>
mov    0x28bf(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rdx
lea    0xb1e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1785 <conv_adc_temp+0x5e5>
mov    -0x18(%rbp),%edi
movslq -0x5c(%rbp),%rax
lea    -0xc0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
movl   $0x2c,-0x88(%rbp)
movl   $0x20,-0x84(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x88(%rbp),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1726 <conv_adc_temp+0x586>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_adc_temp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2dc0(%rip),%rax
mov    0x2dc9(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
mov    0x2db6(%rip),%rax
or     (%rax),%ebp
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
or     %ebp,%eax
mov    %eax,0x1c(%rsp)
movq   $0x0,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x80(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
lea    0x60(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x16,%edx
call   1080 <memset@plt>
lea    0xde5(%rip),%rbx
mov    %r12,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1070 <snprintf@plt>
mov    %r13,%rdi
mov    $0x16,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <snprintf@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
mov    %ebp,%edx
call   10c0 <open@plt>
test   %eax,%eax
js     16bc <conv_adc_temp+0x4fc>
mov    %eax,%ebp
lea    0x40(%rsp),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xf87(%rip),%rdi
call   1040 <puts@plt>
mov    0x40(%rsp),%ebx
lea    0xdae(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf34(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   10a0 <read@plt>
mov    0x10(%rsp),%r15d
mov    0x14(%rsp),%r12d
cmp    $0x2c,%r15d
mov    %ebp,0xc(%rsp)
jne    1342 <conv_adc_temp+0x182>
cmp    $0x20,%r12d
jne    1342 <conv_adc_temp+0x182>
shl    $0x8,%ebx
add    0x44(%rsp),%ebx
mov    %ebx,0x30(%rsp)
lea    0xe08(%rip),%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,0x18(%rsp)
jmp    1397 <conv_adc_temp+0x1d7>
movl   $0x0,0x18(%rsp)
mov    0x2c6f(%rip),%rbx
mov    (%rbx),%edi
lea    0xd6b(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd2f(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd71(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd85(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1402 <conv_adc_temp+0x242>
xchg   %ax,%ax
mov    0x2c19(%rip),%r15
mov    (%r15),%edi
lea    0xd14(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%r15),%edi
lea    0xcd7(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%r15),%edi
lea    0xd18(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%r15),%edi
lea    0xd2c(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
add    $0x1,%rbp
add    $0x8,%r14
cmp    $0x3,%rbp
je     14bb <conv_adc_temp+0x2fb>
lea    0x48(%rsp),%rax
lea    (%rax,%r14,1),%rsi
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
mov    $0x2,%edx
call   10a0 <read@plt>
lea    0xde2(%rip),%rdi
call   1040 <puts@plt>
mov    0x48(%rsp,%rbp,8),%r15d
lea    0xc50(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4c(%rsp,%rbp,8),%r13d
lea    0xc66(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdbf(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
lea    0x10(%rsp),%rsi
mov    $0x2,%edx
call   10a0 <read@plt>
mov    0x10(%rsp),%ebx
mov    0x14(%rsp),%r12d
cmp    $0x2c,%ebx
jne    13a0 <conv_adc_temp+0x1e0>
cmp    $0x20,%r12d
jne    13a0 <conv_adc_temp+0x1e0>
shl    $0x8,%r15d
add    %r13d,%r15d
mov    %r15d,0x34(%rsp,%rbp,4)
lea    0x1(%rbp),%esi
lea    0xc8d(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13f0 <conv_adc_temp+0x230>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
xor    %ebx,%ebx
lea    0xc87(%rip),%r12
lea    0xca2(%rip),%r15
lea    0xccc(%rip),%rbp
mov    0x18(%rsp),%eax
nop
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xb11(%rip),%xmm0
divsd  0xb11(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0xb07(%rip),%xmm0
divss  0xc(%rsp),%xmm0
addss  0xafd(%rip),%xmm0
movss  0xaf9(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0xc(%rsp),%xmm0
divss  0xad2(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
call   10d0 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xabd(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xa91(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xaa9(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
addsd  0xa7a(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x20(%rsp,%rbx,4)
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1060 <printf@plt>
cmp    $0x3,%rbx
je     15cb <conv_adc_temp+0x40b>
mov    0x34(%rsp,%rbx,4),%eax
add    $0x1,%rbx
jmp    14e0 <conv_adc_temp+0x320>
mov    0x29c6(%rip),%rax
mov    0x2a1f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2a0c(%rip),%rax
or     (%rax),%esi
lea    0x60(%rsp),%rdi
mov    0x1c(%rsp),%edx
call   10c0 <open@plt>
test   %eax,%eax
js     16d6 <conv_adc_temp+0x516>
mov    %eax,%ebx
lea    0x20(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1050 <write@plt>
movabs $0x200000002c,%r14
mov    %r14,0x10(%rsp)
lea    0x10(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1050 <write@plt>
lea    0x24(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <write@plt>
mov    %r14,0x10(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1050 <write@plt>
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <write@plt>
mov    %r14,0x10(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1050 <write@plt>
lea    0x2c(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <write@plt>
mov    %r14,0x10(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1050 <write@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x28fd(%rip),%rax
mov    (%rax),%edi
lea    0x96f(%rip),%rsi
lea    0x80(%rsp),%rdx
jmp    16eb <conv_adc_temp+0x52b>
mov    0x28e3(%rip),%rax
mov    (%rax),%edi
lea    0xafd(%rip),%rsi
lea    0x60(%rsp),%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@S_IRUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Couldn't open input file [%s].\0A\00"
@.str.3 = [40 x i8] c"Skipping one byte in first temp value!\0A\00"
@.str.4 = [17 x i8] c"Raw Byte Read: \0A\00"
@.str.5 = [22 x i8] c"Byte 0 (MSB): [%.2X]\0A\00"
@.str.6 = [22 x i8] c"Raw Two Bytes Read: \0A\00"
@.str.7 = [22 x i8] c"Byte 1 (LSB): [%.2X]\0A\00"
@.str.8 = [52 x i8] c"Hint: [0x7F] often means the thermistor was D/C'd.\0A\00"
@.str.9 = [38 x i8] c"Failed comma/space validation check.\0A\00"
@.str.10 = [39 x i8] c"Byte 0 (Expecting Comma [2C]): [%.2X]\0A\00"
@.str.11 = [39 x i8] c"Byte 1 (Expecting Space [20]): [%.2X]\0A\00"
@.str.12 = [27 x i8] c"ADC Word Reg [%d]: [%.4X]\0A\00"
@.str.13 = [34 x i8] c"Thermistor %d Voltage = %f Volts\0A\00"
@.str.14 = [49 x i8] c"Thermistor %d Calculated Resistance = %.6f Ohms\0A\00"
@.str.15 = [60 x i8] c"Thermistor %d Calculated Temperature = %f degrees Celsius\0A\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.16 = [33 x i8] c"Couldn't open output file [%s].\0A\00"
define i32 @conv_adc_temp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
%8 = alloca [22 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x [2 x i32]]
%13 = alloca [2 x i32]
%14 = alloca [4 x i32]
%15 = alloca [4 x float]
%16 = alloca [4 x float]
%17 = alloca float
store i8* %0, i8** %3
store i8* %1, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
store i32 0, i32* %6
%19 = load i32, i32* @S_IRUSR
%20 = load i32, i32* @S_IRGRP
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IROTH
%23 = or i32 %21, %22
store i32 %23, i32* %9
%24 = load i32, i32* @S_IRUSR
%25 = load i32, i32* @S_IWUSR
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IRGRP
%28 = or i32 %26, %27
%29 = load i32, i32* @S_IROTH
%30 = or i32 %28, %29
store i32 %30, i32* %10
store i32 0, i32* %11
%31 = bitcast [2 x i32]* %13 to i8*
%32 = bitcast [4 x i32]* %14 to i8*
%33 = bitcast [4 x float]* %15 to i8*
%34 = bitcast [4 x float]* %16 to i8*
store float 0.000000e+00, float* %17
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%36 = call i32 @memset(i8* %35, i8 signext 0, i32 16)
%37 = getelementptr inbounds [22 x i8], [22 x i8]* %8, i64 0, i64 0
%38 = call i32 @memset(i8* %37, i8 signext 0, i32 22)
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%40 = load i8*, i8** %3
%41 = call i32 @snprintf(i8* %39, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [22 x i8], [22 x i8]* %8, i64 0, i64 0
%43 = load i8*, i8** %4
%44 = call i32 @snprintf(i8* %42, i32 22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%46 = load i32, i32* @O_RDONLY
%47 = load i32, i32* %9
%48 = call i32 @open(i8* %45, i32 %46, i32 %47)
store i32 %48, i32* %5
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %2
%51 = load i32, i32* @stderr
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %2
store i32 0, i32* %11
br label %56
56: ; preds = %147, %55
%57 = load i32, i32* %11
%58 = icmp slt i32 %57, 4
br i1 %58, label %59, label %150
59: ; preds = %56
%60 = load i32, i32* %11
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %78
62: ; preds = %59
%63 = load i32, i32* %5
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %65
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %66, i64 0, i64 0
%68 = call i32 @read(i32 %63, i32* %67, i32 1)
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%72 = load i32, i32* %11
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %73
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %74, i64 0, i64 0
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %76)
br label %98
78: ; preds = %59
%79 = load i32, i32* %5
%80 = load i32, i32* %11
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %81
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %82, i64 0, i64 0
%84 = call i32 @read(i32 %79, i32* %83, i32 2)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %87
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %88, i64 0, i64 0
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %90)
%92 = load i32, i32* %11
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %93
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %94, i64 0, i64 1
%96 = load i32, i32* %95
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %78, %62
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%101 = load i32, i32* %5
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%103 = call i32 @read(i32 %101, i32* %102, i32 2)
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%105 = load i32, i32* %104
%106 = icmp ne i32 %105, 44
br i1 %106, label %111, label %107
107: ; preds = %98
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%109 = load i32, i32* %108
%110 = icmp ne i32 %109, 32
br i1 %110, label %111, label %124
111: ; preds = %107, %98
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%116 = load i32, i32* @stderr
%117 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%118 = load i32, i32* %117
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %118)
%120 = load i32, i32* @stderr
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%122 = load i32, i32* %121
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i32 %122)
br label %146
124: ; preds = %107
%125 = load i32, i32* %11
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %126
%128 = getelementptr inbounds [2 x i32], [2 x i32]* %127, i64 0, i64 0
%129 = load i32, i32* %128
%130 = shl i32 %129, 8
%131 = load i32, i32* %11
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %12, i64 0, i64 %132
%134 = getelementptr inbounds [2 x i32], [2 x i32]* %133, i64 0, i64 1
%135 = load i32, i32* %134
%136 = add nsw i32 %130, %135
%137 = load i32, i32* %11
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %138
store i32 %136, i32* %139
%140 = load i32, i32* %11
%141 = load i32, i32* %11
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %142
%144 = load i32, i32* %143
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i32 %140, i32 %144)
br label %146
146: ; preds = %124, %111
br label %147
147: ; preds = %146
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %11
br label %56
150: ; preds = %56
%151 = load i32, i32* %5
%152 = call i32 @close(i32 %151)
store i32 0, i32* %11
br label %153
153: ; preds = %246, %150
%154 = load i32, i32* %11
%155 = icmp slt i32 %154, 4
br i1 %155, label %156, label %249
156: ; preds = %153
%157 = load i32, i32* %11
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %158
%160 = load i32, i32* %159
%161 = sitofp i32 %160 to double
%162 = fmul double %161, 4.096000e+00
%163 = fdiv double %162, 3.276700e+04
%164 = fptrunc double %163 to float
%165 = load i32, i32* %11
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 %166
store float %164, float* %167
%168 = load i32, i32* %11
%169 = load i32, i32* %11
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 %170
%172 = load float, float* %171
%173 = fpext float %172 to double
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %168, double %173)
%175 = load i32, i32* %11
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 %176
%178 = load float, float* %177
%179 = fdiv float 4.095000e+03, %178
%180 = fsub float %179, 1.000000e+00
%181 = fdiv float 3.000000e+05, %180
store float %181, float* %17
%182 = load i32, i32* %11
%183 = load float, float* %17
%184 = fpext float %183 to double
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 %182, double %184)
%186 = load float, float* %17
%187 = fdiv float %186, 1.000000e+04
%188 = load i32, i32* %11
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %189
store float %187, float* %190
%191 = load i32, i32* %11
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %192
%194 = load float, float* %193
%195 = fpext float %194 to double
%196 = call i64 @log(double %195)
%197 = sitofp i64 %196 to float
%198 = load i32, i32* %11
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %199
store float %197, float* %200
%201 = load i32, i32* %11
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %202
%204 = load float, float* %203
%205 = fdiv float %204, 3.892000e+03
%206 = load i32, i32* %11
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %207
store float %205, float* %208
%209 = load i32, i32* %11
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %210
%212 = load float, float* %211
%213 = fpext float %212 to double
%214 = fadd double %213, 0x3F6B79E1DCB5DB83
%215 = fptrunc double %214 to float
%216 = load i32, i32* %11
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %217
store float %215, float* %218
%219 = load i32, i32* %11
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %220
%222 = load float, float* %221
%223 = fpext float %222 to double
%224 = fdiv double 1.000000e+00, %223
%225 = fptrunc double %224 to float
%226 = load i32, i32* %11
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %227
store float %225, float* %228
%229 = load i32, i32* %11
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %230
%232 = load float, float* %231
%233 = fpext float %232 to double
%234 = fsub double %233, 2.731500e+02
%235 = fptrunc double %234 to float
%236 = load i32, i32* %11
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %237
store float %235, float* %238
%239 = load i32, i32* %11
%240 = load i32, i32* %11
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %241
%243 = load float, float* %242
%244 = fpext float %243 to double
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.15, i64 0, i64 0), i32 %239, double %244)
br label %246
246: ; preds = %156
%247 = load i32, i32* %11
%248 = add nsw i32 %247, 1
store i32 %248, i32* %11
br label %153
249: ; preds = %153
%250 = getelementptr inbounds [22 x i8], [22 x i8]* %8, i64 0, i64 0
%251 = load i32, i32* @O_WRONLY
%252 = load i32, i32* @O_CREAT
%253 = or i32 %251, %252
%254 = load i32, i32* @O_TRUNC
%255 = or i32 %253, %254
%256 = load i32, i32* %10
%257 = call i32 @open(i8* %250, i32 %255, i32 %256)
store i32 %257, i32* %6
%258 = icmp slt i32 %257, 0
br i1 %258, label %259, label %264
259: ; preds = %249
%260 = load i32, i32* @stderr
%261 = getelementptr inbounds [22 x i8], [22 x i8]* %8, i64 0, i64 0
%262 = call i32 (i32, i8*, ...) @fprintf(i32 %260, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0), i8* %261)
%263 = call i32 @exit(i32 1)
unreachable
264: ; preds = %249
store i32 0, i32* %11
br label %265
265: ; preds = %280, %264
%266 = load i32, i32* %11
%267 = icmp slt i32 %266, 4
br i1 %267, label %268, label %283
268: ; preds = %265
%269 = load i32, i32* %6
%270 = load i32, i32* %11
%271 = sext i32 %270 to i64
%272 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 %271
%273 = bitcast float* %272 to i32*
%274 = call i32 @write(i32 %269, i32* %273, i32 4)
%275 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
store i32 44, i32* %275
%276 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
store i32 32, i32* %276
%277 = load i32, i32* %6
%278 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%279 = call i32 @write(i32 %277, i32* %278, i32 2)
br label %280
280: ; preds = %268
%281 = load i32, i32* %11
%282 = add nsw i32 %281, 1
store i32 %282, i32* %11
br label %265
283: ; preds = %265
%284 = load i32, i32* %6
%285 = call i32 @close(i32 %284)
ret i32 0
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Couldn't open input file [%s].\0A\00"
@.str.3 = [40 x i8] c"Skipping one byte in first temp value!\0A\00"
@.str.5 = [22 x i8] c"Byte 0 (MSB): [%.2X]\0A\00"
@.str.6 = [22 x i8] c"Raw Two Bytes Read: \0A\00"
@.str.7 = [22 x i8] c"Byte 1 (LSB): [%.2X]\0A\00"
@.str.9 = [38 x i8] c"Failed comma/space validation check.\0A\00"
@.str.10 = [39 x i8] c"Byte 0 (Expecting Comma [2C]): [%.2X]\0A\00"
@.str.11 = [39 x i8] c"Byte 1 (Expecting Space [20]): [%.2X]\0A\00"
@.str.12 = [27 x i8] c"ADC Word Reg [%d]: [%.4X]\0A\00"
@.str.13 = [34 x i8] c"Thermistor %d Voltage = %f Volts\0A\00"
@.str.14 = [49 x i8] c"Thermistor %d Calculated Resistance = %.6f Ohms\0A\00"
@.str.15 = [60 x i8] c"Thermistor %d Calculated Temperature = %f degrees Celsius\0A\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.16 = [33 x i8] c"Couldn't open output file [%s].\0A\00"
@str = [21 x i8] c"Raw Two Bytes Read: \00"
@str.17 = [51 x i8] c"Hint: [0x7F] often means the thermistor was D/C'd.\00"
@str.18 = [16 x i8] c"Raw Byte Read: \00"
define i32 @conv_adc_temp(i8* %0, i8* %1) {
%3 = alloca [16 x i8]
%4 = alloca [22 x i8]
%5 = alloca [4 x [2 x i32]]
%6 = alloca i64
%7 = alloca [4 x i32]
%8 = alloca [4 x float]
%9 = tail call i32 @putchar(i32 10)
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* @S_IRUSR
%13 = load i32, i32* @S_IRGRP
%14 = or i32 %13, %12
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IWUSR
%18 = or i32 %16, %17
%19 = bitcast [4 x [2 x i32]]* %5 to i8*
%20 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%21 = bitcast [4 x i32]* %7 to i8*
%22 = bitcast [4 x float]* %8 to i8*
%23 = call i32 @memset(i8* %10, i8 signext 0, i32 16)
%24 = call i32 @memset(i8* %11, i8 signext 0, i32 22)
%25 = call i32 @snprintf(i8* %10, i32 16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%26 = call i32 @snprintf(i8* %11, i32 22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %10, i32 %27, i32 %16)
%29 = icmp slt i32 %28, 0
br i1 %29, label %67, label %30
30: ; preds = %2
%31 = bitcast i64* %6 to [2 x i32]*
%32 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %5, i64 0, i64 0, i64 0
%33 = bitcast i64* %6 to i32*
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %31, i64 0, i64 1
%35 = call i32 @read(i32 %28, i32* %32, i32 1)
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.18, i64 0, i64 0))
%39 = load i32, i32* %32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.17, i64 0, i64 0))
%42 = call i32 @putchar(i32 10)
%43 = call i32 @read(i32 %28, i32* %33, i32 2)
%44 = load i32, i32* %33
%45 = icmp ne i32 %44, 44
%46 = load i32, i32* %34
%47 = icmp ne i32 %46, 32
%48 = select i1 %45, i1 true, i1 %47
br i1 %48, label %56, label %49
49: ; preds = %30
%50 = shl i32 %39, 8
%51 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %5, i64 0, i64 0, i64 1
%52 = load i32, i32* %51
%53 = add nsw i32 %50, %52
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
store i32 %53, i32* %54
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i32 0, i32 %53)
br label %65
56: ; preds = %30
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %44)
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i32 %46)
br label %65
65: ; preds = %49, %56
%66 = phi i32 [ 0, %56 ], [ %53, %49 ]
br label %71
67: ; preds = %2
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %65, %104
%72 = phi i64 [ 1, %65 ], [ %105, %104 ]
%73 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %5, i64 0, i64 %72, i64 0
%74 = call i32 @read(i32 %28, i32* %73, i32 2)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%76 = load i32, i32* %73
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %76)
%78 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %5, i64 0, i64 %72, i64 1
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %79)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.17, i64 0, i64 0))
%82 = call i32 @putchar(i32 10)
%83 = call i32 @read(i32 %28, i32* %33, i32 2)
%84 = load i32, i32* %33
%85 = icmp ne i32 %84, 44
%86 = load i32, i32* %34
%87 = icmp ne i32 %86, 32
%88 = select i1 %85, i1 true, i1 %87
br i1 %88, label %89, label %98
89: ; preds = %71
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), i32 %84)
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), i32 %86)
br label %104
98: ; preds = %71
%99 = shl i32 %76, 8
%100 = add nsw i32 %99, %79
%101 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %72
store i32 %100, i32* %101
%102 = trunc i64 %72 to i32
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i32 %102, i32 %100)
br label %104
104: ; preds = %89, %98
%105 = add nuw nsw i64 %72, 1
%106 = icmp eq i64 %105, 4
br i1 %106, label %107, label %71
107: ; preds = %104
%108 = call i32 @close(i32 %28)
br label %109
109: ; preds = %141, %107
%110 = phi i32 [ %66, %107 ], [ %143, %141 ]
%111 = phi i64 [ 0, %107 ], [ %139, %141 ]
%112 = sitofp i32 %110 to double
%113 = fmul double %112, 4.096000e+00
%114 = fdiv double %113, 3.276700e+04
%115 = fptrunc double %114 to float
%116 = fpext float %115 to double
%117 = trunc i64 %111 to i32
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %117, double %116)
%119 = fdiv float 4.095000e+03, %115
%120 = fadd float %119, -1.000000e+00
%121 = fdiv float 3.000000e+05, %120
%122 = fpext float %121 to double
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 %117, double %122)
%124 = fdiv float %121, 1.000000e+04
%125 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 %111
%126 = fpext float %124 to double
%127 = call i64 @log(double %126)
%128 = sitofp i64 %127 to float
%129 = fdiv float %128, 3.892000e+03
%130 = fpext float %129 to double
%131 = fadd double %130, 0x3F6B79E1DCB5DB83
%132 = fptrunc double %131 to float
%133 = fdiv float 1.000000e+00, %132
%134 = fpext float %133 to double
%135 = fadd double %134, -2.731500e+02
%136 = fptrunc double %135 to float
store float %136, float* %125
%137 = fpext float %136 to double
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.15, i64 0, i64 0), i32 %117, double %137)
%139 = add nuw nsw i64 %111, 1
%140 = icmp eq i64 %139, 4
br i1 %140, label %144, label %141
141: ; preds = %109
%142 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %139
%143 = load i32, i32* %142
br label %109
144: ; preds = %109
%145 = load i32, i32* @O_WRONLY
%146 = load i32, i32* @O_CREAT
%147 = or i32 %146, %145
%148 = load i32, i32* @O_TRUNC
%149 = or i32 %147, %148
%150 = call i32 @open(i8* %11, i32 %149, i32 %18)
%151 = icmp slt i32 %150, 0
br i1 %151, label %169, label %152
152: ; preds = %144
%153 = bitcast [4 x float]* %8 to i32*
%154 = call i32 @write(i32 %150, i32* %153, i32 4)
store i32 44, i32* %33
store i32 32, i32* %34
%155 = call i32 @write(i32 %150, i32* %33, i32 2)
%156 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%157 = bitcast float* %156 to i32*
%158 = call i32 @write(i32 %150, i32* %157, i32 4)
store i32 44, i32* %33
store i32 32, i32* %34
%159 = call i32 @write(i32 %150, i32* %33, i32 2)
%160 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%161 = bitcast float* %160 to i32*
%162 = call i32 @write(i32 %150, i32* %161, i32 4)
store i32 44, i32* %33
store i32 32, i32* %34
%163 = call i32 @write(i32 %150, i32* %33, i32 2)
%164 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%165 = bitcast float* %164 to i32*
%166 = call i32 @write(i32 %150, i32* %165, i32 4)
store i32 44, i32* %33
store i32 32, i32* %34
%167 = call i32 @write(i32 %150, i32* %33, i32 2)
%168 = call i32 @close(i32 %150)
ret i32 0
169: ; preds = %144
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.16, i64 0, i64 0), i8* %11)
%172 = call i32 @exit(i32 1)
unreachable
}