#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;
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc <= 1) {
    printf("useage: seek file_path.\n");
    return 1;
  }
  int fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    printf("open %s fail.\n", argv[1]);
    return 1;
  }
  char buf[64] = {0};
  lseek(fd, 6, SEEK_SET);
  read(fd, buf, 64);
  printf("%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     118a <main+0x3a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11cf <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121f <main+0xcf>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%esi
call   1040 <lseek@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1060 <read@plt>
lea    -0x60(%rbp),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
cmp    $0x1,%edi
jg     1169 <main+0x19>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
jmp    11df <main+0x8f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
test   %eax,%eax
js     11cd <main+0x7d>
mov    %eax,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    $0x6,%esi
call   1050 <lseek@plt>
mov    %rsp,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1060 <read@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    11e4 <main+0x94>
mov    0x8(%rbx),%rsi
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"useage: seek file_path.\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [15 x i8] c"open %s fail.\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %35
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* %15, i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %35
25: ; preds = %12
%26 = bitcast [64 x i8]* %7 to i8*
%27 = load i32, i32* %6
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @lseek(i32 %27, i32 6, i32 %28)
%30 = load i32, i32* %6
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%32 = call i32 @read(i32 %30, i8* %31, i32 64)
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 0, i32* %3
br label %35
35: ; preds = %25, %20, %10
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str.1 = [15 x i8] c"open %s fail.\0A\00"
@SEEK_SET = global i32 0
@str = [24 x i8] c"useage: seek file_path.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %22
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8*, i8** %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %22
16: ; preds = %7
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @lseek(i32 %11, i32 6, i32 %18)
%20 = call i32 @read(i32 %11, i8* %17, i32 64)
%21 = call i32 @puts(i8* %17)
br label %22
22: ; preds = %13, %16, %5
%23 = phi i32 [ 1, %5 ], [ 1, %13 ], [ 0, %16 ]
ret i32 %23
}