#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 */
int /*<<< orphan*/ printf(char *, double);
double sqrt(double);
int main() {
  double i1, i2;
  double tri = 1;
  int counter = 0;
  double root;
  i1 = 2;
  while (counter < 500) {
    counter = 0;
    tri += i1;
    root = sqrt(tri);
    for (i2 = 1; i2 < root; i2++) {
      if (!((long int)tri % (long int)i2))
        counter++;
    }
    counter *= 2;
    i1++;
  }
  printf("tri: %lf\n", tri);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x1f4,-0x24(%rbp)
jge    1203 <main+0xe3>
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11e3 <main+0xc3>
cvttsd2si -0x20(%rbp),%rax
cvttsd2si -0x18(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11c7 <main+0xa7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <main+0xac>
movsd  0xe34(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118f <main+0x6f>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  0xe14(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1150 <main+0x30>
movsd  -0x20(%rbp),%xmm0
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm2
movsd  0xed4(%rip),%xmm4
xorpd  %xmm5,%xmm5
movapd %xmm2,%xmm3
jmp    1150 <main+0x30>
xchg   %ax,%ax
addsd  %xmm2,%xmm4
cmp    $0xfa,%esi
jge    11f6 <main+0xd6>
addsd  %xmm4,%xmm3
ucomisd %xmm5,%xmm3
jb     1170 <main+0x50>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    119d <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm3,%xmm0
movsd  %xmm3,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm5,%xmm5
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
movsd  0xe63(%rip),%xmm2
xor    %esi,%esi
ucomisd %xmm2,%xmm0
jbe    1140 <main+0x20>
cvttsd2si %xmm3,%rcx
xor    %esi,%esi
movapd %xmm2,%xmm1
jmp    11dd <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rcx,%rax
cqto
idiv   %rdi
cmp    $0x1,%rdx
adc    $0x0,%esi
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1140 <main+0x20>
cvttsd2si %xmm1,%rdi
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    11c0 <main+0xa0>
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
jmp    11c8 <main+0xa8>
lea    0xe13(%rip),%rdi
movapd %xmm3,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"tri: %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %4
store i32 0, i32* %5
store double 2.000000e+00, double* %2
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 500
br i1 %9, label %10, label %39
10: ; preds = %7
store i32 0, i32* %5
%11 = load double, double* %2
%12 = load double, double* %4
%13 = fadd double %12, %11
store double %13, double* %4
%14 = load double, double* %4
%15 = call double @sqrt(double %14)
store double %15, double* %6
store double 1.000000e+00, double* %3
br label %16
16: ; preds = %31, %10
%17 = load double, double* %3
%18 = load double, double* %6
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load double, double* %4
%22 = fptosi double %21 to i64
%23 = load double, double* %3
%24 = fptosi double %23 to i64
%25 = srem i64 %22, %24
%26 = icmp ne i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %30
30: ; preds = %27, %20
br label %31
31: ; preds = %30
%32 = load double, double* %3
%33 = fadd double %32, 1.000000e+00
store double %33, double* %3
br label %16
34: ; preds = %16
%35 = load i32, i32* %5
%36 = mul nsw i32 %35, 2
store i32 %36, i32* %5
%37 = load double, double* %2
%38 = fadd double %37, 1.000000e+00
store double %38, double* %2
br label %7
39: ; preds = %7
%40 = load double, double* %4
%41 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"tri: %lf\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %19
%2 = phi double [ 2.000000e+00, %0 ], [ %21, %19 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %4, %19 ]
%4 = fadd double %3, %2
%5 = tail call double @sqrt(double %4)
%6 = fcmp ogt double %5, 1.000000e+00
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = fptosi double %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %16, %9 ]
%11 = phi double [ 1.000000e+00, %7 ], [ %17, %9 ]
%12 = fptosi double %11 to i64
%13 = srem i64 %8, %12
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %10, %15
%17 = fadd double %11, 1.000000e+00
%18 = fcmp olt double %17, %5
br i1 %18, label %9, label %19
19: ; preds = %9, %1
%20 = phi i32 [ 0, %1 ], [ %16, %9 ]
%21 = fadd double %2, 1.000000e+00
%22 = icmp slt i32 %20, 250
br i1 %22, label %1, label %23
23: ; preds = %19
%24 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %4)
ret i32 0
}