#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 */
struct spwd {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EINTR;
int __getspent_r(struct spwd *, char *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int fgetspent_r(FILE *file, struct spwd *spwd, char *buff, size_t buflen,
                struct spwd **crap) {
  if (file == NULL) {
    __set_errno(EINTR);
    return -1;
  }
  return (__getspent_r(spwd, buff, buflen, fileno(file)));
}


x86 assembly (clang, -O0):
<fgetspent_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1171 <fgetspent_r+0x41>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <fgetspent_r+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fileno@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    %eax,%ecx
call   1040 <__getspent_r@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgetspent_r>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     115d <fgetspent_r+0x2d>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
call   1050 <fileno@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <__getspent_r@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.spwd = type { i32 }
@EINTR = global i32 0
define i32 @fgetspent_r(i32* %0, %struct.spwd* %1, i8* %2, i64 %3, %struct.spwd** %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.spwd*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca %struct.spwd**
store i32* %0, i32** %7
store %struct.spwd* %1, %struct.spwd** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store %struct.spwd** %4, %struct.spwd*** %11
%12 = load i32*, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32, i32* @EINTR
%16 = call i32 @__set_errno(i32 %15)
store i32 -1, i32* %6
br label %24
17: ; preds = %5
%18 = load %struct.spwd*, %struct.spwd** %8
%19 = load i8*, i8** %9
%20 = load i64, i64* %10
%21 = load i32*, i32** %7
%22 = call i32 @fileno(i32* %21)
%23 = call i32 @__getspent_r(%struct.spwd* %18, i8* %19, i64 %20, i32 %22)
store i32 %23, i32* %6
br label %24
24: ; preds = %17, %14
%25 = load i32, i32* %6
ret i32 %25
}

LLVM IR (-O2):
%struct.spwd = type { i32 }
@EINTR = global i32 0
define i32 @fgetspent_r(i32* %0, %struct.spwd* %1, i8* %2, i64 %3, %struct.spwd** nocapture readnone %4) {
%6 = icmp eq i32* %0, null
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = load i32, i32* @EINTR
%9 = tail call i32 @__set_errno(i32 %8)
br label %13
10: ; preds = %5
%11 = tail call i32 @fileno(i32* %0)
%12 = tail call i32 @__getspent_r(%struct.spwd* %1, i8* %2, i64 %3, i32 %11)
br label %13
13: ; preds = %10, %7
%14 = phi i32 [ -1, %7 ], [ %12, %10 ]
ret i32 %14
}