#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*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char);
void readBytes(FILE *myFile, long int offset, long int charsRead) {
  char ch;
  for (long int i = offset; i < offset + charsRead; i++) {
    fseek(myFile, i, SEEK_SET);
    char ch = getc(myFile);
    printf("%c", ch);
  }
}


x86 assembly (clang, -O0):
<readBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
cmp    %rcx,%rax
jge    11a4 <readBytes+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %al,-0x29(%rbp)
lea    0xe76(%rip),%rdi
movsbl -0x29(%rbp),%esi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    114c <readBytes+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readBytes>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdx,%rdx
jle    118b <readBytes+0x5b>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
add    %rsi,%r14
mov    0x2e8f(%rip),%r13
lea    0xea8(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <fseek@plt>
mov    %r15,%rdi
call   1050 <getc@plt>
movsbl %al,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %r14,%rbx
jl     1160 <readBytes+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
define void @readBytes(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
%8 = alloca i64
%9 = alloca i8
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%10 = load i64, i64* %5
store i64 %10, i64* %8
br label %11
11: ; preds = %26, %3
%12 = load i64, i64* %8
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = add nsw i64 %13, %14
%16 = icmp slt i64 %12, %15
br i1 %16, label %17, label %29
17: ; preds = %11
%18 = load i32*, i32** %4
%19 = load i64, i64* %8
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %18, i64 %19, i32 %20)
%22 = load i32*, i32** %4
%23 = call signext i8 @getc(i32* %22)
store i8 %23, i8* %9
%24 = load i8, i8* %9
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %24)
br label %26
26: ; preds = %17
%27 = load i64, i64* %8
%28 = add nsw i64 %27, 1
store i64 %28, i64* %8
br label %11
29: ; preds = %11
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
define void @readBytes(i32* nocapture %0, i64 %1, i64 %2) {
%4 = add nsw i64 %2, %1
%5 = icmp sgt i64 %2, 0
br i1 %5, label %7, label %6
6: ; preds = %7, %3
ret void
7: ; preds = %3, %7
%8 = phi i64 [ %13, %7 ], [ %1, %3 ]
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %0, i64 %8, i32 %9)
%11 = tail call signext i8 @getc(i32* %0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = add nsw i64 %8, 1
%14 = icmp slt i64 %13, %4
br i1 %14, label %7, label %6
}