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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
int more(FILE *fp) {
  int ch, line, col;
  char buf[80];
  line = 1;
  col = 0;
  while ((ch = fgetc(fp)) != EOF) {
    switch (ch) {
    case '\r':
      col = 0;
      break;
    case '\n':
      line++;
      col = 0;
      break;
    case '\t':
      col = ((col + 1) | 0x07) + 1;
      break;
    case '\b':
      if (col > 0)
        --col;
      break;
    default:
      col++;
    }
    putchar(ch);
    if (col >= 80) {
      col -= 80;
      ++line;
    }
    if (line < 24)
      continue;
    if (col > 0)
      putchar('\n');
    printf("--More--");
    fflush(stdout);
    if (read(0, buf, sizeof(buf)) < 0) {
      return 0;
    }
    ch = buf[0];
    if (ch == ':')
      ch = buf[1];
    switch (ch) {
    case 'N':
    case 'n':
      return 1;
    case 'Q':
    case 'q':
      return 0;
    }
    col = 0;
    line = 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<more>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
je     12fd <more+0x1ad>
mov    -0x14(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x5,%eax
ja     11fe <more+0xae>
mov    -0x78(%rbp),%rax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x1c(%rbp)
jmp    1207 <more+0xb7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    1207 <more+0xb7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
or     $0x7,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1207 <more+0xb7>
cmpl   $0x0,-0x1c(%rbp)
jle    11f9 <more+0xa9>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1207 <more+0xb7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
cmpl   $0x50,-0x1c(%rbp)
jl     122e <more+0xde>
mov    -0x1c(%rbp),%eax
sub    $0x50,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x18,-0x18(%rbp)
jge    123d <more+0xed>
jmp    116d <more+0x1d>
cmpl   $0x0,-0x1c(%rbp)
jle    1251 <more+0x101>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x70(%rbp),%rsi
xor    %edi,%edi
mov    $0x50,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jge    1291 <more+0x141>
movl   $0x0,-0x4(%rbp)
jmp    1304 <more+0x1b4>
movsbl -0x70(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3a,-0x14(%rbp)
jne    12a9 <more+0x159>
movsbl -0x6f(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffb2,%eax
mov    %eax,%ecx
mov    %rcx,-0x80(%rbp)
sub    $0x23,%eax
ja     12ea <more+0x19a>
mov    -0x80(%rbp),%rax
lea    0xd4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    1304 <more+0x1b4>
movl   $0x0,-0x4(%rbp)
jmp    1304 <more+0x1b4>
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    116d <more+0x1d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<more>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
call   1050 <fgetc@plt>
mov    0x2e7b(%rip),%rcx
mov    $0x1,%ebp
cmp    (%rcx),%eax
je     12a3 <more+0x153>
mov    $0x1,%r13d
xor    %r15d,%r15d
lea    0xe76(%rip),%r14
jmp    11aa <more+0x5a>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %ebp,%r13d
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%eax
je     129e <more+0x14e>
lea    -0x8(%rax),%ecx
cmp    $0x5,%ecx
ja     11d8 <more+0x88>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
xor    %r12d,%r12d
jmp    *%rcx
xor    %ecx,%ecx
test   %r15d,%r15d
setg   %cl
sub    %ecx,%r15d
jmp    11dc <more+0x8c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
or     $0x7,%r15d
add    $0x1,%r15d
mov    %r15d,%r12d
jmp    1200 <more+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
lea    -0x50(%r12),%r15d
xor    %ebp,%ebp
cmp    $0x50,%r12d
setge  %bpl
cmovl  %r12d,%r15d
add    %r13d,%ebp
cmp    $0x17,%ebp
jle    1190 <more+0x40>
test   %r15d,%r15d
jle    1236 <more+0xe6>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %ebp,%ebp
xor    %edi,%edi
mov    %rsp,%rsi
mov    $0x50,%edx
call   1060 <read@plt>
test   %rax,%rax
js     12a3 <more+0x153>
mov    (%rsp),%eax
cmp    $0x3a,%al
movzbl 0x1(%rsp),%ecx
cmovne %eax,%ecx
movsbl %cl,%eax
xor    %r15d,%r15d
mov    $0x1,%ebp
add    $0xffffffb2,%eax
cmp    $0x23,%eax
ja     1190 <more+0x40>
lea    0xd87(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %ebp,%ebp
jmp    12a3 <more+0x153>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [9 x i8] c"--More--\00"
@stdout = global i32 0
define i32 @more(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [80 x i8]
store i32* %0, i32** %3
store i32 1, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %76, %48, %1
%9 = load i32*, i32** %3
%10 = call i32 @fgetc(i32* %9)
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %77
13: ; preds = %8
%14 = load i32, i32* %4
switch i32 %14, label %31 [
i32 13, label %15
i32 10, label %16
i32 9, label %19
i32 8, label %24
]
15: ; preds = %13
store i32 0, i32* %6
br label %34
16: ; preds = %13
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
store i32 0, i32* %6
br label %34
19: ; preds = %13
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
%22 = or i32 %21, 7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %34
24: ; preds = %13
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %30
30: ; preds = %27, %24
br label %34
31: ; preds = %13
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %31, %30, %19, %16, %15
%35 = load i32, i32* %4
%36 = trunc i32 %35 to i8
%37 = call i32 @putchar(i8 signext %36)
%38 = load i32, i32* %6
%39 = icmp sge i32 %38, 80
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i32, i32* %6
%42 = sub nsw i32 %41, 80
store i32 %42, i32* %6
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %45
45: ; preds = %40, %34
%46 = load i32, i32* %5
%47 = icmp slt i32 %46, 24
br i1 %47, label %48, label %49
48: ; preds = %45
br label %8
49: ; preds = %45
%50 = load i32, i32* %6
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @putchar(i8 signext 10)
br label %54
54: ; preds = %52, %49
%55 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%56 = load i32, i32* @stdout
%57 = call i32 @fflush(i32 %56)
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%59 = call i64 @read(i32 0, i8* %58, i32 80)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %54
store i32 0, i32* %2
br label %78
62: ; preds = %54
%63 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
store i32 %65, i32* %4
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 58
br i1 %67, label %68, label %72
68: ; preds = %62
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 1
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
store i32 %71, i32* %4
br label %72
72: ; preds = %68, %62
%73 = load i32, i32* %4
switch i32 %73, label %76 [
i32 78, label %74
i32 110, label %74
i32 81, label %75
i32 113, label %75
]
74: ; preds = %72, %72
store i32 1, i32* %2
br label %78
75: ; preds = %72, %72
store i32 0, i32* %2
br label %78
76: ; preds = %72
store i32 0, i32* %6
store i32 1, i32* %5
br label %8
77: ; preds = %8
store i32 1, i32* %2
br label %78
78: ; preds = %77, %75, %74, %61
%79 = load i32, i32* %2
ret i32 %79
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [9 x i8] c"--More--\00"
@stdout = global i32 0
define i32 @more(i32* nocapture %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @fgetc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %60, label %7
7: ; preds = %1
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 1
br label %9
9: ; preds = %7, %36
%10 = phi i32 [ %4, %7 ], [ %39, %36 ]
%11 = phi i32 [ 0, %7 ], [ %38, %36 ]
%12 = phi i32 [ 1, %7 ], [ %37, %36 ]
switch i32 %10, label %23 [
i32 13, label %25
i32 10, label %13
i32 9, label %15
i32 8, label %19
]
13: ; preds = %9
%14 = add nsw i32 %12, 1
br label %25
15: ; preds = %9
%16 = add nsw i32 %11, 1
%17 = or i32 %16, 7
%18 = add nsw i32 %17, 1
br label %25
19: ; preds = %9
%20 = icmp sgt i32 %11, 0
%21 = sext i1 %20 to i32
%22 = add nsw i32 %11, %21
br label %25
23: ; preds = %9
%24 = add nsw i32 %11, 1
br label %25
25: ; preds = %19, %9, %23, %15, %13
%26 = phi i32 [ %12, %23 ], [ %12, %15 ], [ %14, %13 ], [ %12, %9 ], [ %12, %19 ]
%27 = phi i32 [ %24, %23 ], [ %18, %15 ], [ 0, %13 ], [ 0, %9 ], [ %22, %19 ]
%28 = trunc i32 %10 to i8
%29 = tail call i32 @putchar(i8 signext %28)
%30 = icmp sgt i32 %27, 79
%31 = add nsw i32 %27, -80
%32 = zext i1 %30 to i32
%33 = add nsw i32 %26, %32
%34 = select i1 %30, i32 %31, i32 %27
%35 = icmp slt i32 %33, 24
br i1 %35, label %36, label %42
36: ; preds = %25, %52
%37 = phi i32 [ %33, %25 ], [ 1, %52 ]
%38 = phi i32 [ %34, %25 ], [ 0, %52 ]
%39 = tail call i32 @fgetc(i32* %0)
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %58, label %9
42: ; preds = %25
%43 = icmp sgt i32 %34, 0
br i1 %43, label %44, label %46
44: ; preds = %42
%45 = tail call i32 @putchar(i8 signext 10)
br label %46
46: ; preds = %44, %42
%47 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%48 = load i32, i32* @stdout
%49 = tail call i32 @fflush(i32 %48)
%50 = call i64 @read(i32 0, i8* %3, i32 80)
%51 = icmp slt i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %46
%53 = load i8, i8* %3
%54 = icmp eq i8 %53, 58
%55 = load i8, i8* %8
%56 = select i1 %54, i8 %55, i8 %53
%57 = sext i8 %56 to i32
switch i32 %57, label %36 [
i32 78, label %58
i32 110, label %58
i32 81, label %60
i32 113, label %60
]
58: ; preds = %36, %52, %52, %46
%59 = phi i32 [ 1, %36 ], [ 1, %52 ], [ 1, %52 ], [ 0, %46 ]
br label %60
60: ; preds = %52, %52, %58, %1
%61 = phi i32 [ 1, %1 ], [ %59, %58 ], [ 0, %52 ], [ 0, %52 ]
ret i32 %61
}