#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 */
int __breakpoint__inv(size_t *, size_t *, size_t *);
size_t count_n(size_t n) {
  size_t c = 0;
  for (size_t i = 0; __breakpoint__inv(&n, &c, &i), i < n; ++i) {
    ++c;
  }
  return c;
}


x86 assembly (clang, -O0):
<count_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <__breakpoint__inv@plt>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1168 <count_n+0x58>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <count_n+0x1c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_n>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <__breakpoint__inv@plt>
mov    0x8(%rsp),%rax
cmp    0x18(%rsp),%rax
jae    1189 <count_n+0x79>
lea    0x18(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
nop
addq   $0x1,0x10(%rsp)
add    $0x1,%rax
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <__breakpoint__inv@plt>
mov    0x8(%rsp),%rax
cmp    0x18(%rsp),%rax
jb     1160 <count_n+0x50>
mov    0x10(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @count_n(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %13, %1
%6 = call i32 @__breakpoint__inv(i64* %2, i64* %3, i64* %4)
%7 = load i64, i64* %4
%8 = load i64, i64* %2
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %5
%11 = load i64, i64* %3
%12 = add i64 %11, 1
store i64 %12, i64* %3
br label %13
13: ; preds = %10
%14 = load i64, i64* %4
%15 = add i64 %14, 1
store i64 %15, i64* %4
br label %5
16: ; preds = %5
%17 = load i64, i64* %3
ret i64 %17
}

LLVM IR (-O2):
define i64 @count_n(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = call i32 @__breakpoint__inv(i64* %2, i64* %3, i64* %4)
%8 = load i64, i64* %4
%9 = load i64, i64* %2
%10 = icmp ult i64 %8, %9
br i1 %10, label %13, label %11
11: ; preds = %13, %1
%12 = load i64, i64* %3
ret i64 %12
13: ; preds = %1, %13
%14 = phi i64 [ %19, %13 ], [ %8, %1 ]
%15 = load i64, i64* %3
%16 = add i64 %15, 1
store i64 %16, i64* %3
%17 = add nuw i64 %14, 1
store i64 %17, i64* %4
%18 = call i32 @__breakpoint__inv(i64* %2, i64* %3, i64* %4)
%19 = load i64, i64* %4
%20 = load i64, i64* %2
%21 = icmp ult i64 %19, %20
br i1 %21, label %13, label %11
}