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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ _PATH_NOLOGIN;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int open(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ sleepexit(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void checknologin(void) {
  int fd, nchars;
  char tbuf[8192];
  if ((fd = open(_PATH_NOLOGIN, O_RDONLY, 0)) >= 0) {
    while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
      write(fileno(stdout), tbuf, nchars);
    close(fd);
    sleepexit(0);
  }
}


x86 assembly (clang, -O0):
<checknologin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2010,%rsp
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jl     11e8 <checknologin+0x88>
jmp    1195 <checknologin+0x35>
mov    -0x4(%rbp),%edi
lea    -0x2010(%rbp),%rsi
mov    $0x2000,%edx
call   1050 <read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11d9 <checknologin+0x79>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
lea    -0x2010(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <write@plt>
jmp    1195 <checknologin+0x35>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
xor    %edi,%edi
call   1070 <sleepexit@plt>
add    $0x2010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checknologin>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2008,%rsp
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <open@plt>
test   %eax,%eax
js     11f6 <checknologin+0x96>
mov    %eax,%r14d
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x2000,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11da <checknologin+0x7a>
mov    %eax,%ebp
mov    0x2e27(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    (%r15),%edi
call   1060 <fileno@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x2000,%edx
call   1050 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     11b0 <checknologin+0x50>
mov    %r14d,%edi
call   1040 <close@plt>
xor    %edi,%edi
add    $0x2008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <sleepexit@plt>
add    $0x2008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_PATH_NOLOGIN = global i32 0
@O_RDONLY = global i32 0
@stdout = global i32 0
define void @checknologin() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8192 x i8]
%4 = load i32, i32* @_PATH_NOLOGIN
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %1
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %0
br label %9
9: ; preds = %14, %8
%10 = load i32, i32* %1
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%12 = call i32 @read(i32 %10, i8* %11, i32 8192)
store i32 %12, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* @stdout
%16 = call i32 @fileno(i32 %15)
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%18 = load i32, i32* %2
%19 = call i32 @write(i32 %16, i8* %17, i32 %18)
br label %9
20: ; preds = %9
%21 = load i32, i32* %1
%22 = call i32 @close(i32 %21)
%23 = call i32 @sleepexit(i32 0)
br label %24
24: ; preds = %20, %0
ret void
}

LLVM IR (-O2):
@_PATH_NOLOGIN = global i32 0
@O_RDONLY = global i32 0
@stdout = global i32 0
define void @checknologin() {
%1 = alloca [8192 x i8]
%2 = getelementptr inbounds [8192 x i8], [8192 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @_PATH_NOLOGIN
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i32 %3, i32 %4, i32 0)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %20
7: ; preds = %0
%8 = call i32 @read(i32 %5, i8* %2, i32 8192)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7, %10
%11 = phi i32 [ %15, %10 ], [ %8, %7 ]
%12 = load i32, i32* @stdout
%13 = tail call i32 @fileno(i32 %12)
%14 = call i32 @write(i32 %13, i8* %2, i32 %11)
%15 = call i32 @read(i32 %5, i8* %2, i32 8192)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %10, label %17
17: ; preds = %10, %7
%18 = tail call i32 @close(i32 %5)
%19 = tail call i32 @sleepexit(i32 0)
br label %20
20: ; preds = %17, %0
ret void
}