#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 cos(int);
int /*<<< orphan*/ printf(char *, int);
double sin(int);
int main() {
  int i, error = 0;
  for (i = 0; i < 100000000; i++) {
    double a = cos(i) * cos(i) + sin(i) * sin(i);
    if (a > 1.0005 || a < 0.9995) {
      error = 1;
      break;
    }
  }
  printf("%d\n", error);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5f5e100,-0x8(%rbp)
jge    11f5 <main+0xc5>
mov    -0x8(%rbp),%edi
call   1050 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sin@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11d6 <main+0xa6>
movsd  0xe3d(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11e2 <main+0xb2>
movl   $0x1,-0xc(%rbp)
jmp    11f5 <main+0xc5>
jmp    11e7 <main+0xb7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
mov    $0x1,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe76(%rip),%xmm1
ja     1208 <main+0xd8>
movsd  0xe74(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1208 <main+0xd8>
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe19(%rip),%xmm1
ja     1208 <main+0xd8>
movsd  0xe17(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1208 <main+0xd8>
add    $0x1,%ebx
cmp    $0x5f5e100,%ebx
jne    1140 <main+0x10>
xor    %ebp,%ebp
lea    0xe01(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %2
br label %5
5: ; preds = %26, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 100000000
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call double @cos(i32 %9)
%11 = load i32, i32* %2
%12 = call double @cos(i32 %11)
%13 = load i32, i32* %2
%14 = call double @sin(i32 %13)
%15 = load i32, i32* %2
%16 = call double @sin(i32 %15)
%17 = fmul double %14, %16
%18 = call double @llvm.fmuladd.f64(double %10, double %12, double %17)
store double %18, double* %4
%19 = load double, double* %4
%20 = fcmp ogt double %19, 1.000500e+00
br i1 %20, label %24, label %21
21: ; preds = %8
%22 = load double, double* %4
%23 = fcmp olt double %22, 9.995000e-01
br i1 %23, label %24, label %25
24: ; preds = %21, %8
store i32 1, i32* %3
br label %29
25: ; preds = %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %5
29: ; preds = %24, %5
%30 = load i32, i32* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %15
1: ; preds = %15
%2 = or i32 %16, 1
%3 = tail call double @cos(i32 %2)
%4 = tail call double @cos(i32 %2)
%5 = tail call double @sin(i32 %2)
%6 = tail call double @sin(i32 %2)
%7 = fmul double %5, %6
%8 = tail call double @llvm.fmuladd.f64(double %3, double %4, double %7)
%9 = fcmp ogt double %8, 1.000500e+00
%10 = fcmp olt double %8, 9.995000e-01
%11 = or i1 %9, %10
br i1 %11, label %26, label %12
12: ; preds = %1
%13 = add nuw nsw i32 %16, 2
%14 = icmp eq i32 %13, 100000000
br i1 %14, label %26, label %15
15: ; preds = %12, %0
%16 = phi i32 [ 0, %0 ], [ %13, %12 ]
%17 = tail call double @cos(i32 %16)
%18 = tail call double @cos(i32 %16)
%19 = tail call double @sin(i32 %16)
%20 = tail call double @sin(i32 %16)
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %21)
%23 = fcmp ogt double %22, 1.000500e+00
%24 = fcmp olt double %22, 9.995000e-01
%25 = or i1 %23, %24
br i1 %25, label %26, label %1
26: ; preds = %12, %1, %15
%27 = phi i32 [ 1, %15 ], [ 1, %1 ], [ 0, %12 ]
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}