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

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int);
int main() {
  int fd;
  off_t ofset;
  fd = open("data.in", O_RDWR);
  assert(fd >= 0);
  ofset = lseek(fd, 2, SEEK_SET);
  printf("ofset:%lld, sizeof(off_t):%d\n", ofset, sizeof(off_t));
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1040 <lseek@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1070 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1060 <assert@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <lseek@plt>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"data.in\00"
@O_RDWR = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [30 x i8] c"ofset:%lld, sizeof(off_t):%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_RDWR
%5 = call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp sge i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @lseek(i32 %10, i32 2, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 4)
%15 = load i32, i32* %2
%16 = call i32 @close(i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"data.in\00"
@O_RDWR = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [30 x i8] c"ofset:%lld, sizeof(off_t):%d\0A\00"
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = xor i32 %2, -1
%4 = lshr i32 %3, 31
%5 = tail call i32 @assert(i32 %4)
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @lseek(i32 %2, i32 2, i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 4)
%9 = tail call i32 @close(i32 %2)
ret i32 0
}