#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 fabs(double);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  const double ANSWER = 3.14159;
  double response;
  printf("What is the value of pi?\n");
  scanf("%lf", &response);
  while (fabs(response - ANSWER) > 0.0001) {
    printf("Try again!\n");
    scanf("%lf", &response);
  }
  printf("Close enough!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movaps 0xea0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a7 <main+0x87>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1158 <main+0x38>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xeac(%rip),%xmm0
andpd  0xeb4(%rip),%xmm0
ucomisd 0xea4(%rip),%xmm0
jbe    11b3 <main+0x93>
lea    0xede(%rip),%r14
lea    0xeac(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe5f(%rip),%xmm0
andpd  0xe67(%rip),%xmm0
ucomisd 0xe57(%rip),%xmm0
ja     1180 <main+0x60>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"What is the value of pi?\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"Try again!\0A\00"
@.str.3 = [15 x i8] c"Close enough!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 3.141590e+00, double* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
br label %6
6: ; preds = %11, %0
%7 = load double, double* %3
%8 = fsub double %7, 3.141590e+00
%9 = call double @llvm.fabs.f64(double %8)
%10 = fcmp ogt double %9, 1.000000e-04
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
br label %6
14: ; preds = %6
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@str = [25 x i8] c"What is the value of pi?\00"
@str.4 = [14 x i8] c"Close enough!\00"
@str.5 = [11 x i8] c"Try again!\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fadd double %5, -3.141590e+00
%7 = call double @llvm.fabs.f64(double %6)
%8 = fcmp ogt double %7, 1.000000e-04
br i1 %8, label %9, label %16
9: ; preds = %0, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%12 = load double, double* %1
%13 = fadd double %12, -3.141590e+00
%14 = call double @llvm.fabs.f64(double %13)
%15 = fcmp ogt double %14, 1.000000e-04
br i1 %15, label %9, label %16
16: ; preds = %9, %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}