#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;
unsigned long 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) != 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    1172 <go_sect+0x62>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
call   1030 <lseek@plt>
cmp    -0x20(%rbp),%rax
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     1143 <go_sect+0x33>
push   %rbx
mov    %rsi,%rbx
shl    $0x9,%rbx
mov    0x2eb3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rsi
call   1030 <lseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
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 %27
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 i64 @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 = icmp ne i64 %22, %24
%26 = zext i1 %25 to i32
store i32 %26, i32* %3
br label %27
27: ; preds = %17, %16
%28 = load i32, i32* %3
ret i32 %28
}

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 %10
5: ; preds = %2
%6 = load i32, i32* @SEEK_SET
%7 = tail call i64 @lseek(i32 %0, i64 %3, i32 %6)
%8 = icmp ne i64 %7, %3
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ %9, %5 ], [ 1, %2 ]
ret i32 %11
}