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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int lseek(int, unsigned long, int /*<<< orphan*/);
int go_sect(int hd, unsigned long sec) {
  if (sizeof(off_t) >= 8) {
    off_t bs, rs;
    bs = sec;
    bs <<= 9;
    rs = lseek(hd, bs, SEEK_SET);
    return (bs != rs);
  } else {
    unsigned long bs[2];
    bs[0] = sec << 9;
    bs[1] = sec >> 23;
    if (bs[1])
      return 1;
    return (lseek(hd, bs[0], SEEK_SET) != (off_t)bs[0]);
  }
}


x86 assembly (clang, -O0):
<go_sect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x9,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x17,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     114e <go_sect+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    1174 <go_sect+0x64>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
call   1030 <lseek@plt>
mov    -0x20(%rbp),%rcx
cmp    %ecx,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<go_sect>:
mov    $0x1,%eax
cmp    $0x7fffff,%rsi
ja     1141 <go_sect+0x31>
push   %rbx
mov    %rsi,%rbx
shl    $0x9,%rbx
mov    0x2eb3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rsi
call   1030 <lseek@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
setne  %al
pop    %rbx
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @go_sect(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca [2 x i64]
store i32 %0, i32* %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = shl i64 %7, 9
%9 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
store i64 %8, i64* %9
%10 = load i64, i64* %5
%11 = lshr i64 %10, 23
%12 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 1
store i64 %11, i64* %12
%13 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 1
%14 = load i64, i64* %13
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %28
17: ; preds = %2
%18 = load i32, i32* %4
%19 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
%20 = load i64, i64* %19
%21 = load i32, i32* @SEEK_SET
%22 = call i32 @lseek(i32 %18, i64 %20, i32 %21)
%23 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = icmp ne i32 %22, %25
%27 = zext i1 %26 to i32
store i32 %27, i32* %3
br label %28
28: ; preds = %17, %16
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @go_sect(i32 %0, i64 %1) {
%3 = shl i64 %1, 9
%4 = icmp ult i64 %1, 8388608
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @lseek(i32 %0, i64 %3, i32 %6)
%8 = trunc i64 %3 to i32
%9 = icmp ne i32 %7, %8
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ %10, %5 ], [ 1, %2 ]
ret i32 %12
}