#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(int argc, char const *argv[]) {
  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 enought!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
subsd  %xmm1,%xmm0
movaps 0xe99(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ae <main+0x8e>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115f <main+0x3f>
lea    0xe95(%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    0xedf(%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 = [16 x i8] c"Close enought!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 3.141590e+00, double* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
br label %10
10: ; preds = %15, %2
%11 = load double, double* %7
%12 = fsub double %11, 3.141590e+00
%13 = call double @llvm.fabs.f64(double %12)
%14 = fcmp ogt double %13, 1.000000e-04
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
br label %10
18: ; preds = %10
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 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 = [15 x i8] c"Close enought!\00"
@str.5 = [11 x i8] c"Try again!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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* %3)
%7 = load double, double* %3
%8 = fadd 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 %18
11: ; preds = %2, %11
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, 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)
%14 = load double, double* %3
%15 = fadd double %14, -3.141590e+00
%16 = call double @llvm.fabs.f64(double %15)
%17 = fcmp ogt double %16, 1.000000e-04
br i1 %17, label %11, label %18
18: ; preds = %11, %2
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}