#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 /*<<< orphan*/ get_path(int, char *);
int open(int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, int *, int);
int first_active_facility(void) {
  int fd;
  int proccount = 0;
  int br;
  fd = open(get_path(4, "iptraf-processcount.dat"), O_RDONLY);
  br = read(fd, &proccount, sizeof(int));
  close(fd);
  return ((proccount == 0) || (br < 0) || (fd < 0));
}


x86 assembly (clang, -O0):
<first_active_facility>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x4,%edi
lea    0xea5(%rip),%rsi
call   1050 <get_path@plt>
mov    %eax,%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     11b7 <first_active_facility+0x77>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     11b7 <first_active_facility+0x77>
cmpl   $0x0,-0x4(%rbp)
setl   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_active_facility>:
push   %rbp
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeae(%rip),%rsi
mov    $0x4,%edi
call   1050 <get_path@plt>
mov    0x2e85(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1060 <open@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <read@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
shr    $0x1f,%ebx
cmpl   $0x0,0x4(%rsp)
mov    $0x1,%eax
cmove  %eax,%ebx
test   %ebp,%ebp
cmovs  %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"iptraf-processcount.dat\00"
@O_RDONLY = global i32 0
define i32 @first_active_facility() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
%4 = call i32 @get_path(i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i32 %4, i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @read(i32 %7, i32* %2, i32 4)
store i32 %8, i32* %3
%9 = load i32, i32* %1
%10 = call i32 @close(i32 %9)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %1
%18 = icmp slt i32 %17, 0
br label %19
19: ; preds = %16, %13, %0
%20 = phi i1 [ true, %13 ], [ true, %0 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
ret i32 %21
}

LLVM IR (-O2):
@.str = [24 x i8] c"iptraf-processcount.dat\00"
@O_RDONLY = global i32 0
define i32 @first_active_facility() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @get_path(i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i32 %3, i32 %4)
%6 = call i32 @read(i32 %5, i32* %1, i32 4)
%7 = tail call i32 @close(i32 %5)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
%10 = icmp slt i32 %6, 0
%11 = or i1 %10, %9
%12 = lshr i32 %5, 31
%13 = select i1 %11, i32 1, i32 %12
ret i32 %13
}