#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int extract_from_line_to_line(char *path, unsigned int from, unsigned int to) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int number = 1;
  fp = fopen(path, "r");
  if (fp == NULL)
    exit(EXIT_FAILURE);
  while ((read = getline(&line, &len, fp)) != -1) {
    if (number > to)
      break;
    if (number >= from)
      printf("%s", line);
    number++;
  }
  fclose(fp);
  if (line)
    free(line);
  return number - from;
}


x86 assembly (clang, -O0):
<extract_from_line_to_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b6 <extract_from_line_to_line+0x56>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11bb <extract_from_line_to_line+0x5b>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1213 <extract_from_line_to_line+0xb3>
mov    -0x30(%rbp),%eax
cmp    -0x10(%rbp),%eax
jbe    11e9 <extract_from_line_to_line+0x89>
jmp    1213 <extract_from_line_to_line+0xb3>
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jb     1205 <extract_from_line_to_line+0xa5>
mov    -0x20(%rbp),%rsi
lea    0xe02(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11bb <extract_from_line_to_line+0x5b>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     1230 <extract_from_line_to_line+0xd0>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_from_line_to_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %esi,%r14d
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe73(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1233 <extract_from_line_to_line+0xd3>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1070 <getline@plt>
mov    $0x1,%ebp
cmp    $0xffffffff,%eax
je     1208 <extract_from_line_to_line+0xa8>
test   %r15d,%r15d
je     1208 <extract_from_line_to_line+0xa8>
mov    $0x1,%r12d
lea    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
cmp    %r14d,%r12d
jb     11e6 <extract_from_line_to_line+0x86>
mov    0x8(%rsp),%rsi
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
lea    0x1(%r12),%ebp
lea    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     1208 <extract_from_line_to_line+0xa8>
cmp    %r15d,%r12d
mov    %ebp,%r12d
jb     11d0 <extract_from_line_to_line+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     121f <extract_from_line_to_line+0xbf>
call   1030 <free@plt>
sub    %r14d,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @extract_from_line_to_line(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%12 = icmp eq i32 %11, -1
%13 = icmp eq i32 %2, 0
%14 = or i1 %12, %13
br i1 %14, label %30, label %18
15: ; preds = %3
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %10, %24
%19 = phi i32 [ %25, %24 ], [ 1, %10 ]
%20 = icmp ult i32 %19, %1
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %18
%25 = add nuw nsw i32 %19, 1
%26 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%27 = icmp eq i32 %26, -1
%28 = icmp uge i32 %19, %2
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %30, label %18
30: ; preds = %24, %10
%31 = phi i32 [ 1, %10 ], [ %25, %24 ]
%32 = call i32 @fclose(i32* %8)
%33 = load i8*, i8** %4
%34 = icmp eq i8* %33, null
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = call i32 @free(i8* %33)
br label %37
37: ; preds = %35, %30
%38 = sub i32 %31, %1
ret i32 %38
}