#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*/ error_message_testP(int);
int exactP(double, double *, double *, double *, double *, double *, double,
           double, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  double r, h, magvb, Wcrit, W, P;
  int scanret, ierr;
  const double secpera = 31556926.0;
  double EPS_ABS[] = {1.0e-12, 1.0e-9, 1.0e-7};
  double EPS_REL[] = {1.0e-15, 1.0e-14, 1.0e-11};
  printf("Enter  r  (in km; 0 <= r <= TESTP_L = %.1f):   ",
         0.9 * 25000.0 / 1000.0);
  scanret = scanf("%lf", &r);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  ierr =
      exactP(r * 1000.0, &h, &magvb, &Wcrit, &W, &P, EPS_ABS[0], EPS_REL[0], 1);
  if (ierr) {
    printf("\n\nsimpleP ENDING because of ERROR from exactP():\n");
    error_message_testP(ierr);
    return 1;
  }
  printf("Results from Test P:\n");
  printf("    h = %.4f (m)  Po = %.7f (bar)  |vb| = %.5f (m/year)\n"
         "    W_c = %.8f (m)  W = %.8f (m)  P = %.7f (bar)\n",
         h, 910.0 * 9.81 * h / 1.0e5, magvb * secpera, Wcrit, W, P / 1.0e5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xec0(%rip),%rdi
movsd  0xe50(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
je     11ee <main+0xae>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bc <main+0x17c>
movsd  0xe1a(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm2
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
mov    $0x1,%r9d
call   1050 <exactP@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     1253 <main+0x113>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%edi
call   1040 <error_message_testP@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bc <main+0x17c>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xd9d(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xd81(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  0xd75(%rip),%xmm6
divsd  %xmm6,%xmm5
lea    0xe50(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
lea    0xedb(%rip),%rdi
movsd  0xe9b(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11e4 <main+0x94>
movsd  0x30(%rsp),%xmm0
mulsd  0xe78(%rip),%xmm0
lea    0x28(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
movsd  0xe5f(%rip),%xmm1
movsd  0xe5f(%rip),%xmm2
mov    $0x1,%ebx
mov    $0x1,%r9d
call   1060 <exactP@plt>
test   %eax,%eax
je     11f7 <main+0xa7>
mov    %eax,%ebp
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1050 <error_message_testP@plt>
jmp    1255 <main+0x105>
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1255 <main+0x105>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
movsd  0x28(%rsp),%xmm0
movsd  0xe0f(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe0b(%rip),%xmm6
divsd  %xmm6,%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  0xe01(%rip),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm5
divsd  %xmm6,%xmm5
lea    0xe20(%rip),%rdi
mov    $0x6,%al
call   1040 <printf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.EPS_ABS = [3 x double] [double 0x3D719799812DEA11, double 1.000000e-09, double 0x3E7AD7F29ABCAF48]
@__const.main.EPS_REL = [3 x double] [double 1.000000e-15, double 0x3D06849B86A12B9B, double 0x3DA5FD7FE1796495]
@.str = [48 x i8] c"Enter r (in km; 0 <= r <= TESTP_L = %.1f): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [26 x i8] c"... input error; exiting\0A\00"
@.str.3 = [50 x i8] c"\0A\0AsimpleP ENDING because of ERROR from exactP():\0A\00"
@.str.4 = [22 x i8] c"Results from Test P:\0A\00"
@.str.5 = [106 x i8] c" h = %.4f (m) Po = %.7f (bar) |vb| = %.5f (m/year)\0A W_c = %.8f (m) W = %.8f (m) P = %.7f (bar)\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 i32
%10 = alloca double
%11 = alloca [3 x double]
%12 = alloca [3 x double]
store i32 0, i32* %1
store double 0x417E1853E0000000, double* %10
%13 = bitcast [3 x double]* %11 to i8*
%14 = bitcast [3 x double]* %12 to i8*
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), double 2.250000e+01)
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = 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 %48
21: ; preds = %0
%22 = load double, double* %2
%23 = fmul double %22, 1.000000e+03
%24 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%27 = load double, double* %26
%28 = call i32 @exactP(double %23, double* %3, double* %4, double* %5, double* %6, double* %7, double %25, double %27, i32 1)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %21
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %9
%34 = call i32 @error_message_testP(i32 %33)
store i32 1, i32* %1
br label %48
35: ; preds = %21
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%37 = load double, double* %3
%38 = load double, double* %3
%39 = fmul double 8.927100e+03, %38
%40 = fdiv double %39, 1.000000e+05
%41 = load double, double* %4
%42 = fmul double %41, 0x417E1853E0000000
%43 = load double, double* %5
%44 = load double, double* %6
%45 = load double, double* %7
%46 = fdiv double %45, 1.000000e+05
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.5, i64 0, i64 0), double %37, double %40, double %42, double %43, double %44, double %46)
store i32 0, i32* %1
br label %48
48: ; preds = %35, %31, %19
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [48 x i8] c"Enter r (in km; 0 <= r <= TESTP_L = %.1f): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.5 = [106 x i8] c" h = %.4f (m) Po = %.7f (bar) |vb| = %.5f (m/year)\0A W_c = %.8f (m) W = %.8f (m) P = %.7f (bar)\0A\00"
@str = [21 x i8] c"Results from Test P:\00"
@str.6 = [49 x i8] c"\0A\0AsimpleP ENDING because of ERROR from exactP():\00"
@str.7 = [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 ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), double 2.250000e+01)
%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.7, i64 0, i64 0))
br label %38
18: ; preds = %0
%19 = load double, double* %1
%20 = fmul double %19, 1.000000e+03
%21 = call i32 @exactP(double %20, double* %2, double* %3, double* %4, double* %5, double* %6, double 0x3D719799812DEA11, double 1.000000e-15, i32 1)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.6, i64 0, i64 0))
%25 = call i32 @error_message_testP(i32 %21)
br label %38
26: ; preds = %18
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%28 = load double, double* %2
%29 = fmul double %28, 8.927100e+03
%30 = fdiv double %29, 1.000000e+05
%31 = load double, double* %3
%32 = fmul double %31, 0x417E1853E0000000
%33 = load double, double* %4
%34 = load double, double* %5
%35 = load double, double* %6
%36 = fdiv double %35, 1.000000e+05
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str.5, i64 0, i64 0), double %28, double %30, double %32, double %33, double %34, double %36)
br label %38
38: ; preds = %26, %23, %16
%39 = phi i32 [ 1, %16 ], [ 1, %23 ], [ 0, %26 ]
ret i32 %39
}