#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 *, long);
long sqrt(long);
void main(void) {
  long n = 1, c = 0, t = 0, i = 0;
  while (n != 0) {
    t += n;
    c = 2;
    for (i = 2; i <= sqrt(t); ++i) {
      if (!(t % i))
        c += 2;
      if (c >= 500) {
        printf("%d\n", t);
        return;
      }
    }
    ++n;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x1,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11fa <main+0xda>
mov    -0x8(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x2,-0x10(%rbp)
movq   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sqrt@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jg     11e9 <main+0xc9>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    11b0 <main+0x90>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x1f4,-0x10(%rbp)
jl     11d3 <main+0xb3>
mov    -0x18(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <main+0xda>
jmp    11d8 <main+0xb8>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116f <main+0x4f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1148 <main+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14d
xor    %r15d,%r15d
jmp    1144 <main+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
add    %r14,%r15
mov    %r15,%rdi
call   1040 <sqrt@plt>
cmp    $0x2,%rax
jl     1140 <main+0x20>
mov    $0x2,%ebx
mov    $0x1,%r12d
add    $0x1,%r12
mov    %r15,%rax
or     %r12,%rax
shr    $0x20,%rax
je     1180 <main+0x60>
mov    %r15,%rax
xor    %edx,%edx
div    %r12
jmp    1188 <main+0x68>
nopw   0x0(%rax,%rax,1)
mov    %r15d,%eax
xor    %edx,%edx
div    %r12d
lea    0x2(%rbx),%rax
test   %rdx,%rdx
cmove  %rax,%rbx
cmp    $0x1f4,%rbx
jge    11ab <main+0x8b>
mov    %r15,%rdi
call   1040 <sqrt@plt>
cmp    %rax,%r12
jl     1160 <main+0x40>
jmp    1140 <main+0x20>
lea    0xe4e(%rip),%rdi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
br label %1
1: ; preds = %21, %0
%2 = phi i64 [ 1, %0 ], [ %22, %21 ]
%3 = phi i64 [ 0, %0 ], [ %4, %21 ]
%4 = add nuw nsw i64 %3, %2
%5 = tail call i64 @sqrt(i64 %4)
%6 = icmp slt i64 %5, 2
br i1 %6, label %21, label %11
7: ; preds = %11
%8 = add nuw nsw i64 %12, 1
%9 = tail call i64 @sqrt(i64 %4)
%10 = icmp slt i64 %12, %9
br i1 %10, label %11, label %21
11: ; preds = %1, %7
%12 = phi i64 [ %8, %7 ], [ 2, %1 ]
%13 = phi i64 [ %17, %7 ], [ 2, %1 ]
%14 = urem i64 %4, %12
%15 = icmp eq i64 %14, 0
%16 = add nsw i64 %13, 2
%17 = select i1 %15, i64 %16, i64 %13
%18 = icmp sgt i64 %17, 499
br i1 %18, label %19, label %7
19: ; preds = %11
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %4)
ret void
21: ; preds = %7, %1
%22 = add nuw nsw i64 %2, 1
br label %1
}