#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 exactJ(double, double, double *, double *, double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int main() {
  double x, y, u, v, H, nu;
  int scanret;
  const double secpera = 31556926.0;
  printf("Enter  x, y  separated by space (or newline);\n");
  printf("    (units: km, km; e.g. 100 100):\n");
  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;
  }
  printf("\nResults from Test J (returned %d):\n",
         exactJ(x * 1000.0, y * 1000.0, &H, &nu, &u, &v));
  printf("  H   = %10.3f (m)     nu    = %10.3f (MPa a)\n", H,
         (nu * 1.0e-6) / secpera);
  printf("  u   = %10.5f (m/a)   v     = %10.5f (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,-0x48(%rbp)
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
je     119f <main+0x6f>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1270 <main+0x140>
lea    0xec5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
je     11d6 <main+0xa6>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1270 <main+0x140>
movsd  0xe32(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe25(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <exactJ@plt>
mov    %eax,%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xdd1(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xe74(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  0xdb7(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
lea    0xe7b(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xf51(%rip),%rdi
call   1030 <puts@plt>
lea    0xf73(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
lea    0x28(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1223 <main+0xe3>
lea    0xe9a(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1223 <main+0xe3>
movsd  0xe67(%rip),%xmm1
movsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x20(%rsp),%xmm1
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <exactJ@plt>
lea    0xe55(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mulsd  0xe23(%rip),%xmm1
divsd  0xe23(%rip),%xmm1
lea    0xe4d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0xe07(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm1
lea    0xe56(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1234 <main+0xf4>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%lf\00"
@.str.4 = [37 x i8] c"\0AResults from Test J (returned %d):\0A\00"
@.str.5 = [47 x i8] c" H = %10.3f (m) nu = %10.3f (MPa a)\0A\00"
@.str.6 = [45 x i8] c" u = %10.5f (m/a) v = %10.5f (m/a)\0A\00"
@str = [46 x i8] c"Enter x, y separated by space (or newline);\00"
@str.7 = [35 x i8] c" (units: km, km; e.g. 100 100):\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%16 = icmp eq i32 %15, 1
br i1 %16, label %19, label %17
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %41
19: ; preds = %0
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %41
24: ; preds = %19
%25 = load double, double* %1
%26 = fmul double %25, 1.000000e+03
%27 = load double, double* %2
%28 = fmul double %27, 1.000000e+03
%29 = call i32 @exactJ(double %26, double %28, double* %5, double* %6, double* %3, double* %4)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = load double, double* %5
%32 = load double, double* %6
%33 = fmul double %32, 0x3EB0C6F7A0B5ED8D
%34 = fdiv double %33, 0x417E1853E0000000
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), double %31, double %34)
%36 = load double, double* %3
%37 = fmul double %36, 0x417E1853E0000000
%38 = load double, double* %4
%39 = fmul double %38, 0x417E1853E0000000
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), double %37, double %39)
br label %41
41: ; preds = %24, %22, %17
%42 = phi i32 [ 1, %17 ], [ 1, %22 ], [ 0, %24 ]
ret i32 %42
}