#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 */
unsigned long divisorCount(unsigned long);
int /*<<< orphan*/ printf(char *, size_t, unsigned long, unsigned long);
unsigned long triangularNumber(size_t);
int main(void) {
  unsigned long int divisors = 0;
  for (size_t i = 7278; divisors <= 500; i++) {
    unsigned long int triangular = triangularNumber(i);
    divisors = divisorCount(triangular);
    printf("i: %lu\ttriangular number: %lu\t# of divisors: %lu\n", i,
           triangular, divisors);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x1c6e,-0x18(%rbp)
cmpq   $0x1f4,-0x10(%rbp)
ja     11a0 <main+0x70>
mov    -0x18(%rbp),%rdi
call   1040 <triangularNumber@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <divisorCount@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1c6e,%ebx
lea    0xebc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <triangularNumber@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <divisorCount@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %rax,%rcx
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x1f5,%r12
jb     1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [50 x i8] c"i: %lu\09triangular number: %lu\09# of divisors: %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 7278, i64* %3
br label %5
5: ; preds = %17, %0
%6 = load i64, i64* %2
%7 = icmp ule i64 %6, 500
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i64, i64* %3
%10 = call i64 @triangularNumber(i64 %9)
store i64 %10, i64* %4
%11 = load i64, i64* %4
%12 = call i64 @divisorCount(i64 %11)
store i64 %12, i64* %2
%13 = load i64, i64* %3
%14 = load i64, i64* %4
%15 = load i64, i64* %2
%16 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %14, i64 %15)
br label %17
17: ; preds = %8
%18 = load i64, i64* %3
%19 = add i64 %18, 1
store i64 %19, i64* %3
br label %5
20: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"i: %lu\09triangular number: %lu\09# of divisors: %lu\0A\00"
define i32 @main() {
br label %2
1: ; preds = %2
ret i32 0
2: ; preds = %0, %2
%3 = phi i64 [ 7278, %0 ], [ %7, %2 ]
%4 = tail call i64 @triangularNumber(i64 %3)
%5 = tail call i64 @divisorCount(i64 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i64 %3, i64 %4, i64 %5)
%7 = add i64 %3, 1
%8 = icmp ult i64 %5, 501
br i1 %8, label %2, label %1
}