#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
extern int see_more(int pagelen, FILE *fp_tty) {
  int c;
  printf("\033[7m more? \33[m");
  while ((c = getc(fp_tty)) != EOF) {
    switch (c) {
    case 'q':
      return 0;
    case '\n':
      return 1;
    case ' ':
      return pagelen;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<see_more>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11b4 <see_more+0x94>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xa,%eax
je     1198 <see_more+0x78>
jmp    116a <see_more+0x4a>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
je     11a4 <see_more+0x84>
jmp    117b <see_more+0x5b>
mov    -0x18(%rbp),%eax
sub    $0x71,%eax
jne    11af <see_more+0x8f>
jmp    118c <see_more+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    11bb <see_more+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11bb <see_more+0x9b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <see_more+0x9b>
jmp    113b <see_more+0x1b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<see_more>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    0x2eab(%rip),%rbp
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    0x0(%rbp),%ecx
je     116a <see_more+0x4a>
cmp    $0x71,%ecx
je     116a <see_more+0x4a>
cmp    $0x20,%ecx
je     1167 <see_more+0x47>
cmp    $0xa,%ecx
jne    1140 <see_more+0x20>
mov    $0x1,%eax
jmp    116a <see_more+0x4a>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"\1B[7m more? \1B[m\00"
@EOF = global i32 0
define i32 @see_more(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %19, %2
%9 = load i32*, i32** %5
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %19 [
i32 113, label %15
i32 10, label %16
i32 32, label %17
]
15: ; preds = %13
store i32 0, i32* %3
br label %21
16: ; preds = %13
store i32 1, i32* %3
br label %21
17: ; preds = %13
%18 = load i32, i32* %4
store i32 %18, i32* %3
br label %21
19: ; preds = %13
br label %8
20: ; preds = %8
store i32 0, i32* %3
br label %21
21: ; preds = %20, %17, %16, %15
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [15 x i8] c"\1B[7m more? \1B[m\00"
@EOF = global i32 0
define i32 @see_more(i32 %0, i32* nocapture %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %8, %2
%5 = tail call i32 @getc(i32* %1)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %9, label %8
8: ; preds = %4
switch i32 %5, label %4 [
i32 113, label %9
i32 10, label %10
i32 32, label %11
]
9: ; preds = %8, %4
br label %11
10: ; preds = %8
br label %11
11: ; preds = %8, %10, %9
%12 = phi i32 [ 0, %9 ], [ 1, %10 ], [ %0, %8 ]
ret i32 %12
}