#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_FAILURE;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *infile, *outfile;
  int start;
  int end;
  char line[1024] = {0};
  int lineno = 1;
  if (argc < 3) {
    fprintf(stderr, "Usage: %s start end [infile] [outfile]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  start = atoi(argv[1]);
  end = atoi(argv[2]);
  if (argc > 3) {
    infile = fopen(argv[3], "r");
    if (infile == NULL) {
      fprintf(stderr, "Could not open %s\n", argv[3]);
      exit(EXIT_FAILURE);
    }
  } else
    infile = stdin;
  if (argc > 4) {
    outfile = fopen(argv[4], "w");
    if (outfile == NULL) {
      fprintf(stderr, "Could not open %s\n", argv[4]);
      exit(EXIT_FAILURE);
    }
  } else
    outfile = stdout;
  while (fgets(line, 1024, infile)) {
    if (lineno > end)
      break;
    if (lineno >= start)
      fprintf(outfile, "%s", line);
    lineno++;
  }
  fclose(infile);
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x1,-0x434(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11db <main+0x6b>
mov    0x2e21(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe38(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1259 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe14(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1254 <main+0xe4>
mov    0x2da9(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xde9(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1267 <main+0xf7>
mov    0x2d88(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    12c5 <main+0x155>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdbd(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12c0 <main+0x150>
mov    0x2d3d(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xd7d(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    12d3 <main+0x163>
mov    0x2cfc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12d8 <main+0x168>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1345 <main+0x1d5>
mov    -0x434(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    130b <main+0x19b>
jmp    1345 <main+0x1d5>
mov    -0x434(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     1331 <main+0x1c1>
mov    -0x20(%rbp),%rdi
lea    -0x430(%rbp),%rdx
lea    0xd13(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    12d8 <main+0x168>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
cmp    $0x2,%r12d
jle    12b3 <main+0x133>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r13d
cmp    $0x3,%r12d
jne    11da <main+0x5a>
mov    0x2e13(%rip),%rax
mov    (%rax),%r15
jmp    1227 <main+0xa7>
mov    0x18(%rbx),%rdi
lea    0xe43(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12c9 <main+0x149>
mov    %rax,%r15
cmp    $0x5,%r12d
jb     1227 <main+0xa7>
mov    0x20(%rbx),%rdi
lea    0xe36(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1231 <main+0xb1>
mov    0x2dbd(%rip),%rax
mov    (%rax),%rdi
mov    0x20(%rbx),%rdx
jmp    12d7 <main+0x157>
mov    0x2d9a(%rip),%rax
mov    (%rax),%r12
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     128f <main+0x10f>
test   %r13d,%r13d
jle    128f <main+0x10f>
mov    $0x1,%ebx
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r14d,%ebx
jl     1270 <main+0xf0>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <fputs@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     128f <main+0x10f>
lea    0x1(%rbx),%eax
cmp    %r13d,%ebx
mov    %eax,%ebx
jl     1260 <main+0xe0>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d1e(%rip),%rax
mov    (%rax),%rdi
mov    (%rbx),%rdx
lea    0xd39(%rip),%rsi
jmp    12de <main+0x15e>
mov    0x2d08(%rip),%rax
mov    (%rax),%rdi
mov    0x18(%rbx),%rdx
lea    0xd4c(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [40 x i8] c"Usage: %s start end [infile] [outfile]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.4 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1024 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [1024 x i8]* %10 to i8*
store i32 1, i32* %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32*, i32** @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %8
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %9
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 3
br i1 %33, label %34, label %50
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %6
%39 = load i32*, i32** %6
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %49
41: ; preds = %34
%42 = load i32*, i32** @stderr
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %34
br label %52
50: ; preds = %23
%51 = load i32*, i32** @stdin
store i32* %51, i32** %6
br label %52
52: ; preds = %50, %49
%53 = load i32, i32* %4
%54 = icmp sgt i32 %53, 4
br i1 %54, label %55, label %71
55: ; preds = %52
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 4
%58 = load i8*, i8** %57
%59 = call i32* @fopen(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %59, i32** %7
%60 = load i32*, i32** %7
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %70
62: ; preds = %55
%63 = load i32*, i32** @stderr
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 4
%66 = load i8*, i8** %65
%67 = call i32 @fprintf(i32* %63, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %55
br label %73
71: ; preds = %52
%72 = load i32*, i32** @stdout
store i32* %72, i32** %7
br label %73
73: ; preds = %71, %70
br label %74
74: ; preds = %92, %73
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%76 = load i32*, i32** %6
%77 = call i64 @fgets(i8* %75, i32 1024, i32* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %95
79: ; preds = %74
%80 = load i32, i32* %11
%81 = load i32, i32* %9
%82 = icmp sgt i32 %80, %81
br i1 %82, label %83, label %84
83: ; preds = %79
br label %95
84: ; preds = %79
%85 = load i32, i32* %11
%86 = load i32, i32* %8
%87 = icmp sge i32 %85, %86
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = load i32*, i32** %7
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%91 = call i32 @fprintf(i32* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %88, %84
%93 = load i32, i32* %11
%94 = add nsw i32 %93, 1
store i32 %94, i32* %11
br label %74
95: ; preds = %83, %74
%96 = load i32*, i32** %6
%97 = call i32 @fclose(i32* %96)
%98 = load i32*, i32** %7
%99 = call i32 @fclose(i32* %98)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [40 x i8] c"Usage: %s start end [infile] [outfile]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
@stdin = global i32* null
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32* null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = icmp eq i32 %0, 3
br i1 %19, label %31, label %20
20: ; preds = %12
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load i32*, i32** @stderr
%27 = load i8*, i8** %21
%28 = tail call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %12
%32 = load i32*, i32** @stdin
br label %46
33: ; preds = %20
%34 = icmp ugt i32 %0, 4
br i1 %34, label %35, label %46
35: ; preds = %33
%36 = getelementptr inbounds i8*, i8** %1, i64 4
%37 = load i8*, i8** %36
%38 = tail call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %49
40: ; preds = %35
%41 = load i32*, i32** @stderr
%42 = load i8*, i8** %36
%43 = tail call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %31, %33
%47 = phi i32* [ %32, %31 ], [ %23, %33 ]
%48 = load i32*, i32** @stdout
br label %49
49: ; preds = %35, %46
%50 = phi i32* [ %23, %35 ], [ %47, %46 ]
%51 = phi i32* [ %38, %35 ], [ %48, %46 ]
%52 = call i64 @fgets(i8* %4, i32 1024, i32* %50)
%53 = icmp eq i64 %52, 0
%54 = icmp slt i32 %18, 1
%55 = select i1 %53, i1 true, i1 %54
br i1 %55, label %67, label %56
56: ; preds = %49, %61
%57 = phi i32 [ %62, %61 ], [ 1, %49 ]
%58 = icmp slt i32 %57, %15
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = call i32 @fputs(i8* %4, i32* %51)
br label %61
61: ; preds = %59, %56
%62 = add nuw nsw i32 %57, 1
%63 = call i64 @fgets(i8* %4, i32 1024, i32* %50)
%64 = icmp eq i64 %63, 0
%65 = icmp sge i32 %57, %18
%66 = select i1 %64, i1 true, i1 %65
br i1 %66, label %67, label %56
67: ; preds = %61, %49
%68 = call i32 @fclose(i32* %50)
%69 = call i32 @fclose(i32* %51)
ret i32 0
}