#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 exactM(double, double *, double *, double, double, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  double r, alpha, strainrate;
  int scanret;
  const double secpera = 31556926.0;
  printf("Enter  r  (in km; e.g. 600.0):   ");
  scanret = scanf("%lf", &r);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  double EPS_ABS[] = {1.0e-12, 1.0e-9, 1.0e-7};
  double EPS_REL[] = {0.0, 1.0e-14, 1.0e-11};
  int eMresult;
  eMresult = exactM(r * 1000.0, &alpha, &strainrate, EPS_ABS[0], EPS_REL[0], 1);
  if (eMresult != 0) {
    printf("\n\nFAILURE in evaluatine exactM() !!!!\n\n\n");
  }
  printf("Results from Test M:\n");
  printf("     alpha = %8.5f (m/a),  D_rr = alpha' = %11.8f (1/a)\n",
         alpha * secpera, strainrate * secpera);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
je     1194 <main+0x64>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1257 <main+0x127>
mov    0xf35(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xf32(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xf2f(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xf34(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xf31(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xf2e(%rip),%rax
mov    %rax,-0x60(%rbp)
movsd  0xe2a(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1030 <exactM@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
je     121a <main+0xea>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xdd0(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdc3(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
lea    0xe46(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee1(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11db <main+0x9b>
movsd  0x10(%rsp),%xmm0
mulsd  0xe8a(%rip),%xmm0
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
movsd  0xe82(%rip),%xmm1
xorps  %xmm2,%xmm2
mov    $0x1,%edx
call   1040 <exactM@plt>
test   %eax,%eax
je     11a3 <main+0x63>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
movsd  0xe59(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  (%rsp),%xmm1
lea    0xe71(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter r (in km; e.g. 600.0): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [26 x i8] c"... input error; exiting\0A\00"
@__const.main.EPS_ABS = [3 x double] [double 0x3D719799812DEA11, double 1.000000e-09, double 0x3E7AD7F29ABCAF48]
@__const.main.EPS_REL = [3 x double] [double 0.000000e+00, double 0x3D06849B86A12B9B, double 0x3DA5FD7FE1796495]
@.str.3 = [41 x i8] c"\0A\0AFAILURE in evaluatine exactM() !!!!\0A\0A\0A\00"
@.str.4 = [22 x i8] c"Results from Test M:\0A\00"
@.str.5 = [57 x i8] c" alpha = %8.5f (m/a), D_rr = alpha' = %11.8f (1/a)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca i32
store i32 0, i32* %1
store double 0x417E1853E0000000, double* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = 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 %37
16: ; preds = %0
%17 = bitcast [3 x double]* %7 to i8*
%18 = bitcast [3 x double]* %8 to i8*
%19 = load double, double* %2
%20 = fmul double %19, 1.000000e+03
%21 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%22 = load double, double* %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%24 = load double, double* %23
%25 = call i32 @exactM(double %20, double* %3, double* %4, double %22, double %24, i32 1)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%32 = load double, double* %3
%33 = fmul double %32, 0x417E1853E0000000
%34 = load double, double* %4
%35 = fmul double %34, 0x417E1853E0000000
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), double %33, double %35)
store i32 0, i32* %1
br label %37
37: ; preds = %30, %14
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter r (in km; e.g. 600.0): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.5 = [57 x i8] c" alpha = %8.5f (m/a), D_rr = alpha' = %11.8f (1/a)\0A\00"
@str = [21 x i8] c"Results from Test M:\00"
@str.6 = [40 x i8] c"\0A\0AFAILURE in evaluatine exactM() !!!!\0A\0A\00"
@str.7 = [25 x i8] c"... input error; exiting\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
br label %26
12: ; preds = %0
%13 = load double, double* %1
%14 = fmul double %13, 1.000000e+03
%15 = call i32 @exactM(double %14, double* %2, double* %3, double 0x3D719799812DEA11, double 0.000000e+00, i32 1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%21 = load double, double* %2
%22 = fmul double %21, 0x417E1853E0000000
%23 = load double, double* %3
%24 = fmul double %23, 0x417E1853E0000000
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), double %22, double %24)
br label %26
26: ; preds = %19, %10
%27 = phi i32 [ 1, %10 ], [ 0, %19 ]
ret i32 %27
}