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


x86 assembly (clang, -O0):
<_user_numusers_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
mov    0x2ead(%rip),%rax
or     (%rax),%esi
lea    0xeac(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cltq
cmp    $0x4,%rax
je     1185 <_user_numusers_set+0x55>
movl   $0x0,-0x4(%rbp)
jmp    1193 <_user_numusers_set+0x63>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_user_numusers_set>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,0x4(%rsp)
mov    0x2ea0(%rip),%rax
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xeae(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
lea    0x4(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
jne    117c <_user_numusers_set+0x4c>
mov    %ebp,%edi
call   1040 <close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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