#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*/ exactH(double, double, double, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  const double SperA = 31556926.0;
  double f, year, r, H, M, b;
  int scanret;
  printf("Enter  f,  t,  and  r  separated by spaces (or newline)\n");
  printf("    (in pure, yrs, and km, resp.;  note  f = rho_ice/rho_bedrock;\n");
  printf("     e.g. input 0.28 40000 500):\n");
  scanret = scanf("%lf", &f);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  scanret = scanf("%lf", &year);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  scanret = scanf("%lf", &r);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  exactH(f, year * SperA, r * 1000.0, &H, &M);
  b = -f * H;
  printf("Results for Test H:\n");
  printf("    H = %12.6f (m)     M = %12.6f (m/a)    b = %12.6f (m)\n", H,
         M * SperA, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf31(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     11ad <main+0x7d>
lea    0xf18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x177>
lea    0xefa(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     11e4 <main+0xb4>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x177>
lea    0xec3(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     121b <main+0xeb>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x177>
movsd  -0x18(%rbp),%xmm0
movsd  0xdd8(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xdd3(%rip),%xmm2
mulsd  -0x28(%rbp),%xmm2
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <exactH@plt>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xd78(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xe48(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
lea    0xf76(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123b <main+0xfb>
lea    0xe97(%rip),%rdi
lea    0x28(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123b <main+0xfb>
lea    0xe7d(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123b <main+0xfb>
movsd  0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0xe36(%rip),%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  0xe30(%rip),%xmm2
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1050 <exactH@plt>
movsd  0x10(%rsp),%xmm0
xorpd  0xe1b(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
movapd %xmm0,0x30(%rsp)
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xde5(%rip),%xmm1
mulsd  0x18(%rsp),%xmm1
lea    0xdfc(%rip),%rdi
movaps 0x30(%rsp),%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Enter f, t, and r separated by spaces (or newline)\0A\00"
@.str.1 = [67 x i8] c" (in pure, yrs, and km, resp.; note f = rho_ice/rho_bedrock;\0A\00"
@.str.2 = [34 x i8] c" e.g. input 0.28 40000 500):\0A\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [26 x i8] c"... input error; exiting\0A\00"
@.str.5 = [21 x i8] c"Results for Test H:\0A\00"
@.str.6 = [59 x i8] c" H = %12.6f (m) M = %12.6f (m/a) b = %12.6f (m)\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 double
%9 = alloca i32
store i32 0, i32* %1
store double 0x417E1853E0000000, double* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%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.4, i64 0, i64 0))
store i32 1, i32* %1
br label %47
18: ; preds = %0
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %4)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %47
24: ; preds = %18
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %5)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %47
30: ; preds = %24
%31 = load double, double* %3
%32 = load double, double* %4
%33 = fmul double %32, 0x417E1853E0000000
%34 = load double, double* %5
%35 = fmul double %34, 1.000000e+03
%36 = call i32 @exactH(double %31, double %33, double %35, double* %6, double* %7)
%37 = load double, double* %3
%38 = fneg double %37
%39 = load double, double* %6
%40 = fmul double %38, %39
store double %40, double* %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%42 = load double, double* %6
%43 = load double, double* %7
%44 = fmul double %43, 0x417E1853E0000000
%45 = load double, double* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0), double %42, double %44, double %45)
store i32 0, i32* %1
br label %47
47: ; preds = %30, %28, %22, %16
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%lf\00"
@.str.6 = [59 x i8] c" H = %12.6f (m) M = %12.6f (m/a) b = %12.6f (m)\0A\00"
@str = [56 x i8] c"Enter f, t, and r separated by spaces (or newline)\00"
@str.7 = [66 x i8] c" (in pure, yrs, and km, resp.; note f = rho_ice/rho_bedrock;\00"
@str.8 = [33 x i8] c" e.g. input 0.28 40000 500):\00"
@str.9 = [20 x i8] c"Results for Test H:\00"
@str.12 = [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 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, 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.12, i64 0, i64 0))
br label %44
18: ; preds = %0
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%20 = icmp eq i32 %19, 1
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
br label %44
23: ; preds = %18
%24 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%25 = icmp eq i32 %24, 1
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
br label %44
28: ; preds = %23
%29 = load double, double* %1
%30 = load double, double* %2
%31 = fmul double %30, 0x417E1853E0000000
%32 = load double, double* %3
%33 = fmul double %32, 1.000000e+03
%34 = call i32 @exactH(double %29, double %31, double %33, double* %4, double* %5)
%35 = load double, double* %1
%36 = fneg double %35
%37 = load double, double* %4
%38 = fmul double %37, %36
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
%40 = load double, double* %4
%41 = load double, double* %5
%42 = fmul double %41, 0x417E1853E0000000
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0), double %40, double %42, double %38)
br label %44
44: ; preds = %28, %26, %21, %16
%45 = phi i32 [ 1, %16 ], [ 1, %21 ], [ 1, %26 ], [ 0, %28 ]
ret i32 %45
}