#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);
double sin(int);
int tester(void *start_point) {
  int error_status = 0, i = (int)start_point;
  double j;
  for (i; i < 100000000; i++) {
    j = (cos(i) * cos(i)) + (sin(i) * sin(i));
    if (j > 1.0005 || j < 0.9995) {
      error_status = 1;
      break;
    }
  }
  return error_status;
}


x86 assembly (clang, -O0):
<tester>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x10(%rbp)
cmpl   $0x5f5e100,-0x10(%rbp)
jge    11e2 <tester+0xc2>
mov    -0x10(%rbp),%edi
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <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  0xe5a(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11c3 <tester+0xa3>
movsd  0xe50(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11cf <tester+0xaf>
movl   $0x1,-0xc(%rbp)
jmp    11e2 <tester+0xc2>
jmp    11d4 <tester+0xb4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <tester+0x1a>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tester>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
cmp    $0x5f5e0ff,%ebx
jg     119c <tester+0x7c>
mov    %ebx,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebx,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe84(%rip),%xmm1
mov    $0x1,%eax
ja     119e <tester+0x7e>
movsd  0xe7d(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     119e <tester+0x7e>
add    $0x1,%ebx
cmp    $0x5f5e100,%ebx
jne    1130 <tester+0x10>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @tester(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = icmp slt i32 %3, 100000000
br i1 %4, label %8, label %19
5: ; preds = %8
%6 = add i32 %9, 1
%7 = icmp eq i32 %6, 100000000
br i1 %7, label %19, label %8
8: ; preds = %1, %5
%9 = phi i32 [ %6, %5 ], [ %3, %1 ]
%10 = tail call double @cos(i32 %9)
%11 = tail call double @cos(i32 %9)
%12 = tail call double @sin(i32 %9)
%13 = tail call double @sin(i32 %9)
%14 = fmul double %12, %13
%15 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %14)
%16 = fcmp ogt double %15, 1.000500e+00
%17 = fcmp olt double %15, 9.995000e-01
%18 = or i1 %16, %17
br i1 %18, label %19, label %5
19: ; preds = %5, %8, %1
%20 = phi i32 [ 0, %1 ], [ 1, %8 ], [ 0, %5 ]
ret i32 %20
}