#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 thetaE(float, float);
float get_temp_for_thte(float thte, float pres) {
  float tgnu = 293.16;
  float tgnup, tenu, tenup, cor;
  int x;
  for (x = 1; x < 100; x++) {
    tgnup = tgnu + 1.0;
    tenu = thetaE(pres, tgnu);
    tenup = thetaE(pres, tgnup);
    cor = (thte - tenu) / (tenup - tenu);
    tgnu = tgnu + cor;
    if ((cor < .01) && ((-1 * cor) < .01)) {
      return tgnu;
    }
  }
  return 9999.9;
}


x86 assembly (clang, -O0):
<get_temp_for_thte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  0xed6(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    1212 <get_temp_for_thte+0x102>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec7(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1030 <thetaE@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1030 <thetaE@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
subss  -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe4d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ff <get_temp_for_thte+0xef>
movss  0xe33(%rip),%xmm0
mulss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ff <get_temp_for_thte+0xef>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    121f <get_temp_for_thte+0x10f>
jmp    1204 <get_temp_for_thte+0xf4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <get_temp_for_thte+0x26>
movss  0xdea(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_temp_for_thte>:
push   %rbx
sub    $0x20,%rsp
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x10(%rsp)
movss  0xed7(%rip),%xmm1
mov    $0x63,%ebx
jmp    1139 <get_temp_for_thte+0x29>
add    $0xffffffff,%ebx
je     11c3 <get_temp_for_thte+0xb3>
movss  %xmm1,0x1c(%rsp)
movaps %xmm1,%xmm0
addss  0xeba(%rip),%xmm0
movss  %xmm0,0x18(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <thetaE@plt>
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
call   1030 <thetaE@plt>
movsd  0xe96(%rip),%xmm3
movss  0x1c(%rsp),%xmm1
movss  0x10(%rsp),%xmm2
movss  0x14(%rsp),%xmm4
subss  %xmm4,%xmm2
subss  %xmm4,%xmm0
divss  %xmm0,%xmm2
addss  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd %xmm0,%xmm3
jbe    1130 <get_temp_for_thte+0x20>
xorps  0xe70(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd %xmm0,%xmm3
jbe    1130 <get_temp_for_thte+0x20>
jmp    11cb <get_temp_for_thte+0xbb>
movss  0xe3d(%rip),%xmm1
movaps %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @get_temp_for_thte(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i32
store float %0, float* %4
store float %1, float* %5
store float 0x4072528F60000000, float* %6
store i32 1, i32* %11
br label %12
12: ; preds = %47, %2
%13 = load i32, i32* %11
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %50
15: ; preds = %12
%16 = load float, float* %6
%17 = fpext float %16 to double
%18 = fadd double %17, 1.000000e+00
%19 = fptrunc double %18 to float
store float %19, float* %7
%20 = load float, float* %5
%21 = load float, float* %6
%22 = call float @thetaE(float %20, float %21)
store float %22, float* %8
%23 = load float, float* %5
%24 = load float, float* %7
%25 = call float @thetaE(float %23, float %24)
store float %25, float* %9
%26 = load float, float* %4
%27 = load float, float* %8
%28 = fsub float %26, %27
%29 = load float, float* %9
%30 = load float, float* %8
%31 = fsub float %29, %30
%32 = fdiv float %28, %31
store float %32, float* %10
%33 = load float, float* %6
%34 = load float, float* %10
%35 = fadd float %33, %34
store float %35, float* %6
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fcmp olt double %37, 1.000000e-02
br i1 %38, label %39, label %46
39: ; preds = %15
%40 = load float, float* %10
%41 = fmul float -1.000000e+00, %40
%42 = fpext float %41 to double
%43 = fcmp olt double %42, 1.000000e-02
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load float, float* %6
store float %45, float* %3
br label %51
46: ; preds = %39, %15
br label %47
47: ; preds = %46
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
store i32 %49, i32* %11
br label %12
50: ; preds = %12
store float 0x40C387F340000000, float* %3
br label %51
51: ; preds = %50, %44
%52 = load float, float* %3
ret float %52
}

LLVM IR (-O2):
define float @get_temp_for_thte(float %0, float %1) {
br label %3
3: ; preds = %2, %19
%4 = phi i32 [ 1, %2 ], [ %20, %19 ]
%5 = phi float [ 0x4072528F60000000, %2 ], [ %12, %19 ]
%6 = fadd float %5, 1.000000e+00
%7 = tail call float @thetaE(float %1, float %5)
%8 = tail call float @thetaE(float %1, float %6)
%9 = fsub float %0, %7
%10 = fsub float %8, %7
%11 = fdiv float %9, %10
%12 = fadd float %5, %11
%13 = fpext float %11 to double
%14 = fcmp olt double %13, 1.000000e-02
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = fneg float %11
%17 = fpext float %16 to double
%18 = fcmp olt double %17, 1.000000e-02
br i1 %18, label %22, label %19
19: ; preds = %3, %15
%20 = add nuw nsw i32 %4, 1
%21 = icmp eq i32 %20, 100
br i1 %21, label %22, label %3
22: ; preds = %19, %15
%23 = phi float [ %12, %15 ], [ 0x40C387F340000000, %19 ]
ret float %23
}