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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(void) {
  int fd;
  char buf[BUFSIZ];
  ssize_t n;
  fd = open("/etc/nologin.txt", O_RDONLY);
  if (fd >= 0) {
    while ((n = read(fd, buf, sizeof(buf))) > 0)
      write(STDOUT_FILENO, buf, n);
    close(fd);
  } else {
    printf("The account is currently unavailable.\n");
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x30(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11fb <main+0xab>
jmp    11b6 <main+0x66>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%edi
mov    %eax,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    11ee <main+0x9e>
mov    -0x28(%rbp),%rsi
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
jmp    11b6 <main+0x66>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
jmp    1207 <main+0xb7>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e6e(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     11da <main+0x8a>
mov    %eax,%r15d
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    11d0 <main+0x80>
mov    0x2e46(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <read@plt>
test   %eax,%eax
jg     11b0 <main+0x60>
mov    %r15d,%edi
call   1050 <close@plt>
jmp    11e6 <main+0x96>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [17 x i8] c"/etc/nologin.txt\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.1 = [39 x i8] c"The account is currently unavailable.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %0
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %2
%17 = trunc i64 %7 to i32
%18 = call i32 @read(i32 %16, i8* %9, i32 %17)
store i32 %18, i32* %5
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @STDOUT_FILENO
%22 = load i32, i32* %5
%23 = call i32 @write(i32 %21, i8* %9, i32 %22)
br label %15
24: ; preds = %15
%25 = load i32, i32* %2
%26 = call i32 @close(i32 %25)
br label %29
27: ; preds = %0
%28 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
store i32 1, i32* %1
%30 = load i8*, i8** %3
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [17 x i8] c"/etc/nologin.txt\00"
@O_RDONLY = global i32 0
@STDOUT_FILENO = global i32 0
@str = [38 x i8] c"The account is currently unavailable.\00"
define i32 @main() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %18
7: ; preds = %0
%8 = call i32 @read(i32 %5, i8* %3, i32 %1)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7, %10
%11 = phi i32 [ %14, %10 ], [ %8, %7 ]
%12 = load i32, i32* @STDOUT_FILENO
%13 = call i32 @write(i32 %12, i8* %3, i32 %11)
%14 = call i32 @read(i32 %5, i8* %3, i32 %1)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %10, %7
%17 = tail call i32 @close(i32 %5)
br label %20
18: ; preds = %0
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret i32 1
}