#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, unsigned int *, int);
unsigned int _user_numusers_get() {
  int fd;
  unsigned int numusers;
  fd = open("D1:NUMUSERS", O_RDONLY);
  if (read(fd, &numusers, sizeof(unsigned int)) != sizeof(unsigned int)) {
    perror("read()");
    close(fd);
    return 0;
  }
  close(fd);
  return numusers;
}


x86 assembly (clang, -O0):
<_user_numusers_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cltq
cmp    $0x4,%rax
je     119d <_user_numusers_get+0x5d>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ab <_user_numusers_get+0x6b>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_user_numusers_get>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0xeab(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
lea    0xc(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
jne    1183 <_user_numusers_get+0x43>
mov    %ebx,%edi
call   1030 <close@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe82(%rip),%rdi
call   1060 <perror@plt>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
jmp    117d <_user_numusers_get+0x3d>

LLVM IR (-O0):
@.str = [12 x i8] c"D1:NUMUSERS\00"
@O_RDONLY = global i32 0
@.str.1 = [7 x i8] c"read()\00"
define i32 @_user_numusers_get() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @O_RDONLY
%5 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @read(i32 %6, i32* %3, i32 4)
%8 = sext i32 %7 to i64
%9 = icmp ne i64 %8, 4
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @close(i32 %12)
store i32 0, i32* %1
br label %18
14: ; preds = %0
%15 = load i32, i32* %2
%16 = call i32 @close(i32 %15)
%17 = load i32, i32* %3
store i32 %17, i32* %1
br label %18
18: ; preds = %14, %10
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [12 x i8] c"D1:NUMUSERS\00"
@O_RDONLY = global i32 0
@.str.1 = [7 x i8] c"read()\00"
define i32 @_user_numusers_get() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @read(i32 %4, i32* %1, i32 4)
%6 = icmp eq i32 %5, 4
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @close(i32 %4)
br label %13
10: ; preds = %0
%11 = tail call i32 @close(i32 %4)
%12 = load i32, i32* %1
br label %13
13: ; preds = %10, %7
%14 = phi i32 [ 0, %7 ], [ %12, %10 ]
ret i32 %14
}