#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int fetch(long *f, int a, int b, FILE *lb, char *s) {
  register int i, j;
  register int nc;
  for (i = a; i <= b; i++) {
    fseek(lb, f[i - 1], 0);
    nc = f[i] - f[i - 1];
    fputs(s, stdout);
    for (j = 0; j < nc; j++)
      putchar(getc(lb));
  }
}


x86 assembly (clang, -O0):
<fetch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11fe <fetch+0xbe>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
xor    %edx,%edx
call   1050 <fseek@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x10(%rbp),%rcx
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
sub    (%rcx,%rdx,8),%rax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11eb <fetch+0xab>
mov    -0x20(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c1 <fetch+0x81>
jmp    11f0 <fetch+0xb0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1160 <fetch+0x20>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fetch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %edx,%esi
jle    115e <fetch+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r8,%r14
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rdi,%r12
movslq %esi,%rbp
add    $0x1,%r15d
jmp    1189 <fetch+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    %ebp,%r15d
je     114f <fetch+0xf>
mov    -0x8(%r12,%rbp,8),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <fseek@plt>
mov    (%r12,%rbp,8),%r13d
sub    -0x8(%r12,%rbp,8),%r13d
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <fputs@plt>
test   %r13d,%r13d
jle    1180 <fetch+0x40>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r13d
jne    11c0 <fetch+0x80>
jmp    1180 <fetch+0x40>

LLVM IR (-O0):
@stdout = global i32 0
define i32 @fetch(i64* %0, i32 %1, i32 %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i64* %0, i64** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i8* %4, i8** %11
%15 = load i32, i32* %8
store i32 %15, i32* %12
br label %16
16: ; preds = %57, %5
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %60
20: ; preds = %16
%21 = load i32*, i32** %10
%22 = load i64*, i64** %7
%23 = load i32, i32* %12
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i64, i64* %22, i64 %25
%27 = load i64, i64* %26
%28 = call i32 @fseek(i32* %21, i64 %27, i32 0)
%29 = load i64*, i64** %7
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i64, i64* %29, i64 %31
%33 = load i64, i64* %32
%34 = load i64*, i64** %7
%35 = load i32, i32* %12
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i64, i64* %34, i64 %37
%39 = load i64, i64* %38
%40 = sub nsw i64 %33, %39
%41 = trunc i64 %40 to i32
store i32 %41, i32* %14
%42 = load i8*, i8** %11
%43 = load i32, i32* @stdout
%44 = call i32 @fputs(i8* %42, i32 %43)
store i32 0, i32* %13
br label %45
45: ; preds = %53, %20
%46 = load i32, i32* %13
%47 = load i32, i32* %14
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %56
49: ; preds = %45
%50 = load i32*, i32** %10
%51 = call i32 @getc(i32* %50)
%52 = call i32 @putchar(i32 %51)
br label %53
53: ; preds = %49
%54 = load i32, i32* %13
%55 = add nsw i32 %54, 1
store i32 %55, i32* %13
br label %45
56: ; preds = %45
br label %57
57: ; preds = %56
%58 = load i32, i32* %12
%59 = add nsw i32 %58, 1
store i32 %59, i32* %12
br label %16
60: ; preds = %16
%61 = load i32, i32* %6
ret i32 %61
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @fetch(i64* nocapture %0, i32 %1, i32 %2, i32* nocapture %3, i8* %4) {
%6 = icmp sgt i32 %1, %2
br i1 %6, label %34, label %7
7: ; preds = %5
%8 = sext i32 %1 to i64
%9 = add i32 %2, 1
br label %10
10: ; preds = %7, %30
%11 = phi i64 [ %8, %7 ], [ %31, %30 ]
%12 = add nsw i64 %11, -1
%13 = getelementptr inbounds i64, i64* %0, i64 %12
%14 = load i64, i64* %13
%15 = tail call i32 @fseek(i32* %3, i64 %14, i32 0)
%16 = getelementptr inbounds i64, i64* %0, i64 %11
%17 = load i64, i64* %16
%18 = load i64, i64* %13
%19 = sub nsw i64 %17, %18
%20 = trunc i64 %19 to i32
%21 = load i32, i32* @stdout
%22 = tail call i32 @fputs(i8* %4, i32 %21)
%23 = icmp sgt i32 %20, 0
br i1 %23, label %24, label %30
24: ; preds = %10, %24
%25 = phi i32 [ %28, %24 ], [ 0, %10 ]
%26 = tail call i32 @getc(i32* %3)
%27 = tail call i32 @putchar(i32 %26)
%28 = add nuw nsw i32 %25, 1
%29 = icmp eq i32 %28, %20
br i1 %29, label %30, label %24
30: ; preds = %24, %10
%31 = add nsw i64 %11, 1
%32 = trunc i64 %31 to i32
%33 = icmp eq i32 %9, %32
br i1 %33, label %34, label %10
34: ; preds = %30, %5
ret i32 undef
}