#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 LOG_CONS;
int /*<<< orphan*/ LOG_LOCAL0;
int LOG_NDELAY;
int LOG_PERROR;
int LOG_PID;
scalar_t__ isatty(int);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
void setup_syslog() {
  int flags = LOG_CONS | LOG_NDELAY | LOG_PID;
  if (isatty(1)) {
    flags |= LOG_PERROR;
  }
  openlog("statsite", flags, LOG_LOCAL0);
}


x86 assembly (clang, -O0):
<setup_syslog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    0x2e80(%rip),%rcx
or     (%rcx),%eax
mov    0x2e8f(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    $0x1,%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     1169 <setup_syslog+0x49>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
lea    0xe84(%rip),%rdi
call   1040 <openlog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_syslog>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    0x2e96(%rip),%rax
or     (%rax),%ebx
mov    $0x1,%edi
call   1030 <isatty@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     1156 <setup_syslog+0x36>
mov    0x2e8c(%rip),%rax
mov    (%rax),%ecx
or     %ecx,%ebx
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
lea    0xe98(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <openlog@plt>

LLVM IR (-O0):
@LOG_CONS = global i32 0
@LOG_NDELAY = global i32 0
@LOG_PID = global i32 0
@LOG_PERROR = global i32 0
@.str = [9 x i8] c"statsite\00"
@LOG_LOCAL0 = global i32 0
define void @setup_syslog() {
%1 = alloca i32
%2 = load i32, i32* @LOG_CONS
%3 = load i32, i32* @LOG_NDELAY
%4 = or i32 %2, %3
%5 = load i32, i32* @LOG_PID
%6 = or i32 %4, %5
store i32 %6, i32* %1
%7 = call i64 @isatty(i32 1)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @LOG_PERROR
%11 = load i32, i32* %1
%12 = or i32 %11, %10
store i32 %12, i32* %1
br label %13
13: ; preds = %9, %0
%14 = load i32, i32* %1
%15 = load i32, i32* @LOG_LOCAL0
%16 = call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
ret void
}

LLVM IR (-O2):
@LOG_CONS = global i32 0
@LOG_NDELAY = global i32 0
@LOG_PID = global i32 0
@LOG_PERROR = global i32 0
@.str = [9 x i8] c"statsite\00"
@LOG_LOCAL0 = global i32 0
define void @setup_syslog() {
%1 = load i32, i32* @LOG_CONS
%2 = load i32, i32* @LOG_NDELAY
%3 = or i32 %2, %1
%4 = load i32, i32* @LOG_PID
%5 = or i32 %3, %4
%6 = tail call i64 @isatty(i32 1)
%7 = icmp eq i64 %6, 0
%8 = load i32, i32* @LOG_PERROR
%9 = select i1 %7, i32 0, i32 %8
%10 = or i32 %5, %9
%11 = load i32, i32* @LOG_LOCAL0
%12 = tail call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
ret void
}