#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 */
scalar_t__ count_twos(int);
scalar_t__ count_twos_brute(int);
int test_large_numbers() {
  for (int i = 0; i < 10000; i++) {
    if (count_twos_brute(i) != count_twos(i)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_large_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    117f <test_large_numbers+0x5f>
mov    -0x8(%rbp),%edi
call   1030 <count_twos_brute@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <count_twos@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
je     116c <test_large_numbers+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    1186 <test_large_numbers+0x66>
jmp    1171 <test_large_numbers+0x51>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112f <test_large_numbers+0xf>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_large_numbers>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <count_twos_brute@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1040 <count_twos@plt>
cmp    %rax,%r14
jne    1171 <test_large_numbers+0x51>
xor    %ebx,%ebx
nop
mov    %ebx,%r15d
cmp    $0x270f,%ebx
je     1165 <test_large_numbers+0x45>
lea    0x1(%r15),%ebx
mov    %ebx,%edi
call   1030 <count_twos_brute@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1040 <count_twos@plt>
cmp    %rax,%r14
je     1140 <test_large_numbers+0x20>
xor    %ebx,%ebx
cmp    $0x270f,%r15d
setae  %bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @test_large_numbers() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %14, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10000
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i64 @count_twos_brute(i32 %7)
%9 = load i32, i32* %2
%10 = call i64 @count_twos(i32 %9)
%11 = icmp ne i64 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %6
store i32 0, i32* %1
br label %18
13: ; preds = %6
br label %14
14: ; preds = %13
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %3
17: ; preds = %3
store i32 1, i32* %1
br label %18
18: ; preds = %17, %12
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @test_large_numbers() {
%1 = tail call i64 @count_twos_brute(i32 0)
%2 = tail call i64 @count_twos(i32 0)
%3 = icmp eq i64 %1, %2
br i1 %3, label %4, label %15
4: ; preds = %0, %8
%5 = phi i32 [ %6, %8 ], [ 0, %0 ]
%6 = add nuw nsw i32 %5, 1
%7 = icmp eq i32 %6, 10000
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i64 @count_twos_brute(i32 %6)
%10 = tail call i64 @count_twos(i32 %6)
%11 = icmp eq i64 %9, %10
br i1 %11, label %4, label %12
12: ; preds = %8, %4
%13 = icmp ugt i32 %5, 9998
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %12, %0
%16 = phi i32 [ 0, %0 ], [ %14, %12 ]
ret i32 %16
}