#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 */
float ComputeTemperature(double, double);
int GetRegisterValue(int, unsigned short *);
int TMP006DrvGetTemp(float *pfCurrTemp) {
  unsigned short usVObjectRaw, usTAmbientRaw;
  double dVObject, dTAmbient;
  {
    int iRetVal = (GetRegisterValue(0x0, &usVObjectRaw));
    if (0 != iRetVal)
      return iRetVal;
  };
  {
    int iRetVal = (GetRegisterValue(0x1, &usTAmbientRaw));
    if (0 != iRetVal)
      return iRetVal;
  };
  dVObject = ((short)usVObjectRaw) * 156.25e-9;
  dTAmbient = ((short)usTAmbientRaw) / 128;
  *pfCurrTemp = ComputeTemperature(dVObject, dTAmbient);
  *pfCurrTemp = ((*pfCurrTemp * 9) / 5) + 32;
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
xor    %edi,%edi
lea    -0x12(%rbp),%rsi
call   1040 <GetRegisterValue@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmp    -0x2c(%rbp),%eax
je     1150 <TMP006DrvGetTemp+0x30>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <TMP006DrvGetTemp+0xd3>
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
call   1040 <GetRegisterValue@plt>
mov    %eax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%eax
je     1177 <TMP006DrvGetTemp+0x57>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <TMP006DrvGetTemp+0xd3>
movswl -0x12(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe89(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movswl -0x14(%rbp),%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <ComputeTemperature@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0xe40(%rip),%xmm0
mulss  (%rax),%xmm0
movss  0xe30(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe20(%rip),%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe(%rsp),%rsi
xor    %edi,%edi
call   1040 <GetRegisterValue@plt>
test   %eax,%eax
jne    1197 <TMP006DrvGetTemp+0x77>
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1040 <GetRegisterValue@plt>
test   %eax,%eax
jne    1197 <TMP006DrvGetTemp+0x77>
movswl 0xe(%rsp),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xea4(%rip),%xmm0
movzwl 0xc(%rsp),%eax
lea    0x7f(%rax),%ecx
test   %ax,%ax
cmovns %eax,%ecx
movswl %cx,%eax
sar    $0x7,%eax
cvtsi2sd %eax,%xmm1
call   1030 <ComputeTemperature@plt>
mulss  0xe87(%rip),%xmm0
divss  0xe83(%rip),%xmm0
addss  0xe7f(%rip),%xmm0
movss  %xmm0,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @TMP006DrvGetTemp(float* %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i16
%5 = alloca i16
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store float* %0, float** %3
%10 = call i32 @GetRegisterValue(i32 0, i16* %4)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp ne i32 0, %11
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load i32, i32* %8
store i32 %14, i32* %2
br label %40
15: ; preds = %1
%16 = call i32 @GetRegisterValue(i32 1, i16* %5)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ne i32 0, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* %9
store i32 %20, i32* %2
br label %40
21: ; preds = %15
%22 = load i16, i16* %4
%23 = sext i16 %22 to i32
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 1.562500e-07
store double %25, double* %6
%26 = load i16, i16* %5
%27 = sext i16 %26 to i32
%28 = sdiv i32 %27, 128
%29 = sitofp i32 %28 to double
store double %29, double* %7
%30 = load double, double* %6
%31 = load double, double* %7
%32 = call float @ComputeTemperature(double %30, double %31)
%33 = load float*, float** %3
store float %32, float* %33
%34 = load float*, float** %3
%35 = load float, float* %34
%36 = fmul float %35, 9.000000e+00
%37 = fdiv float %36, 5.000000e+00
%38 = fadd float %37, 3.200000e+01
%39 = load float*, float** %3
store float %38, float* %39
store i32 0, i32* %2
br label %40
40: ; preds = %21, %19, %13
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @TMP006DrvGetTemp(float* nocapture writeonly %0) {
%2 = alloca i16
%3 = alloca i16
%4 = bitcast i16* %2 to i8*
%5 = bitcast i16* %3 to i8*
%6 = call i32 @GetRegisterValue(i32 0, i16* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %1
%9 = call i32 @GetRegisterValue(i32 1, i16* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i16, i16* %2
%13 = sitofp i16 %12 to double
%14 = fmul double %13, 1.562500e-07
%15 = load i16, i16* %3
%16 = sdiv i16 %15, 128
%17 = sitofp i16 %16 to double
%18 = call float @ComputeTemperature(double %14, double %17)
%19 = fmul float %18, 9.000000e+00
%20 = fdiv float %19, 5.000000e+00
%21 = fadd float %20, 3.200000e+01
store float %21, float* %0
br label %22
22: ; preds = %8, %1, %11
%23 = phi i32 [ 0, %11 ], [ %9, %8 ], [ %6, %1 ]
ret i32 %23
}