#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 long divisors(unsigned long long);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main() {
  unsigned long long int i, flag = 0, n = 0, div;
  for (i = 1; !flag; i++) {
    if (i == 1)
      n = 1;
    else {
      n += i;
      div = divisors(n);
      if (div > 500)
        flag = 1;
    }
  }
  printf("\nLargest is %llu", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115e <main+0x3e>
jmp    11c0 <main+0xa0>
cmpq   $0x1,-0x10(%rbp)
jne    1176 <main+0x56>
movq   $0x1,-0x20(%rbp)
jmp    11aa <main+0x8a>
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <divisors@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x1f4,-0x28(%rbp)
jbe    11a5 <main+0x85>
movq   $0x1,-0x18(%rbp)
jmp    11aa <main+0x8a>
jmp    11af <main+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1147 <main+0x27>
mov    -0x20(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
xor    %r14d,%r14d
jmp    114f <main+0x2f>
xchg   %ax,%ax
add    %rbx,%r14
mov    %r14,%rdi
call   1040 <divisors@plt>
xor    %ecx,%ecx
cmp    $0x1f5,%rax
setae  %cl
add    $0x1,%rbx
test   %rcx,%rcx
jne    115f <main+0x3f>
cmp    $0x1,%rbx
jne    1130 <main+0x10>
xor    %ecx,%ecx
mov    $0x1,%r14d
jmp    1146 <main+0x26>
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0ALargest is %llu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %3
store i64 0, i64* %4
store i64 1, i64* %2
br label %6
6: ; preds = %25, %0
%7 = load i64, i64* %3
%8 = icmp ne i64 %7, 0
%9 = xor i1 %8, true
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i64, i64* %2
%12 = icmp eq i64 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %10
store i64 1, i64* %4
br label %24
14: ; preds = %10
%15 = load i64, i64* %2
%16 = load i64, i64* %4
%17 = add i64 %16, %15
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = call i64 @divisors(i64 %18)
store i64 %19, i64* %5
%20 = load i64, i64* %5
%21 = icmp ugt i64 %20, 500
br i1 %21, label %22, label %23
22: ; preds = %14
store i64 1, i64* %3
br label %23
23: ; preds = %22, %14
br label %24
24: ; preds = %23, %13
br label %25
25: ; preds = %24
%26 = load i64, i64* %2
%27 = add i64 %26, 1
store i64 %27, i64* %2
br label %6
28: ; preds = %6
%29 = load i64, i64* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0ALargest is %llu\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i64 [ 1, %0 ], [ %13, %10 ]
%3 = phi i64 [ 0, %0 ], [ %12, %10 ]
%4 = icmp eq i64 %2, 1
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = add i64 %2, %3
%7 = tail call i64 @divisors(i64 %6)
%8 = icmp ugt i64 %7, 500
%9 = zext i1 %8 to i64
br label %10
10: ; preds = %5, %1
%11 = phi i64 [ 0, %1 ], [ %9, %5 ]
%12 = phi i64 [ 1, %1 ], [ %6, %5 ]
%13 = add i64 %2, 1
%14 = icmp eq i64 %11, 0
br i1 %14, label %1, label %15
15: ; preds = %10
%16 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %12)
ret i32 0
}