#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;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int see_more();
int /*<<< orphan*/ stdout;
extern void do_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) {
        exit(EXIT_SUCCESS);
      }
      num_of_lines -= reply;
    }
    if (fputs(line, stdout) == EOF) {
      printf("No more lines.\n");
      exit(EXIT_SUCCESS);
    }
    ++num_of_lines;
  }
}


x86 assembly (clang, -O0):
<do_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   1060 <fgets@plt>
cmp    $0x0,%rax
je     1224 <do_more+0xd4>
cmpl   $0x18,-0x214(%rbp)
jne    11d1 <do_more+0x81>
mov    $0x0,%al
call   1030 <see_more@plt>
mov    %eax,-0x218(%rbp)
cmpl   $0x0,-0x218(%rbp)
jne    11bd <do_more+0x6d>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x218(%rbp),%ecx
mov    -0x214(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%rax
jne    1210 <do_more+0xc0>
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    1169 <do_more+0x19>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_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   1060 <fgets@plt>
test   %rax,%rax
je     11d0 <do_more+0x80>
mov    0x2e5a(%rip),%r15
mov    %rsp,%rbx
mov    0x2e60(%rip),%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
cmp    $0x18,%ebp
jne    11a7 <do_more+0x57>
xor    %eax,%eax
call   1030 <see_more@plt>
test   %eax,%eax
je     11ec <do_more+0x9c>
mov    $0x18,%ebp
sub    %eax,%ebp
mov    (%r15),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
cmp    (%r12),%rax
je     11e0 <do_more+0x90>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1190 <do_more+0x40>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stdout = global i32 0
@EOF = global i64 0
@.str = [16 x i8] c"No more lines.\0A\00"
define void @do_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 = %35, %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 %38
11: ; preds = %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 24
br i1 %13, label %14, label %25
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 %21
18: ; preds = %14
%19 = load i32, i32* @EXIT_SUCCESS
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %14
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, %22
store i32 %24, i32* %4
br label %25
25: ; preds = %21, %11
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%27 = load i32, i32* @stdout
%28 = call i64 @fputs(i8* %26, i32 %27)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* @EXIT_SUCCESS
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %25
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %6
38: ; preds = %6
ret void
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stdout = global i32 0
@EOF = global i64 0
@str = [15 x i8] c"No more lines.\00"
define void @do_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 %31, label %10
6: ; preds = %21
%7 = add nsw i32 %22, 1
%8 = call i64 @fgets(i8* %3, i32 512, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %31, 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 %21
13: ; preds = %10
%14 = call i32 (...) @see_more()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %13
%20 = sub nsw i32 24, %14
br label %21
21: ; preds = %19, %10
%22 = phi i32 [ %20, %19 ], [ %11, %10 ]
%23 = load i32, i32* @stdout
%24 = call i64 @fputs(i8* %3, i32 %23)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %6
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%29 = load i32, i32* @EXIT_SUCCESS
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %6, %1
ret void
}