#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 */
typedef scalar_t__ uint32_t;

/* Variables and functions */
scalar_t__ count_factors(scalar_t__);
uint32_t consecfactors(uint32_t n) {
  uint32_t i = 1;
  for (uint32_t c = 0; c != n;) {
    i += c + 1;
    for (c = 0; count_factors(i + c) == n && c < n; c++)
      ;
  }
  return i;
}


x86 assembly (clang, -O0):
<consecfactors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     11aa <consecfactors+0x9a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
call   1030 <count_factors@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jne    117f <consecfactors+0x6f>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118f <consecfactors+0x7f>
jmp    11a5 <consecfactors+0x95>
jmp    1194 <consecfactors+0x84>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1152 <consecfactors+0x42>
jmp    112c <consecfactors+0x1c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consecfactors>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     116c <consecfactors+0x5c>
mov    %rdi,%r12
lea    0x1(%rdi),%r15
mov    $0x1,%r14d
xor    %eax,%eax
jmp    1139 <consecfactors+0x29>
xchg   %ax,%ax
lea    -0x1(%rcx),%rax
cmp    %rcx,%r15
je     1172 <consecfactors+0x62>
add    %rax,%r14
add    $0x1,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r14,%rbx,1),%rdi
call   1030 <count_factors@plt>
lea    0x1(%rbx),%rcx
cmp    %r12,%rax
jne    1130 <consecfactors+0x20>
cmp    %r12,%rbx
mov    %rcx,%rbx
jl     1150 <consecfactors+0x40>
jmp    1130 <consecfactors+0x20>
mov    $0x1,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @consecfactors(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
store i64 1, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %31, %1
%6 = load i64, i64* %4
%7 = load i64, i64* %2
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %32
9: ; preds = %5
%10 = load i64, i64* %4
%11 = add nsw i64 %10, 1
%12 = load i64, i64* %3
%13 = add nsw i64 %12, %11
store i64 %13, i64* %3
store i64 0, i64* %4
br label %14
14: ; preds = %28, %9
%15 = load i64, i64* %3
%16 = load i64, i64* %4
%17 = add nsw i64 %15, %16
%18 = call i64 @count_factors(i64 %17)
%19 = load i64, i64* %2
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = load i64, i64* %4
%23 = load i64, i64* %2
%24 = icmp slt i64 %22, %23
br label %25
25: ; preds = %21, %14
%26 = phi i1 [ false, %14 ], [ %24, %21 ]
br i1 %26, label %27, label %31
27: ; preds = %25
br label %28
28: ; preds = %27
%29 = load i64, i64* %4
%30 = add nsw i64 %29, 1
store i64 %30, i64* %4
br label %14
31: ; preds = %25
br label %5
32: ; preds = %5
%33 = load i64, i64* %3
ret i64 %33
}

LLVM IR (-O2):
define i64 @consecfactors(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %5, label %7
3: ; preds = %12
%4 = icmp eq i64 %13, %0
br i1 %4, label %5, label %7
5: ; preds = %3, %1
%6 = phi i64 [ 1, %1 ], [ %11, %3 ]
ret i64 %6
7: ; preds = %1, %3
%8 = phi i64 [ %13, %3 ], [ 0, %1 ]
%9 = phi i64 [ %11, %3 ], [ 1, %1 ]
%10 = add i64 %9, 1
%11 = add i64 %10, %8
br label %12
12: ; preds = %12, %7
%13 = phi i64 [ 0, %7 ], [ %19, %12 ]
%14 = add nuw nsw i64 %13, %11
%15 = tail call i64 @count_factors(i64 %14)
%16 = icmp eq i64 %15, %0
%17 = icmp slt i64 %13, %0
%18 = select i1 %16, i1 %17, i1 false
%19 = add nuw nsw i64 %13, 1
br i1 %18, label %12, label %3
}