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


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <get_int@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1192 <count+0x52>
mov    -0x8(%rbp),%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <count+0x27>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b4 <count+0x74>
jmp    119c <count+0x5c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_int@plt>
test   %eax,%eax
jle    118f <count+0x4f>
mov    %eax,%r15d
neg    %r15d
mov    $0x1,%ebx
lea    0xeb1(%rip),%r14
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>
mov    $0xa,%edi
call   1030 <putchar@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11a0 <count+0x60>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Count how far? Enter an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
define void @count() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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 ([3 x i8], [3 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
%16 = call i32 @putchar(i8 signext 10)
br label %17
17: ; preds = %21, %15
%18 = call signext i8 (...) @getchar()
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %17
br label %17
22: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Count how far? Enter an integer:\00"
@.str.1 = [3 x i8] c"%d\00"
define void @count() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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 ([3 x i8], [3 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
%10 = tail call i32 @putchar(i8 signext 10)
br label %11
11: ; preds = %11, %9
%12 = tail call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 10
br i1 %13, label %14, label %11
14: ; preds = %11
ret void
}