#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 scalar_t__ uint16_t;

/* Variables and functions */
float App_Calculate_Thermocouple_Temperature(uint16_t adc_counts) {
  static float filtered_deg_f = 0;
  static uint8_t initialized = 0;
  float voltage = (float)adc_counts * 5.0 / 1024.0;
  float deg_c = (voltage - 1.25) / .005;
  float deg_f = deg_c * 1.8 + 32.0;
  if (!initialized) {
    filtered_deg_f = deg_f;
    initialized = (!0);
  }
  filtered_deg_f = (0.99 * filtered_deg_f) + ((1.0 - 0.99) * deg_f);
  return filtered_deg_f;
}


x86 assembly (clang, -O0):
<App_Calculate_Thermocouple_Temperature>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cvtsi2ssq -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xf0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xefa(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xec0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe92(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
cmpl   $0x0,0x2e9a(%rip)
jne    11ab <App_Calculate_Thermocouple_Temperature+0xab>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,0x2e83(%rip)
movl   $0x1,0x2e7d(%rip)
movss  0x2e71(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe70(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe5c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x2e3c(%rip)
movss  0x2e34(%rip),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<App_Calculate_Thermocouple_Temperature>:
cvtsi2ss %rdi,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xeef(%rip),%xmm0
mulsd  0xeef(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xee7(%rip),%xmm0
divsd  0xee7(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xedf(%rip),%xmm0
addsd  0xedf(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cmpb   $0x1,0x2ed4(%rip)
jne    1160 <App_Calculate_Thermocouple_Temperature+0x60>
movss  0x2ec6(%rip),%xmm1
jmp    116a <App_Calculate_Thermocouple_Temperature+0x6a>
movb   $0x1,0x2ec1(%rip)
movaps %xmm0,%xmm1
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  0xeb6(%rip),%xmm0
mulsd  0xeb6(%rip),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x2e8f(%rip)
ret

LLVM IR (-O0):
@App_Calculate_Thermocouple_Temperature.filtered_deg_f = internal global float 0.000000e+00
@App_Calculate_Thermocouple_Temperature.initialized = internal global i32 0
define float @App_Calculate_Thermocouple_Temperature(i64 %0) {
%2 = alloca i64
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = sitofp i64 %6 to float
%8 = fpext float %7 to double
%9 = fmul double %8, 5.000000e+00
%10 = fdiv double %9, 1.024000e+03
%11 = fptrunc double %10 to float
store float %11, float* %3
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fsub double %13, 1.250000e+00
%15 = fdiv double %14, 5.000000e-03
%16 = fptrunc double %15 to float
store float %16, float* %4
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = call double @llvm.fmuladd.f64(double %18, double 1.800000e+00, double 3.200000e+01)
%20 = fptrunc double %19 to float
store float %20, float* %5
%21 = load i32, i32* @App_Calculate_Thermocouple_Temperature.initialized
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %1
%24 = load float, float* %5
store float %24, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
store i32 1, i32* @App_Calculate_Thermocouple_Temperature.initialized
br label %25
25: ; preds = %23, %1
%26 = load float, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
%27 = fpext float %26 to double
%28 = load float, float* %5
%29 = fpext float %28 to double
%30 = fmul double 0x3F847AE147AE1480, %29
%31 = call double @llvm.fmuladd.f64(double 0x3FEFAE147AE147AE, double %27, double %30)
%32 = fptrunc double %31 to float
store float %32, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
%33 = load float, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
ret float %33
}

LLVM IR (-O2):
@App_Calculate_Thermocouple_Temperature.filtered_deg_f = internal unnamed_addr global float 0.000000e+00
@App_Calculate_Thermocouple_Temperature.initialized = internal unnamed_addr global i1 false
define float @App_Calculate_Thermocouple_Temperature(i64 %0) {
%2 = sitofp i64 %0 to float
%3 = fpext float %2 to double
%4 = fmul double %3, 5.000000e+00
%5 = fmul double %4, 0x3F50000000000000
%6 = fptrunc double %5 to float
%7 = fpext float %6 to double
%8 = fadd double %7, -1.250000e+00
%9 = fdiv double %8, 5.000000e-03
%10 = fptrunc double %9 to float
%11 = fpext float %10 to double
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.800000e+00, double 3.200000e+01)
%13 = fptrunc double %12 to float
%14 = load i1, i1* @App_Calculate_Thermocouple_Temperature.initialized
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = load float, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
br label %18
17: ; preds = %1
store i1 true, i1* @App_Calculate_Thermocouple_Temperature.initialized
br label %18
18: ; preds = %15, %17
%19 = phi float [ %16, %15 ], [ %13, %17 ]
%20 = fpext float %19 to double
%21 = fpext float %13 to double
%22 = fmul double %21, 0x3F847AE147AE1480
%23 = tail call double @llvm.fmuladd.f64(double %20, double 0x3FEFAE147AE147AE, double %22)
%24 = fptrunc double %23 to float
store float %24, float* @App_Calculate_Thermocouple_Temperature.filtered_deg_f
ret float %24
}