#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*/ exactI(double, double, double, double *, double *, double *,
                          double *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  double m, x, y, bed, tauc, u, v;
  int scanret;
  const double secpera = 31556926.0;
  printf("Enter  m, x, y  separated by space (or newline);\n");
  printf("    (units: pure, km, km; e.g. 10 100 40):\n");
  scanret = scanf("%lf", &m);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  scanret = scanf("%lf", &x);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  scanret = scanf("%lf", &y);
  if (scanret != 1) {
    printf("... input error; exiting\n");
    return 1;
  }
  exactI(m, x * 1000.0, y * 1000.0, &bed, &tauc, &u, &v);
  printf("\nResults from Test I:\n");
  printf("  bed = %9.3f (m)     tau_c = %10.3f (kPa)\n", bed, tauc / 1000.0);
  printf("  u   = %9.3f (m/a)   v     = %10.3f (m/a)\n", u * secpera,
         v * secpera);
  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,-0x50(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     119f <main+0x6f>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a2 <main+0x172>
lea    0xec8(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     11d6 <main+0xa6>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a2 <main+0x172>
lea    0xe91(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     120d <main+0xdd>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a2 <main+0x172>
movsd  -0x10(%rbp),%xmm0
movsd  0xdee(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xde1(%rip),%xmm2
mulsd  -0x20(%rbp),%xmm2
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1030 <exactI@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xda7(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xe37(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0xd85(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd78(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
lea    0xe3b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xf21(%rip),%rdi
call   1030 <puts@plt>
lea    0xf46(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123d <main+0xfd>
lea    0xe93(%rip),%rdi
lea    0x28(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123d <main+0xfd>
lea    0xe79(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    123d <main+0xfd>
movsd  0x30(%rsp),%xmm0
movsd  0xe48(%rip),%xmm3
movsd  0x28(%rsp),%xmm1
mulsd  %xmm3,%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  %xmm3,%xmm2
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <exactI@plt>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  0xdfd(%rip),%xmm1
lea    0xe0a(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xdef(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  (%rsp),%xmm1
lea    0xe11(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Enter m, x, y separated by space (or newline);\0A\00"
@.str.1 = [44 x i8] c" (units: pure, km, km; e.g. 10 100 40):\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [26 x i8] c"... input error; exiting\0A\00"
@.str.4 = [23 x i8] c"\0AResults from Test I:\0A\00"
@.str.5 = [44 x i8] c" bed = %9.3f (m) tau_c = %10.3f (kPa)\0A\00"
@.str.6 = [44 x i8] c" u = %9.3f (m/a) v = %10.3f (m/a)\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
%10 = alloca double
store i32 0, i32* %1
store double 0x417E1853E0000000, double* %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
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.3, 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.2, i64 0, i64 0), double* %3)
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.3, 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.2, i64 0, i64 0), double* %4)
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.3, i64 0, i64 0))
store i32 1, i32* %1
br label %47
30: ; preds = %24
%31 = load double, double* %2
%32 = load double, double* %3
%33 = fmul double %32, 1.000000e+03
%34 = load double, double* %4
%35 = fmul double %34, 1.000000e+03
%36 = call i32 @exactI(double %31, double %33, double %35, double* %5, double* %6, double* %7, double* %8)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%38 = load double, double* %5
%39 = load double, double* %6
%40 = fdiv double %39, 1.000000e+03
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %38, double %40)
%42 = load double, double* %7
%43 = fmul double %42, 0x417E1853E0000000
%44 = load double, double* %8
%45 = fmul double %44, 0x417E1853E0000000
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %43, 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.2 = [4 x i8] c"%lf\00"
@.str.5 = [44 x i8] c" bed = %9.3f (m) tau_c = %10.3f (kPa)\0A\00"
@.str.6 = [44 x i8] c" u = %9.3f (m/a) v = %10.3f (m/a)\0A\00"
@str = [49 x i8] c"Enter m, x, y separated by space (or newline);\00"
@str.7 = [43 x i8] c" (units: pure, km, km; e.g. 10 100 40):\00"
@str.8 = [22 x i8] c"\0AResults from Test I:\00"
@str.11 = [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 = alloca double
%8 = bitcast double* %1 to i8*
%9 = bitcast double* %2 to i8*
%10 = bitcast double* %3 to i8*
%11 = bitcast double* %4 to i8*
%12 = bitcast double* %5 to i8*
%13 = bitcast double* %6 to i8*
%14 = bitcast double* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.7, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%18 = icmp eq i32 %17, 1
br i1 %18, label %21, label %19
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
br label %48
21: ; preds = %0
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%23 = icmp eq i32 %22, 1
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
br label %48
26: ; preds = %21
%27 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%28 = icmp eq i32 %27, 1
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
br label %48
31: ; preds = %26
%32 = load double, double* %1
%33 = load double, double* %2
%34 = fmul double %33, 1.000000e+03
%35 = load double, double* %3
%36 = fmul double %35, 1.000000e+03
%37 = call i32 @exactI(double %32, double %34, double %36, double* %4, double* %5, double* %6, double* %7)
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%39 = load double, double* %4
%40 = load double, double* %5
%41 = fdiv double %40, 1.000000e+03
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %39, double %41)
%43 = load double, double* %6
%44 = fmul double %43, 0x417E1853E0000000
%45 = load double, double* %7
%46 = fmul double %45, 0x417E1853E0000000
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %44, double %46)
br label %48
48: ; preds = %31, %29, %24, %19
%49 = phi i32 [ 1, %19 ], [ 1, %24 ], [ 1, %29 ], [ 0, %31 ]
ret i32 %49
}