#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
void printpages(FILE *ifp, FILE *ofp) {
  int c;
  int line = 0;
  int pg = 1;
  while ((c = getc(ifp)) != EOF) {
    putc(c, ofp);
    if (c == '\n') {
      line = line + 1;
      if (line == 10) {
        fprintf(stdout, "\n\t\t\tPage %d End.\n\n", pg);
        pg = pg + 1;
        line = 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<printpages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e87(%rip),%rcx
cmp    (%rcx),%eax
je     11c4 <printpages+0x94>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
cmpl   $0xa,-0x14(%rbp)
jne    11bf <printpages+0x8f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jne    11ba <printpages+0x8a>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe5b(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11bf <printpages+0x8f>
jmp    114e <printpages+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpages>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <getc@plt>
mov    0x2e9b(%rip),%r13
cmp    0x0(%r13),%eax
jne    1162 <printpages+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
xor    %r15d,%r15d
mov    $0x1,%r12d
jmp    1180 <printpages+0x50>
nop
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     1153 <printpages+0x23>
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
cmp    $0xa,%ebp
jne    1170 <printpages+0x40>
add    $0x1,%r15d
cmp    $0xa,%r15d
jne    1170 <printpages+0x40>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
mov    %r12d,%edx
call   1040 <fprintf@plt>
add    $0x1,%r12d
xor    %r15d,%r15d
jmp    1170 <printpages+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@stdout = global i32 0
@.str = [19 x i8] c"\0A\09\09\09Page %d End.\0A\0A\00"
define void @printpages(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 1, i32* %7
br label %8
8: ; preds = %31, %2
%9 = load i32*, i32** %3
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %8
%14 = load i32, i32* %5
%15 = load i32*, i32** %4
%16 = call i32 @putc(i32 %14, i32* %15)
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %31
19: ; preds = %13
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load i32, i32* @stdout
%26 = load i32, i32* %7
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
store i32 0, i32* %6
br label %30
30: ; preds = %24, %19
br label %31
31: ; preds = %30, %13
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@stdout = global i32 0
@.str = [19 x i8] c"\0A\09\09\09Page %d End.\0A\0A\00"
define void @printpages(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %25, label %6
6: ; preds = %2, %19
%7 = phi i32 [ %22, %19 ], [ %3, %2 ]
%8 = phi i32 [ %21, %19 ], [ 1, %2 ]
%9 = phi i32 [ %20, %19 ], [ 0, %2 ]
%10 = tail call i32 @putc(i32 %7, i32* %1)
%11 = icmp eq i32 %7, 10
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = add nsw i32 %9, 1
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @stdout
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
%18 = add nsw i32 %8, 1
br label %19
19: ; preds = %12, %15, %6
%20 = phi i32 [ 0, %15 ], [ %13, %12 ], [ %9, %6 ]
%21 = phi i32 [ %18, %15 ], [ %8, %12 ], [ %8, %6 ]
%22 = tail call i32 @getc(i32* %0)
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %6
25: ; preds = %19, %2
ret void
}