#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_APPEND;
int O_CREAT;
int /*<<< orphan*/ O_RDWR;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int, ...);
void init_log() {
  close(0);
  close(1);
  close(2);
  int infd = open("/dev/null", O_RDWR);
  int outfd = open("/var/log/issd/issd.log",
                   O_CREAT | O_WRONLY | O_TRUNC | O_APPEND, 0666);
  int errfd = open("/var/log/issd/issdErr.log",
                   O_CREAT | O_WRONLY | O_TRUNC | O_APPEND, 0666);
  if (infd == -1 || outfd == -1 || errfd == -1)
    exit(-1);
}


x86 assembly (clang, -O0):
<init_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1030 <close@plt>
mov    $0x2,%edi
call   1030 <close@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <open@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    0x2e43(%rip),%rax
or     (%rax),%esi
mov    0x2e6a(%rip),%rax
or     (%rax),%esi
mov    0x2e29(%rip),%rax
or     (%rax),%esi
lea    0xe72(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
mov    0x2e09(%rip),%rax
or     (%rax),%esi
mov    0x2e30(%rip),%rax
or     (%rax),%esi
mov    0x2def(%rip),%rax
or     (%rax),%esi
lea    0xe4f(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     11ff <init_log+0xcf>
cmpl   $0xffffffff,-0x8(%rbp)
je     11ff <init_log+0xcf>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1209 <init_log+0xd9>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <close@plt>
mov    $0x1,%edi
call   1030 <close@plt>
mov    $0x2,%edi
call   1030 <close@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <open@plt>
mov    0x2e84(%rip),%r14
mov    0x2e45(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
mov    0x2e68(%rip),%r12
or     (%r12),%esi
mov    %eax,%ebp
mov    0x2e23(%rip),%r13
or     0x0(%r13),%esi
lea    0xe6a(%rip),%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1040 <open@plt>
mov    %eax,%ebx
mov    (%r15),%esi
or     (%r14),%esi
or     (%r12),%esi
or     0x0(%r13),%esi
lea    0xe5e(%rip),%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1040 <open@plt>
cmp    $0xffffffff,%ebp
je     11ed <init_log+0xbd>
cmp    $0xffffffff,%ebx
je     11ed <init_log+0xbd>
cmp    $0xffffffff,%eax
je     11ed <init_log+0xbd>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"/var/log/issd/issd.log\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_APPEND = global i32 0
@.str.2 = [26 x i8] c"/var/log/issd/issdErr.log\00"
define void @init_log() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @close(i32 0)
%5 = call i32 @close(i32 1)
%6 = call i32 @close(i32 2)
%7 = load i32, i32* @O_RDWR
%8 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 %8, i32* %1
%9 = load i32, i32* @O_CREAT
%10 = load i32, i32* @O_WRONLY
%11 = or i32 %9, %10
%12 = load i32, i32* @O_TRUNC
%13 = or i32 %11, %12
%14 = load i32, i32* @O_APPEND
%15 = or i32 %13, %14
%16 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 438)
store i32 %16, i32* %2
%17 = load i32, i32* @O_CREAT
%18 = load i32, i32* @O_WRONLY
%19 = or i32 %17, %18
%20 = load i32, i32* @O_TRUNC
%21 = or i32 %19, %20
%22 = load i32, i32* @O_APPEND
%23 = or i32 %21, %22
%24 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 438)
store i32 %24, i32* %3
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, -1
br i1 %26, label %33, label %27
27: ; preds = %0
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, -1
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %35
33: ; preds = %30, %27, %0
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %30
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"/var/log/issd/issd.log\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_APPEND = global i32 0
@.str.2 = [26 x i8] c"/var/log/issd/issdErr.log\00"
define void @init_log() {
%1 = tail call i32 @close(i32 0)
%2 = tail call i32 @close(i32 1)
%3 = tail call i32 @close(i32 2)
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_WRONLY
%8 = or i32 %7, %6
%9 = load i32, i32* @O_TRUNC
%10 = or i32 %8, %9
%11 = load i32, i32* @O_APPEND
%12 = or i32 %10, %11
%13 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 438)
%14 = load i32, i32* @O_CREAT
%15 = load i32, i32* @O_WRONLY
%16 = or i32 %15, %14
%17 = load i32, i32* @O_TRUNC
%18 = or i32 %16, %17
%19 = load i32, i32* @O_APPEND
%20 = or i32 %18, %19
%21 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 438)
%22 = icmp eq i32 %5, -1
%23 = icmp eq i32 %13, -1
%24 = or i1 %22, %23
%25 = icmp eq i32 %21, -1
%26 = or i1 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %0
%28 = tail call i32 @exit(i32 -1)
unreachable
29: ; preds = %0
ret void
}