#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 */
long nextTriang();
int numdivs(long);
int /*<<< orphan*/ printf(char *, long, ...);
int main() {
  int divs, max;
  long triang;
  max = 0;
  do {
    triang = nextTriang();
    divs = numdivs(triang);
    if (divs > max) {
      max = divs;
      printf("max num of divs: %i\n", max);
    }
  } while (divs < 500);
  printf("%i has %i divisors\n", triang, divs);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <nextTriang@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <numdivs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1181 <main+0x51>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1186 <main+0x56>
cmpl   $0x1f4,-0x8(%rbp)
jl     1146 <main+0x16>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%r14
xor    %r15d,%r15d
jmp    1158 <main+0x28>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x1f4,%ebp
jge    1183 <main+0x53>
xor    %eax,%eax
call   1040 <nextTriang@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <numdivs@plt>
mov    %eax,%ebp
cmp    %r15d,%eax
jle    1150 <main+0x20>
movslq %ebp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%r15d
jmp    1150 <main+0x20>
lea    0xe8b(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"max num of divs: %i\0A\00"
@.str.1 = [20 x i8] c"%i has %i divisors\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %18, %0
%6 = call i64 (...) @nextTriang()
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = call i32 @numdivs(i64 %7)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %5
%13 = load i32, i32* %2
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %15)
br label %17
17: ; preds = %12, %5
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 500
br i1 %20, label %5, label %21
21: ; preds = %18
%22 = load i64, i64* %4
%23 = load i32, i32* %2
%24 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 %22, i32 %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [21 x i8] c"max num of divs: %i\0A\00"
@.str.1 = [20 x i8] c"%i has %i divisors\0A\00"
define i32 @main() {
br label %1
1: ; preds = %9, %0
%2 = phi i32 [ 0, %0 ], [ %10, %9 ]
%3 = tail call i64 (...) @nextTriang()
%4 = tail call i32 @numdivs(i64 %3)
%5 = icmp sgt i32 %4, %2
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %7)
br label %9
9: ; preds = %1, %6
%10 = phi i32 [ %4, %6 ], [ %2, %1 ]
%11 = icmp slt i32 %4, 500
br i1 %11, label %1, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 %3, i32 %4)
ret i32 0
}