#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 */
int /*<<< orphan*/ exactO(double, double *, double *, double *, double *,
                          double *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  double z, TT, Tm, qice, qbed, bmelt;
  int scanret;
  const double secpera = 31556926.0;
  const double H0 = 3000.0, B0 = -1000.0;
  printf(
      "Enter z in m (0 <= z < %4.0f for ice and %5.0f < z < 0 for bedrock):  ",
      H0, B0);
  scanret = scanf("%lf", &z);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  exactO(z, &TT, &Tm, &qice, &qbed, &bmelt);
  printf("Results from Test O:\n");
  printf("   T(z)  = %.3f (K)          [absolute temperature]\n", TT);
  printf("   T_m   = %.3f (K)          [pressure-melting (abs.) temperature at "
         "base]\n",
         Tm);
  printf("   q_i   = %f (W m-2)     [upward heat flux in ice]\n", qice);
  printf("   q_bed = %f (W m-2)     [        \"        in bedrock]\n", qbed);
  printf("   bmelt = %.5e (m/year)\n"
         "         = %.5f (mm/year)    [ice-equivalent basal melt rate]\n",
         bmelt * secpera, 1000.0 * bmelt * secpera);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
lea    0xeb3(%rip),%rdi
movsd  0xe8b(%rip),%xmm0
movsd  0xe8b(%rip),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
je     11bb <main+0x8b>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126e <main+0x13e>
movsd  -0x10(%rbp),%xmm0
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1030 <exactO@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xea8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xeca(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xf03(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xf25(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0xdd5(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xdd0(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xdbb(%rip),%xmm2
mulsd  %xmm2,%xmm1
lea    0xf2a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xed5(%rip),%rdi
movsd  0xead(%rip),%xmm0
movsd  0xead(%rip),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xefe(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1233 <main+0xf3>
movsd  0x30(%rsp),%xmm0
lea    0x28(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <exactO@plt>
lea    0x100b(%rip),%rdi
call   1030 <puts@plt>
movsd  0x28(%rsp),%xmm0
lea    0xeb2(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
lea    0xed3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x18(%rsp),%xmm0
lea    0xf0b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
lea    0xf2c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm1
movsd  0xe06(%rip),%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
mulsd  0xdfe(%rip),%xmm1
mulsd  %xmm2,%xmm1
lea    0xf35(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret
lea    0xf8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Enter z in m (0 <= z < %4.0f for ice and %5.0f < z < 0 for bedrock): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [26 x i8] c"... input error; exiting\0A\00"
@.str.3 = [22 x i8] c"Results from Test O:\0A\00"
@.str.4 = [53 x i8] c" T(z) = %.3f (K) [absolute temperature]\0A\00"
@.str.5 = [76 x i8] c" T_m = %.3f (K) [pressure-melting (abs.) temperature at base]\0A\00"
@.str.6 = [53 x i8] c" q_i = %f (W m-2) [upward heat flux in ice]\0A\00"
@.str.7 = [57 x i8] c" q_bed = %f (W m-2) [ \22 in bedrock]\0A\00"
@.str.8 = [88 x i8] c" bmelt = %.5e (m/year)\0A = %.5f (mm/year) [ice-equivalent basal melt rate]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %1
store double 0x417E1853E0000000, double* %9
store double 3.000000e+03, double* %10
store double -1.000000e+03, double* %11
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double 3.000000e+03, double -1.000000e+03)
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %36
18: ; preds = %0
%19 = load double, double* %2
%20 = call i32 @exactO(double %19, double* %3, double* %4, double* %5, double* %6, double* %7)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%22 = load double, double* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = load double, double* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.5, i64 0, i64 0), double %24)
%26 = load double, double* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), double %26)
%28 = load double, double* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), double %28)
%30 = load double, double* %7
%31 = fmul double %30, 0x417E1853E0000000
%32 = load double, double* %7
%33 = fmul double 1.000000e+03, %32
%34 = fmul double %33, 0x417E1853E0000000
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.8, i64 0, i64 0), double %31, double %34)
store i32 0, i32* %1
br label %36
36: ; preds = %18, %16
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [71 x i8] c"Enter z in m (0 <= z < %4.0f for ice and %5.0f < z < 0 for bedrock): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.4 = [53 x i8] c" T(z) = %.3f (K) [absolute temperature]\0A\00"
@.str.5 = [76 x i8] c" T_m = %.3f (K) [pressure-melting (abs.) temperature at base]\0A\00"
@.str.6 = [53 x i8] c" q_i = %f (W m-2) [upward heat flux in ice]\0A\00"
@.str.7 = [57 x i8] c" q_bed = %f (W m-2) [ \22 in bedrock]\0A\00"
@.str.8 = [88 x i8] c" bmelt = %.5e (m/year)\0A = %.5f (mm/year) [ice-equivalent basal melt rate]\0A\00"
@str = [21 x i8] c"Results from Test O:\00"
@str.9 = [25 x i8] c"... input error; exiting\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %1 to i8*
%8 = bitcast double* %2 to i8*
%9 = bitcast double* %3 to i8*
%10 = bitcast double* %4 to i8*
%11 = bitcast double* %5 to i8*
%12 = bitcast double* %6 to i8*
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), double 3.000000e+03, double -1.000000e+03)
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%15 = icmp eq i32 %14, 1
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %35
18: ; preds = %0
%19 = load double, double* %1
%20 = call i32 @exactO(double %19, double* %2, double* %3, double* %4, double* %5, double* %6)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%22 = load double, double* %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = load double, double* %3
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.5, i64 0, i64 0), double %24)
%26 = load double, double* %4
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), double %26)
%28 = load double, double* %5
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i64 0, i64 0), double %28)
%30 = load double, double* %6
%31 = fmul double %30, 0x417E1853E0000000
%32 = fmul double %30, 1.000000e+03
%33 = fmul double %32, 0x417E1853E0000000
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @.str.8, i64 0, i64 0), double %31, double %33)
br label %35
35: ; preds = %18, %16
%36 = phi i32 [ 1, %16 ], [ 0, %18 ]
ret i32 %36
}