#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 */
scalar_t__ EOF;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ fputs(char *, int /*<<< orphan*/);
int see_more();
int /*<<< orphan*/ stdout;
void b_more(FILE *fp) {
  char line[512];
  int num_of_lines = 0;
  int reply;
  while (fgets(line, 512, fp)) {
    if (num_of_lines == 24) {
      reply = see_more();
      if (reply == 0)
        break;
      num_of_lines -= reply;
    }
    if (fputs(line, stdout) == EOF)
      return;
    num_of_lines++;
  }
}


x86 assembly (clang, -O0):
<b_more>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11e6 <b_more+0xb6>
cmpl   $0x18,-0x214(%rbp)
jne    11a8 <b_more+0x78>
mov    $0x0,%al
call   1030 <see_more@plt>
mov    %eax,-0x218(%rbp)
cmpl   $0x0,-0x218(%rbp)
jne    1194 <b_more+0x64>
jmp    11e6 <b_more+0xb6>
mov    -0x218(%rbp),%ecx
mov    -0x214(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
jne    11d2 <b_more+0xa2>
jmp    11e6 <b_more+0xb6>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    1149 <b_more+0x19>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_more>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b0 <b_more+0x80>
mov    0x2e7a(%rip),%r15
mov    %rsp,%rbx
mov    0x2e80(%rip),%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
cmp    $0x18,%ebp
jne    1187 <b_more+0x57>
xor    %eax,%eax
call   1030 <see_more@plt>
test   %eax,%eax
je     11b0 <b_more+0x80>
mov    $0x18,%ebp
sub    %eax,%ebp
mov    (%r15),%esi
mov    %rbx,%rdi
call   1040 <fputs@plt>
cmp    (%r12),%rax
je     11b0 <b_more+0x80>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1170 <b_more+0x40>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@EOF = global i64 0
define void @b_more(i32* %0) {
%2 = alloca i32*
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %6
6: ; preds = %30, %1
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = call i64 @fgets(i8* %7, i32 512, i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 24
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i32 (...) @see_more()
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
br label %33
19: ; preds = %14
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, %20
store i32 %22, i32* %4
br label %23
23: ; preds = %19, %11
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%25 = load i32, i32* @stdout
%26 = call i64 @fputs(i8* %24, i32 %25)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %23
br label %33
30: ; preds = %23
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %6
33: ; preds = %29, %18, %6
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@EOF = global i64 0
define void @b_more(i32* nocapture %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = call i64 @fgets(i8* %3, i32 512, i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %24, label %10
6: ; preds = %18
%7 = add nsw i32 %19, 1
%8 = call i64 @fgets(i8* %3, i32 512, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %1, %6
%11 = phi i32 [ %7, %6 ], [ 0, %1 ]
%12 = icmp eq i32 %11, 24
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call i32 (...) @see_more()
%15 = icmp eq i32 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %13
%17 = sub nsw i32 24, %14
br label %18
18: ; preds = %16, %10
%19 = phi i32 [ %17, %16 ], [ %11, %10 ]
%20 = load i32, i32* @stdout
%21 = call i64 @fputs(i8* %3, i32 %20)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %6
24: ; preds = %18, %13, %6, %1
ret void
}