#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*/ EBADF;
int STDERR_FILENO;
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ errno;
int _lseek(int file, int offset, int whence) {
  if ((STDIN_FILENO == file) || (STDOUT_FILENO == file) ||
      (STDERR_FILENO == file)) {
    return 0;
  } else {
    errno = EBADF;
    return (long)-1;
  }
}


x86 assembly (clang, -O0):
<_lseek>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     1143 <_lseek+0x43>
mov    0x2eca(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
je     1143 <_lseek+0x43>
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    114f <_lseek+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    1168 <_lseek+0x68>
mov    0x2e72(%rip),%rax
mov    (%rax),%ecx
mov    0x2e79(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_lseek>:
mov    0x2eb9(%rip),%rcx
xor    %eax,%eax
cmp    %edi,(%rcx)
je     113a <_lseek+0x3a>
mov    0x2edc(%rip),%rcx
cmp    %edi,(%rcx)
je     113a <_lseek+0x3a>
mov    0x2eb1(%rip),%rcx
cmp    %edi,(%rcx)
je     113a <_lseek+0x3a>
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    0x2ea5(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@EBADF = global i32 0
@errno = global i32 0
define i32 @_lseek(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* @STDIN_FILENO
%9 = load i32, i32* %5
%10 = icmp eq i32 %8, %9
br i1 %10, label %19, label %11
11: ; preds = %3
%12 = load i32, i32* @STDOUT_FILENO
%13 = load i32, i32* %5
%14 = icmp eq i32 %12, %13
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i32, i32* @STDERR_FILENO
%17 = load i32, i32* %5
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15, %11, %3
store i32 0, i32* %4
br label %22
20: ; preds = %15
%21 = load i32, i32* @EBADF
store i32 %21, i32* @errno
store i32 -1, i32* %4
br label %22
22: ; preds = %20, %19
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@EBADF = global i32 0
@errno = global i32 0
define i32 @_lseek(i32 %0, i32 %1, i32 %2) {
%4 = load i32, i32* @STDIN_FILENO
%5 = icmp eq i32 %4, %0
%6 = load i32, i32* @STDOUT_FILENO
%7 = icmp eq i32 %6, %0
%8 = select i1 %5, i1 true, i1 %7
%9 = load i32, i32* @STDERR_FILENO
%10 = icmp eq i32 %9, %0
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = load i32, i32* @EBADF
store i32 %13, i32* @errno
br label %14
14: ; preds = %3, %12
%15 = phi i32 [ -1, %12 ], [ 0, %3 ]
ret i32 %15
}