#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 int int32_t;

/* Variables and functions */
int numdivis(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  (void)argc;
  (void)argv;
  int32_t count = 0;
  int32_t n_divis = 0;
  int32_t next;
  for (int32_t n = 1; n < 10000000; n++) {
    next = numdivis(n + 1);
    count += (n_divis == next);
    n_divis = next;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x989680,-0x20(%rbp)
jge    118e <main+0x6e>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
call   1030 <numdivis@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1040 <printf@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    $0x2,%ebp
xor    %r14d,%r14d
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <numdivis@plt>
xor    %ecx,%ecx
cmp    %eax,%r14d
sete   %cl
add    %ecx,%ebx
add    $0x1,%ebp
mov    %eax,%r14d
cmp    $0x989681,%ebp
jne    1130 <main+0x10>
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %5
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
5: ; preds = %2, %5
%6 = phi i32 [ 1, %2 ], [ %9, %5 ]
%7 = phi i32 [ 0, %2 ], [ %13, %5 ]
%8 = phi i32 [ 0, %2 ], [ %10, %5 ]
%9 = add nuw nsw i32 %6, 1
%10 = tail call i32 @numdivis(i32 %9)
%11 = icmp eq i32 %8, %10
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %7, %12
%14 = icmp eq i32 %9, 10000000
br i1 %14, label %3, label %5
}