#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
scalar_t__ ENOENT;
int _login_error(char *, int);
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int _login_nologin(void) {
  FILE *fp;
  char buf[BUFSIZ];
  size_t size;
  if ((fp = fopen("/etc/nologin", "r")) == NULL) {
    if (errno == ENOENT)
      return 0;
    return -_login_error("/etc/nologin", 1);
  }
  fprintf(stdout, "%s\n", "LOGGING IN IS DENIED");
  while ((size = fread(buf, sizeof(*buf), sizeof(buf), fp)) > 0)
    fwrite(buf, sizeof(*buf), size, stdout);
  if (!feof(fp))
    _login_error("/etc/nologin", 1);
  fclose(fp);
  fputc('\n', stdout);
  return -1;
}


x86 assembly (clang, -O0):
<_login_nologin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe41(%rip),%rdi
lea    0xe47(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    122c <_login_nologin+0xac>
mov    0x2df8(%rip),%rax
mov    (%rax),%rax
mov    0x2dd6(%rip),%rcx
cmp    (%rcx),%rax
jne    1206 <_login_nologin+0x86>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12db <_login_nologin+0x15b>
lea    0xdf3(%rip),%rdi
mov    $0x1,%esi
call   10a0 <_login_error@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    12db <_login_nologin+0x15b>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
lea    0xdd0(%rip),%rdx
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jbe    128e <_login_nologin+0x10e>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    0x2d53(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1090 <fwrite@plt>
jmp    1248 <_login_nologin+0xc8>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    12b1 <_login_nologin+0x131>
lea    0xd59(%rip),%rdi
mov    $0x1,%esi
call   10a0 <_login_error@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_login_nologin>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e4e(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe53(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1258 <_login_nologin+0xd8>
mov    %rax,%r15
mov    0x2e04(%rip),%r12
mov    (%r12),%edi
lea    0xe38(%rip),%rsi
lea    0xe35(%rip),%rdx
call   1060 <fprintf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     121e <_login_nologin+0x9e>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1090 <fwrite@plt>
jmp    11f0 <_login_nologin+0x70>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    123b <_login_nologin+0xbb>
lea    0xdcf(%rip),%rdi
mov    $0x1,%esi
call   10a0 <_login_error@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    (%r12),%esi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    $0xffffffff,%eax
jmp    1283 <_login_nologin+0x103>
mov    0x2d79(%rip),%rax
mov    (%rax),%rcx
mov    0x2d57(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
je     1283 <_login_nologin+0x103>
lea    0xd89(%rip),%rdi
mov    $0x1,%esi
call   10a0 <_login_error@plt>
neg    %eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"/etc/nologin\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i64 0
@ENOENT = global i64 0
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [21 x i8] c"LOGGING IN IS DENIED\00"
define i32 @_login_nologin() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i8, i64 %8
store i64 %8, i64* %4
%11 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %21
13: ; preds = %0
%14 = load i64, i64* @errno
%15 = load i64, i64* @ENOENT
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %1
store i32 1, i32* %6
br label %44
18: ; preds = %13
%19 = call i32 @_login_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = sub nsw i32 0, %19
store i32 %20, i32* %1
store i32 1, i32* %6
br label %44
21: ; preds = %0
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %29, %21
%25 = trunc i64 %8 to i32
%26 = load i32*, i32** %2
%27 = call i64 @fread(i8* %10, i32 1, i32 %25, i32* %26)
store i64 %27, i64* %5
%28 = icmp ugt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i64, i64* %5
%31 = load i32, i32* @stdout
%32 = call i32 @fwrite(i8* %10, i32 1, i64 %30, i32 %31)
br label %24
33: ; preds = %24
%34 = load i32*, i32** %2
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = call i32 @_login_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1)
br label %39
39: ; preds = %37, %33
%40 = load i32*, i32** %2
%41 = call i32 @fclose(i32* %40)
%42 = load i32, i32* @stdout
%43 = call i32 @fputc(i8 signext 10, i32 %42)
store i32 -1, i32* %1
store i32 1, i32* %6
br label %44
44: ; preds = %39, %18, %17
%45 = load i8*, i8** %3
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"/etc/nologin\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i64 0
@ENOENT = global i64 0
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [21 x i8] c"LOGGING IN IS DENIED\00"
define i32 @_login_nologin() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @ENOENT
%9 = icmp eq i64 %7, %8
br i1 %9, label %33, label %10
10: ; preds = %6
%11 = tail call i32 @_login_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = sub nsw i32 0, %11
br label %33
13: ; preds = %0
%14 = load i32, i32* @stdout
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%16 = call i64 @fread(i8* %3, i32 1, i32 %1, i32* %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %13, %18
%19 = phi i64 [ %22, %18 ], [ %16, %13 ]
%20 = load i32, i32* @stdout
%21 = call i32 @fwrite(i8* %3, i32 1, i64 %19, i32 %20)
%22 = call i64 @fread(i8* %3, i32 1, i32 %1, i32* %4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %18
24: ; preds = %18, %13
%25 = call i32 @feof(i32* %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @_login_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1)
br label %29
29: ; preds = %27, %24
%30 = call i32 @fclose(i32* %4)
%31 = load i32, i32* @stdout
%32 = call i32 @fputc(i8 signext 10, i32 %31)
br label %33
33: ; preds = %6, %29, %10
%34 = phi i32 [ %12, %10 ], [ -1, %29 ], [ 0, %6 ]
ret i32 %34
}