#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char line[1000];
  int pageno = 0, filepage = 0;
  int lineno;
  FILE *in;
  char filename[100];
  if (argc == 1)
    printf("Usage: cat file...\n");
  else {
    while (--argc > 0) {
      sprintf(filename, "%s", *++argv);
      if ((in = fopen(filename, "r")) == NULL) {
        fprintf(stderr, "can't open input %s\n", filename);
        exit(1);
      }
      lineno = 0;
      filepage = 0;
      while (fgets(line, 1000, in) != NULL) {
        if (lineno++ % 10 == 0) {
          printf("------------%s:%d------------\n", filename, ++filepage);
          lineno = 2;
        }
        printf("%s", line);
        if (lineno == 10)
          printf("------------%d------------\n", ++pageno);
      }
      if (lineno < 10) {
        while (lineno++ < 10)
          printf("\n");
        printf("------------%d------------\n", ++pageno);
      }
      fclose(in);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x404(%rbp)
movl   $0x0,-0x408(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ba <main+0x4a>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    137d <main+0x20d>
jmp    11bf <main+0x4f>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1378 <main+0x208>
lea    -0x480(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdx
lea    0xe22(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x480(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    1241 <main+0xd1>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    -0x480(%rbp),%rdx
lea    0xde7(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x40c(%rbp)
movl   $0x0,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     130b <main+0x19b>
mov    -0x40c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x40c(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12c7 <main+0x157>
lea    -0x480(%rbp),%rsi
mov    -0x408(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0x408(%rbp)
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x40c(%rbp)
lea    -0x400(%rbp),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xa,-0x40c(%rbp)
jne    1306 <main+0x196>
mov    -0x404(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x404(%rbp)
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1255 <main+0xe5>
cmpl   $0xa,-0x40c(%rbp)
jge    1367 <main+0x1f7>
jmp    131d <main+0x1ad>
mov    -0x40c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x40c(%rbp)
cmp    $0xa,%eax
jge    134a <main+0x1da>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131d <main+0x1ad>
mov    -0x404(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x404(%rbp)
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11bf <main+0x4f>
jmp    137d <main+0x20d>
xor    %eax,%eax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x468,%rsp
cmp    $0x1,%edi
jne    11b7 <main+0x27>
lea    0xea8(%rip),%rdi
call   1050 <puts@plt>
jmp    1339 <main+0x1a9>
jle    1339 <main+0x1a9>
mov    %rsi,%r14
mov    %edi,%ebp
lea    0x80(%rsp),%rbx
xor    %r12d,%r12d
jmp    11f1 <main+0x61>
nop
mov    0x8(%rsp),%rbp
lea    -0x1(%rbp),%r13d
add    $0x8,%r14
mov    %r15,%rdi
call   1060 <fclose@plt>
cmp    $0x2,%ebp
mov    %r13d,%ebp
jle    1339 <main+0x1a9>
mov    0x8(%r14),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xdf7(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     134d <main+0x1bd>
mov    %rax,%r15
mov    %rbp,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1300 <main+0x170>
mov    %r14,%rbp
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    1296 <main+0x106>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14d
lea    0xdbf(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd8f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%r13d
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12f0 <main+0x160>
imul   $0xcccccccd,%r13d,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
jbe    1250 <main+0xc0>
add    $0x1,%r13d
lea    0xd4a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0xa,%r13d
jne    1281 <main+0xf1>
add    $0x1,%r12d
lea    0xd68(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%r13d
jmp    1281 <main+0xf1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x9,%r13d
mov    %rbp,%r14
jg     11d0 <main+0x40>
jmp    1303 <main+0x173>
nop
xor    %r13d,%r13d
add    $0xfffffff6,%r13d
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
inc    %r13d
jne    1310 <main+0x180>
add    $0x1,%r12d
lea    0xd0f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
add    $0x468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
lea    0x10(%rsp),%rdx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Usage: cat file...\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"can't open input %s\0A\00"
@.str.4 = [31 x i8] c"------------%s:%d------------\0A\00"
@.str.5 = [28 x i8] c"------------%d------------\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %79
16: ; preds = %2
br label %17
17: ; preds = %75, %16
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %78
21: ; preds = %17
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %5
%25 = load i8*, i8** %24
%26 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %28, i32** %10
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %21
%31 = load i32, i32* @stderr
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %21
store i32 0, i32* %9
store i32 0, i32* %8
br label %36
36: ; preds = %60, %35
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%38 = load i32*, i32** %10
%39 = call i32* @fgets(i8* %37, i32 1000, i32* %38)
%40 = icmp ne i32* %39, null
br i1 %40, label %41, label %61
41: ; preds = %36
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
%44 = srem i32 %42, 10
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %41
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %47, i32 %49)
store i32 2, i32* %9
br label %51
51: ; preds = %46, %41
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = load i32, i32* %9
%55 = icmp eq i32 %54, 10
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %56, %51
br label %36
61: ; preds = %36
%62 = load i32, i32* %9
%63 = icmp slt i32 %62, 10
br i1 %63, label %64, label %75
64: ; preds = %61
br label %65
65: ; preds = %69, %64
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
%68 = icmp slt i32 %66, 10
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %65
71: ; preds = %65
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %71, %61
%76 = load i32*, i32** %10
%77 = call i32 @fclose(i32* %76)
br label %17
78: ; preds = %17
br label %79
79: ; preds = %78, %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"can't open input %s\0A\00"
@.str.4 = [31 x i8] c"------------%s:%d------------\0A\00"
@.str.5 = [28 x i8] c"------------%d------------\0A\00"
@str = [19 x i8] c"Usage: cat file...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 1
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %12, label %69
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %69
12: ; preds = %8, %65
%13 = phi i32 [ %16, %65 ], [ %0, %8 ]
%14 = phi i32 [ %66, %65 ], [ 0, %8 ]
%15 = phi i8** [ %17, %65 ], [ %1, %8 ]
%16 = add nsw i32 %13, -1
%17 = getelementptr inbounds i8*, i8** %15, i64 1
%18 = load i8*, i8** %17
%19 = call i8* @strcpy(i8* %6, i8* dereferenceable(1) %18)
%20 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %12
%23 = call i32* @fgets(i8* %5, i32 1000, i32* %20)
%24 = icmp eq i32* %23, null
br i1 %24, label %54, label %29
25: ; preds = %12
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %22, %46
%30 = phi i32 [ %47, %46 ], [ 0, %22 ]
%31 = phi i32 [ %48, %46 ], [ 0, %22 ]
%32 = phi i32 [ %49, %46 ], [ %14, %22 ]
%33 = add nsw i32 %30, 1
%34 = srem i32 %30, 10
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = add nsw i32 %31, 1
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %46
40: ; preds = %29
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%42 = icmp eq i32 %33, 10
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = add nsw i32 %32, 1
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %36, %43, %40
%47 = phi i32 [ 10, %43 ], [ %33, %40 ], [ 2, %36 ]
%48 = phi i32 [ %31, %43 ], [ %31, %40 ], [ %37, %36 ]
%49 = phi i32 [ %44, %43 ], [ %32, %40 ], [ %32, %36 ]
%50 = call i32* @fgets(i8* %5, i32 1000, i32* %20)
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %29
52: ; preds = %46
%53 = icmp slt i32 %47, 10
br i1 %53, label %54, label %65
54: ; preds = %22, %52
%55 = phi i32 [ %47, %52 ], [ 0, %22 ]
%56 = phi i32 [ %49, %52 ], [ %14, %22 ]
br label %57
57: ; preds = %54, %57
%58 = phi i32 [ %59, %57 ], [ %55, %54 ]
%59 = add i32 %58, 1
%60 = call i32 @putchar(i32 10)
%61 = icmp eq i32 %59, 10
br i1 %61, label %62, label %57
62: ; preds = %57
%63 = add nsw i32 %56, 1
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %62, %52
%66 = phi i32 [ %63, %62 ], [ %49, %52 ]
%67 = call i32 @fclose(i32* %20)
%68 = icmp sgt i32 %13, 2
br i1 %68, label %12, label %69
69: ; preds = %65, %8, %10
ret i32 0
}