#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 get_int();
char getchar();
int /*<<< orphan*/ printf(char *, ...);
void count(void) {
  int n, i;
  printf("Count how far? Enter an integer: \n");
  n = get_int();
  for (i = 1; i <= n; i++)
    printf("%d\n", i);
  while (getchar() != '\n')
    continue;
}


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <get_int@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1182 <count+0x52>
mov    -0x8(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <count+0x27>
jmp    1187 <count+0x57>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     119f <count+0x6f>
jmp    1187 <count+0x57>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %r15
push   %r14
push   %rbx
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <get_int@plt>
test   %eax,%eax
jle    1190 <count+0x50>
mov    %eax,%r15d
neg    %r15d
mov    $0x1,%ebx
lea    0xe92(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1170 <count+0x30>
nop
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1190 <count+0x50>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Count how far? Enter an integer: \0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @count() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @get_int()
store i32 %4, i32* %1
store i32 1, i32* %2
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %2
%7 = load i32, i32* %1
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %5
15: ; preds = %5
br label %16
16: ; preds = %20, %15
%17 = call signext i8 (...) @getchar()
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [34 x i8] c"Count how far? Enter an integer: \00"
define void @count() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @get_int()
%3 = icmp slt i32 %2, 1
br i1 %3, label %9, label %4
4: ; preds = %0, %4
%5 = phi i32 [ %7, %4 ], [ 1, %0 ]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = add nuw i32 %5, 1
%8 = icmp eq i32 %5, %2
br i1 %8, label %9, label %4
9: ; preds = %4, %0
br label %10
10: ; preds = %9, %10
%11 = tail call signext i8 (...) @getchar()
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %10
13: ; preds = %10
ret void
}