#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 pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
main() {
  double q, n = .014, r, a, s = .0015, depth, width = 10;
  printf("At a depth of 5000 feet, the flow rate is 641.3225 cubic feet per "
         "second\n");
  printf("Please enter your initial guess with flow rate 1000.000 cubic feet "
         "per second\n");
  while (1) {
    scanf("%lf", &depth);
    r = depth * width / (2 * depth + width);
    a = (2.0 * 3.14 * r * depth) + (2.0 * 3.14 * r * r);
    q = ((1.486 / n) * a * (pow(r, (double)2 / 3)) * (pow(s, (double)1 / 2)));
    if (q < 1000) {
      double fin = 1000 - q;
      printf(
          "Acording to your guess the flow rate is %f cubic feet per second\n",
          q);
      printf("Deffernce is %f\nwith percentage error %f\n", fin, fin / 100);
      printf("Please enter the your next guess\n");
    } else if (q > 1000) {
      double fin = (1000 - q) * (-1.0);
      printf(
          "Acording to your guess the flow rate is %f cubic feet per second\n",
          q);
      printf("Deffernce is %f\nwith percentage error %f\n", fin, fin / 100);
      printf("Please enter the your next guess\n");
    } else {
      printf("Your guess is rigth %f\n", depth);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf60(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
addsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe79(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  0xe67(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe40(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdf1(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdcb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12b4 <main+0x184>
movsd  0xdb8(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xe95(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1350 <main+0x220>
movsd  -0x10(%rbp),%xmm0
movsd  0xd57(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1333 <main+0x203>
movsd  0xd45(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xd68(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xdf8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xd32(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xe16(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    134b <main+0x21b>
movsd  -0x38(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1355 <main+0x225>
jmp    1350 <main+0x220>
jmp    1182 <main+0x52>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xf84(%rip),%rdi
call   1030 <puts@plt>
lea    0xfc1(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%r14
lea    0x18(%rsp),%r15
lea    0xedc(%rip),%r12
lea    0xf17(%rip),%r13
lea    0xfe9(%rip),%rbx
jmp    11c6 <main+0x86>
nopl   0x0(%rax,%rax,1)
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm1
divsd  0xe84(%rip),%xmm1
mov    %r13,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm1
movapd %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm3
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
movapd %xmm0,%xmm3
mulsd  0xe05(%rip),%xmm3
movapd %xmm0,%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
mulsd  0xdf5(%rip),%xmm3
movsd  %xmm3,(%rsp)
movsd  0xdf0(%rip),%xmm1
call   1060 <pow@plt>
mulsd  (%rsp),%xmm0
mulsd  0xde6(%rip),%xmm0
movsd  0xde6(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1190 <main+0x50>
ucomisd %xmm1,%xmm0
jbe    1292 <main+0x152>
subsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movapd %xmm1,%xmm2
xorpd  0xdd8(%rip),%xmm2
movapd %xmm2,(%rsp)
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movapd 0x20(%rsp),%xmm1
divsd  0xdab(%rip),%xmm1
mov    %r13,%rdi
movapd (%rsp),%xmm0
jmp    11b7 <main+0x77>
movsd  0x18(%rsp),%xmm0
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [74 x i8] c"At a depth of 5000 feet, the flow rate is 641.3225 cubic feet per second\0A\00"
@.str.1 = [79 x i8] c"Please enter your initial guess with flow rate 1000.000 cubic feet per second\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [66 x i8] c"Acording to your guess the flow rate is %f cubic feet per second\0A\00"
@.str.4 = [42 x i8] c"Deffernce is %f\0Awith percentage error %f\0A\00"
@.str.5 = [34 x i8] c"Please enter the your next guess\0A\00"
@.str.6 = [24 x i8] c"Your guess is rigth %f\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 double
%10 = alloca double
store i32 0, i32* %1
store double 1.400000e-02, double* %3
store double 1.500000e-03, double* %6
store double 1.000000e+01, double* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %0, %70
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%15 = load double, double* %7
%16 = load double, double* %8
%17 = fmul double %15, %16
%18 = load double, double* %7
%19 = load double, double* %8
%20 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %18, double %19)
%21 = fdiv double %17, %20
store double %21, double* %4
%22 = load double, double* %4
%23 = fmul double 6.280000e+00, %22
%24 = load double, double* %7
%25 = load double, double* %4
%26 = fmul double 6.280000e+00, %25
%27 = load double, double* %4
%28 = fmul double %26, %27
%29 = call double @llvm.fmuladd.f64(double %23, double %24, double %28)
store double %29, double* %5
%30 = load double, double* %3
%31 = fdiv double 1.486000e+00, %30
%32 = load double, double* %5
%33 = fmul double %31, %32
%34 = load double, double* %4
%35 = call double @pow(double %34, double 0x3FE5555555555555)
%36 = fmul double %33, %35
%37 = load double, double* %6
%38 = call double @pow(double %37, double 5.000000e-01)
%39 = fmul double %36, %38
store double %39, double* %2
%40 = load double, double* %2
%41 = fcmp olt double %40, 1.000000e+03
br i1 %41, label %42, label %52
42: ; preds = %13
%43 = load double, double* %2
%44 = fsub double 1.000000e+03, %43
store double %44, double* %9
%45 = load double, double* %2
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), double %45)
%47 = load double, double* %9
%48 = load double, double* %9
%49 = fdiv double %48, 1.000000e+02
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %47, double %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %70
52: ; preds = %13
%53 = load double, double* %2
%54 = fcmp ogt double %53, 1.000000e+03
br i1 %54, label %55, label %66
55: ; preds = %52
%56 = load double, double* %2
%57 = fsub double 1.000000e+03, %56
%58 = fmul double %57, -1.000000e+00
store double %58, double* %10
%59 = load double, double* %2
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), double %59)
%61 = load double, double* %10
%62 = load double, double* %10
%63 = fdiv double %62, 1.000000e+02
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %61, double %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %69
66: ; preds = %52
%67 = load double, double* %7
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %67)
br label %71
69: ; preds = %55
br label %70
70: ; preds = %69, %42
br label %13
71: ; preds = %66
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [66 x i8] c"Acording to your guess the flow rate is %f cubic feet per second\0A\00"
@.str.4 = [42 x i8] c"Deffernce is %f\0Awith percentage error %f\0A\00"
@.str.6 = [24 x i8] c"Your guess is rigth %f\0A\00"
@str = [73 x i8] c"At a depth of 5000 feet, the flow rate is 641.3225 cubic feet per second\00"
@str.7 = [78 x i8] c"Please enter your initial guess with flow rate 1000.000 cubic feet per second\00"
@str.9 = [33 x i8] c"Please enter the your next guess\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.7, i64 0, i64 0))
br label %5
5: ; preds = %35, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%7 = load double, double* %1
%8 = fmul double %7, 1.000000e+01
%9 = call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double 1.000000e+01)
%10 = fdiv double %8, %9
%11 = fmul double %10, 6.280000e+00
%12 = fmul double %10, %11
%13 = call double @llvm.fmuladd.f64(double %11, double %7, double %12)
%14 = fmul double %13, 0x405A892492492492
%15 = call double @pow(double %10, double 0x3FE5555555555555)
%16 = fmul double %15, %14
%17 = fmul double %16, 0x3FA3D4659032C1D3
%18 = fcmp olt double %17, 1.000000e+03
br i1 %18, label %19, label %24
19: ; preds = %5
%20 = fsub double 1.000000e+03, %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), double %17)
%22 = fdiv double %20, 1.000000e+02
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %20, double %22)
br label %35
24: ; preds = %5
%25 = fcmp ogt double %17, 1.000000e+03
br i1 %25, label %26, label %32
26: ; preds = %24
%27 = fsub double 1.000000e+03, %17
%28 = fneg double %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), double %17)
%30 = fdiv double %27, -1.000000e+02
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %28, double %30)
br label %35
32: ; preds = %24
%33 = load double, double* %1
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %33)
ret i32 0
35: ; preds = %26, %19
%36 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0), %26 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0), %19 ]
%37 = call i32 @puts(i8* dereferenceable(1) %36)
br label %5
}