#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 */
double dist(double, double);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ speed(double, double);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main() {
  double V0x, V0y, h, t, h0;
  printf("h:\n");
  scanf("%lf", &h0);
  printf("V0y:\n");
  scanf("%lf", &V0y);
  t = 0;
  h = 0;
  while (h >= 0) {
    h = h0 - dist(V0y, t);
    printf("t=%lf Speed=%lf  h=%lf", t, speed(V0y, t), h);
    usleep(100);
    t = t + 0.0001;
    fflush(stdout);
    printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
           "\b\b\b\b\b\b\b\b\b\b");
  }
  printf("t=%lf Speed=%lf  h=%lf\n", t, speed(V0y, t), h);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1267 <main+0x107>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1050 <dist@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1070 <speed@plt>
movsd  -0x38(%rbp),%xmm0
mov    %eax,%esi
movsd  -0x20(%rbp),%xmm1
lea    0xdef(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x64,%edi
call   1080 <usleep@plt>
movsd  0xdc4(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <main+0x5b>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1070 <speed@plt>
movsd  -0x48(%rbp),%xmm0
mov    %eax,%esi
movsd  -0x20(%rbp),%xmm1
lea    0xdc2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe97(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe57(%rip),%r14
mov    0x2e20(%rip),%r15
lea    0xe60(%rip),%rbx
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1060 <dist@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1080 <speed@plt>
mov    %r14,%rdi
movsd  (%rsp),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0x64,%edi
call   1090 <usleep@plt>
movsd  (%rsp),%xmm0
addsd  0xdc6(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    (%r15),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xda9(%rip),%xmm0
jae    11d0 <main+0x60>
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1080 <speed@plt>
lea    0xdd7(%rip),%rdi
movsd  (%rsp),%xmm0
mov    %eax,%esi
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"h:\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [6 x i8] c"V0y:\0A\00"
@.str.3 = [23 x i8] c"t=%lf Speed=%lf h=%lf\00"
@stdout = global i32 0
@.str.4 = [44 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.5 = [24 x i8] c"t=%lf Speed=%lf h=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 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* %6)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %4
br label %11
11: ; preds = %14, %0
%12 = load double, double* %4
%13 = fcmp oge double %12, 0.000000e+00
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load double, double* %6
%16 = load double, double* %3
%17 = load double, double* %5
%18 = call double @dist(double %16, double %17)
%19 = fsub double %15, %18
store double %19, double* %4
%20 = load double, double* %5
%21 = load double, double* %3
%22 = load double, double* %5
%23 = call i32 @speed(double %21, double %22)
%24 = load double, double* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %20, i32 %23, double %24)
%26 = call i32 @usleep(i32 100)
%27 = load double, double* %5
%28 = fadd double %27, 1.000000e-04
store double %28, double* %5
%29 = load i32, i32* @stdout
%30 = call i32 @fflush(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
br label %11
32: ; preds = %11
%33 = load double, double* %5
%34 = load double, double* %3
%35 = load double, double* %5
%36 = call i32 @speed(double %34, double %35)
%37 = load double, double* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %33, i32 %36, double %37)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [23 x i8] c"t=%lf Speed=%lf h=%lf\00"
@stdout = global i32 0
@.str.4 = [44 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.5 = [24 x i8] c"t=%lf Speed=%lf h=%lf\0A\00"
@str = [3 x i8] c"h:\00"
@str.6 = [5 x i8] c"V0y:\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, 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)
br label %9
9: ; preds = %0, %9
%10 = phi double [ 0.000000e+00, %0 ], [ %19, %9 ]
%11 = load double, double* %2
%12 = load double, double* %1
%13 = call double @dist(double %12, double %10)
%14 = fsub double %11, %13
%15 = load double, double* %1
%16 = call i32 @speed(double %15, double %10)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %10, i32 %16, double %14)
%18 = call i32 @usleep(i32 100)
%19 = fadd double %10, 1.000000e-04
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%23 = fcmp ult double %14, 0.000000e+00
br i1 %23, label %24, label %9
24: ; preds = %9
%25 = load double, double* %1
%26 = call i32 @speed(double %25, double %19)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %19, i32 %26, double %14)
ret i32 0
}