#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float d, mu, p, l, v;
  printf("Diameter (m): ");
  scanf("%f", &d);
  if (d <= 0)
    return -1;
  printf("Dynamic viscosity (N s m^2): ");
  scanf("%f", &mu);
  if (mu <= 0)
    return -2;
  printf("Pressure loss (Pa): ");
  scanf("%f", &p);
  if (p <= 0)
    return -3;
  printf("Pipe Length (m): ");
  scanf("%f", &l);
  if (l <= 0)
    return -4;
  printf("\n");
  float r;
  for (r = 0; r <= d / 2; r += d / 20) {
    v = (p / (4 * mu * l)) * (d / 2) * (d / 2) *
        (1 - (2 * r / d) * (2 * r / d));
    printf("Velocity at %.3f m from center: %.7f m/s\n", r, v);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1166 <main+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1316 <main+0x1f6>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     119d <main+0x7d>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1316 <main+0x1f6>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11d4 <main+0xb4>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1316 <main+0x1f6>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     120b <main+0xeb>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1316 <main+0x1f6>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
movss  0xdcd(%rip),%xmm2
divss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jb     130f <main+0x1ef>
movss  -0x10(%rbp),%xmm0
movss  0xdbb(%rip),%xmm1
mulss  -0xc(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xd98(%rip),%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xd83(%rip),%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xd73(%rip),%xmm1
mulss  -0x1c(%rbp),%xmm1
divss  -0x8(%rbp),%xmm1
movss  0xd61(%rip),%xmm2
mulss  -0x1c(%rbp),%xmm2
divss  -0x8(%rbp),%xmm2
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm1
movss  0xd42(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd7f(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xd10(%rip),%xmm1
divss  %xmm1,%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1221 <main+0x101>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xffffffff,%eax
xorps  %xmm0,%xmm0
ucomiss 0xc(%rsp),%xmm0
jae    12c4 <main+0x194>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
lea    0x18(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xfffffffe,%eax
xorps  %xmm0,%xmm0
ucomiss 0x18(%rsp),%xmm0
jae    12c4 <main+0x194>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xfffffffd,%eax
xorps  %xmm0,%xmm0
ucomiss 0x14(%rsp),%xmm0
jae    12c4 <main+0x194>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xfffffffc,%eax
xorps  %xmm0,%xmm0
ucomiss 0x10(%rsp),%xmm0
jae    12c4 <main+0x194>
mov    $0xa,%edi
call   1030 <putchar@plt>
movss  0xc(%rsp),%xmm0
movss  0xdeb(%rip),%xmm1
mulss  %xmm0,%xmm1
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm1
jb     12c2 <main+0x192>
lea    0xe3f(%rip),%rbx
nopl   0x0(%rax)
movss  %xmm4,0x1c(%rsp)
movss  0x14(%rsp),%xmm2
movss  0x18(%rsp),%xmm3
mulss  0xdba(%rip),%xmm3
mulss  0x10(%rsp),%xmm3
divss  %xmm3,%xmm2
mulss  %xmm1,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm4,%xmm1
addss  %xmm4,%xmm1
divss  %xmm0,%xmm1
mulss  %xmm1,%xmm1
movss  0xd95(%rip),%xmm3
subss  %xmm1,%xmm3
mulss  %xmm2,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm4
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
divss  0xd62(%rip),%xmm1
addss  %xmm1,%xmm4
movaps %xmm0,%xmm1
mulss  0xd47(%rip),%xmm1
ucomiss %xmm4,%xmm1
jae    1230 <main+0x100>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Diameter (m): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [30 x i8] c"Dynamic viscosity (N s m^2): \00"
@.str.3 = [21 x i8] c"Pressure loss (Pa): \00"
@.str.4 = [18 x i8] c"Pipe Length (m): \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [42 x i8] c"Velocity at %.3f m from center: %.7f m/s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = load float, float* %2
%11 = fcmp ole float %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 -1, i32* %1
br label %73
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%16 = load float, float* %3
%17 = fcmp ole float %16, 0.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -2, i32* %1
br label %73
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%22 = load float, float* %4
%23 = fcmp ole float %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -3, i32* %1
br label %73
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%28 = load float, float* %5
%29 = fcmp ole float %28, 0.000000e+00
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 -4, i32* %1
br label %73
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store float 0.000000e+00, float* %7
br label %33
33: ; preds = %67, %31
%34 = load float, float* %7
%35 = load float, float* %2
%36 = fdiv float %35, 2.000000e+00
%37 = fcmp ole float %34, %36
br i1 %37, label %38, label %72
38: ; preds = %33
%39 = load float, float* %4
%40 = load float, float* %3
%41 = fmul float 4.000000e+00, %40
%42 = load float, float* %5
%43 = fmul float %41, %42
%44 = fdiv float %39, %43
%45 = load float, float* %2
%46 = fdiv float %45, 2.000000e+00
%47 = fmul float %44, %46
%48 = load float, float* %2
%49 = fdiv float %48, 2.000000e+00
%50 = fmul float %47, %49
%51 = load float, float* %7
%52 = fmul float 2.000000e+00, %51
%53 = load float, float* %2
%54 = fdiv float %52, %53
%55 = load float, float* %7
%56 = fmul float 2.000000e+00, %55
%57 = load float, float* %2
%58 = fdiv float %56, %57
%59 = fneg float %54
%60 = call float @llvm.fmuladd.f32(float %59, float %58, float 1.000000e+00)
%61 = fmul float %50, %60
store float %61, float* %6
%62 = load float, float* %7
%63 = fpext float %62 to double
%64 = load float, float* %6
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), double %63, double %65)
br label %67
67: ; preds = %38
%68 = load float, float* %2
%69 = fdiv float %68, 2.000000e+01
%70 = load float, float* %7
%71 = fadd float %70, %69
store float %71, float* %7
br label %33
72: ; preds = %33
store i32 0, i32* %1
br label %73
73: ; preds = %72, %30, %24, %18, %12
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@.str = [15 x i8] c"Diameter (m): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [30 x i8] c"Dynamic viscosity (N s m^2): \00"
@.str.3 = [21 x i8] c"Pressure loss (Pa): \00"
@.str.4 = [18 x i8] c"Pipe Length (m): \00"
@.str.6 = [42 x i8] c"Velocity at %.3f m from center: %.7f m/s\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%11 = load float, float* %1
%12 = fcmp ugt float %11, 0.000000e+00
br i1 %12, label %13, label %58
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%16 = load float, float* %2
%17 = fcmp ugt float %16, 0.000000e+00
br i1 %17, label %18, label %58
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%21 = load float, float* %3
%22 = fcmp ugt float %21, 0.000000e+00
br i1 %22, label %23, label %58
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%26 = load float, float* %4
%27 = fcmp ugt float %26, 0.000000e+00
br i1 %27, label %28, label %58
28: ; preds = %23
%29 = call i32 @putchar(i32 10)
%30 = load float, float* %1
%31 = fmul float %30, 5.000000e-01
%32 = fcmp ult float %31, 0.000000e+00
br i1 %32, label %58, label %33
33: ; preds = %28, %33
%34 = phi float [ %56, %33 ], [ %31, %28 ]
%35 = phi float [ %53, %33 ], [ %30, %28 ]
%36 = phi float [ %55, %33 ], [ 0.000000e+00, %28 ]
%37 = load float, float* %3
%38 = load float, float* %2
%39 = fmul float %38, 4.000000e+00
%40 = load float, float* %4
%41 = fmul float %39, %40
%42 = fdiv float %37, %41
%43 = fmul float %34, %42
%44 = fmul float %34, %43
%45 = fmul float %36, 2.000000e+00
%46 = fdiv float %45, %35
%47 = fneg float %46
%48 = call float @llvm.fmuladd.f32(float %47, float %46, float 1.000000e+00)
%49 = fmul float %48, %44
%50 = fpext float %36 to double
%51 = fpext float %49 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), double %50, double %51)
%53 = load float, float* %1
%54 = fdiv float %53, 2.000000e+01
%55 = fadd float %36, %54
%56 = fmul float %53, 5.000000e-01
%57 = fcmp ugt float %55, %56
br i1 %57, label %58, label %33
58: ; preds = %33, %28, %23, %18, %13, %0
%59 = phi i32 [ -1, %0 ], [ -2, %13 ], [ -3, %18 ], [ -4, %23 ], [ 0, %28 ], [ 0, %33 ]
ret i32 %59
}