#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 int INT_MAX;
unsigned int achaDivs(unsigned int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int main(void) {
  unsigned int qtdDiv = 0, num = 1, triNum = 0;
  do {
    qtdDiv = achaDivs(triNum);
    triNum += num;
    num++;
  } while (qtdDiv <= 500 && triNum <= INT_MAX);
  printf("triNum: %d\nfactors: %d", triNum, qtdDiv);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <achaDivs@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x1f4,-0x8(%rbp)
mov    %al,-0x11(%rbp)
ja     1195 <main+0x65>
mov    -0x10(%rbp),%eax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
setbe  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1154 <main+0x24>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
mov    $0x1,%ebp
mov    0x2ea6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1050 <achaDivs@plt>
add    %ebp,%ebx
cmp    $0x1f4,%eax
ja     1168 <main+0x38>
add    $0x1,%ebp
cmp    (%r14),%ebx
jbe    1150 <main+0x20>
lea    0xe91(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [23 x i8] c"triNum: %d\0Afactors: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %4
%7 = call i32 @achaDivs(i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = add i32 %9, %8
store i32 %10, i32* %4
%11 = load i32, i32* %3
%12 = add i32 %11, 1
store i32 %12, i32* %3
br label %13
13: ; preds = %5
%14 = load i32, i32* %2
%15 = icmp ule i32 %14, 500
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %4
%18 = load i32, i32* @INT_MAX
%19 = icmp ule i32 %17, %18
br label %20
20: ; preds = %16, %13
%21 = phi i1 [ false, %13 ], [ %19, %16 ]
br i1 %21, label %5, label %22
22: ; preds = %20
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [23 x i8] c"triNum: %d\0Afactors: %d\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 1, %0 ], [ %6, %1 ]
%3 = phi i32 [ 0, %0 ], [ %5, %1 ]
%4 = tail call i32 @achaDivs(i32 %3)
%5 = add i32 %3, %2
%6 = add i32 %2, 1
%7 = icmp ult i32 %4, 501
%8 = load i32, i32* @INT_MAX
%9 = icmp ule i32 %5, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %1, label %11
11: ; preds = %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %4)
%13 = tail call i32 (...) @getchar()
ret i32 0
}