#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int main() {
  char str[1000];
  FILE *fi;
  int a = 0, ch;
  while (1) {
    fscanf(stdin, "%s", str);
    if (feof(stdin))
      break;
    fi = fopen(str, "rb");
    while (1) {
      printf("%d ", a);
      ch = 0;
      while (ch != '\n') {
        ch = fgetc(fi);
        if (feof(fi))
          break;
        fputc(ch, stdout);
      }
      ch = fgetc(fi);
      if (feof(fi))
        break;
      ungetc(ch, fi);
    }
    a++;
    fclose(fi);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3fc(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%rdi
lea    -0x3f0(%rbp),%rdx
lea    0xe4c(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     11d7 <main+0x57>
jmp    12c4 <main+0x144>
lea    -0x3f0(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x3f8(%rbp)
mov    -0x3fc(%rbp),%esi
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x400(%rbp)
cmpl   $0xa,-0x400(%rbp)
je     1260 <main+0xe0>
mov    -0x3f8(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x400(%rbp)
mov    -0x3f8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1247 <main+0xc7>
jmp    1260 <main+0xe0>
mov    -0x400(%rbp),%edi
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
call   1070 <fputc@plt>
jmp    120d <main+0x8d>
mov    -0x3f8(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x400(%rbp)
mov    -0x3f8(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     128d <main+0x10d>
jmp    12a4 <main+0x124>
mov    -0x400(%rbp),%edi
mov    -0x3f8(%rbp),%rsi
call   1090 <ungetc@plt>
jmp    11f1 <main+0x71>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
mov    -0x3f8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    119c <main+0x1c>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    0x2e50(%rip),%rbx
mov    (%rbx),%rdi
lea    0xe5e(%rip),%rsi
mov    %rsp,%rdx
call   1050 <fscanf@plt>
mov    (%rbx),%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     11cb <main+0x4b>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
mov    %rsp,%rbp
lea    0xe2e(%rip),%r12
mov    0x2df9(%rip),%r15
jmp    1225 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    0x2de5(%rip),%rbx
mov    (%rbx),%rdi
lea    0xdf3(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdx
call   1050 <fscanf@plt>
mov    (%rbx),%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11b7 <main+0x37>
mov    %rbp,%rdi
lea    0xdd4(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    1279 <main+0xf9>
mov    (%r15),%esi
mov    %r14d,%edi
call   1070 <fputc@plt>
cmp    $0xa,%r14d
jne    1250 <main+0xd0>
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11f0 <main+0x70>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1090 <ungetc@plt>
jmp    1240 <main+0xc0>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%d \00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %0, %45
%7 = load i32*, i32** @stdin
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%9 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32*, i32** @stdin
%11 = call i64 @feof(i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %6
br label %50
14: ; preds = %6
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %3
br label %17
17: ; preds = %14, %41
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
store i32 0, i32* %5
br label %20
20: ; preds = %30, %17
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i32*, i32** %3
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %5
%26 = load i32*, i32** %3
%27 = call i64 @feof(i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
br label %34
30: ; preds = %23
%31 = load i32, i32* %5
%32 = load i32, i32* @stdout
%33 = call i32 @fputc(i32 %31, i32 %32)
br label %20
34: ; preds = %29, %20
%35 = load i32*, i32** %3
%36 = call i32 @fgetc(i32* %35)
store i32 %36, i32* %5
%37 = load i32*, i32** %3
%38 = call i64 @feof(i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
br label %45
41: ; preds = %34
%42 = load i32, i32* %5
%43 = load i32*, i32** %3
%44 = call i32 @ungetc(i32 %42, i32* %43)
br label %17
45: ; preds = %40
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
%48 = load i32*, i32** %3
%49 = call i32 @fclose(i32* %48)
br label %6
50: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%d \00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = load i32*, i32** @stdin
%4 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = load i32*, i32** @stdin
%6 = call i64 @feof(i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %0, %27
%9 = phi i32 [ %28, %27 ], [ 0, %0 ]
%10 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %25, %8
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %13
13: ; preds = %11, %17
%14 = call i32 @fgetc(i32* %10)
%15 = call i64 @feof(i32* %10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @stdout
%19 = call i32 @fputc(i32 %14, i32 %18)
%20 = icmp eq i32 %14, 10
br i1 %20, label %21, label %13
21: ; preds = %13, %17
%22 = call i32 @fgetc(i32* %10)
%23 = call i64 @feof(i32* %10)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @ungetc(i32 %22, i32* %10)
br label %11
27: ; preds = %21
%28 = add nuw nsw i32 %9, 1
%29 = call i32 @fclose(i32* %10)
%30 = load i32*, i32** @stdin
%31 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%32 = load i32*, i32** @stdin
%33 = call i64 @feof(i32* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %8, label %35
35: ; preds = %27, %0
ret i32 0
}