#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ atoi(char *);
int /*<<< orphan*/ lseek(int, scalar_t__, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd = open(argv[1], O_RDONLY);
  lseek(fd, atoi(argv[2]) - 1, SEEK_SET);
  int cnt;
  char buffer[20];
  while (cnt = read(fd, buffer, 20))
    write(1, buffer, cnt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rsi
sub    $0x1,%rsi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x14,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     11dd <main+0x8d>
lea    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    11aa <main+0x5a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
lea    -0x1(%rax),%rsi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1040 <lseek@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x14,%edx
call   1050 <read@plt>
test   %eax,%eax
je     11c2 <main+0x72>
mov    %rsp,%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x14,%edx
call   1050 <read@plt>
test   %eax,%eax
jne    11a0 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = call i32 @open(i8* %11, i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
%19 = sub nsw i64 %18, 1
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @lseek(i32 %14, i64 %19, i32 %20)
br label %22
22: ; preds = %27, %2
%23 = load i32, i32* %6
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%25 = call i32 @read(i32 %23, i8* %24, i32 20)
store i32 %25, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%29 = load i32, i32* %7
%30 = call i32 @write(i32 1, i8* %28, i32 %29)
br label %22
31: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* %5, i32 %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i64 @atoi(i8* %9)
%11 = add nsw i64 %10, -1
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @lseek(i32 %7, i64 %11, i32 %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%15 = call i32 @read(i32 %7, i8* %14, i32 20)
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %2, %17
%18 = phi i32 [ %20, %17 ], [ %15, %2 ]
%19 = call i32 @write(i32 1, i8* %14, i32 %18)
%20 = call i32 @read(i32 %7, i8* %14, i32 20)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %17
22: ; preds = %17, %2
ret i32 0
}