#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_DAEMON;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int LOG_PID;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char const *);
void loging(const char *msg, int type) {
  openlog("audioswitch", LOG_PID | LOG_CONS, LOG_DAEMON);
  if (type == 0)
    syslog(LOG_INFO, msg);
  if (type == 1)
    syslog(LOG_ERR, msg);
  closelog();
}


x86 assembly (clang, -O0):
<loging>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    0x2e81(%rip),%rax
or     (%rax),%esi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
lea    0xe9f(%rip),%rdi
call   1050 <openlog@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1182 <loging+0x52>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1040 <syslog@plt>
cmpl   $0x1,-0xc(%rbp)
jne    119e <loging+0x6e>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loging>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e99(%rip),%rax
mov    0x2e8a(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0xea6(%rip),%rdi
call   1050 <openlog@plt>
test   %ebp,%ebp
je     1171 <loging+0x41>
cmp    $0x1,%ebp
jne    1182 <loging+0x52>
mov    0x2e49(%rip),%rax
jmp    1178 <loging+0x48>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"audioswitch\00"
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@LOG_ERR = global i32 0
define void @loging(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @LOG_PID
%6 = load i32, i32* @LOG_CONS
%7 = or i32 %5, %6
%8 = load i32, i32* @LOG_DAEMON
%9 = call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @LOG_INFO
%14 = load i8*, i8** %3
%15 = call i32 @syslog(i32 %13, i8* %14)
br label %16
16: ; preds = %12, %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @LOG_ERR
%21 = load i8*, i8** %3
%22 = call i32 @syslog(i32 %20, i8* %21)
br label %23
23: ; preds = %19, %16
%24 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"audioswitch\00"
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@LOG_ERR = global i32 0
define void @loging(i8* %0, i32 %1) {
%3 = load i32, i32* @LOG_PID
%4 = load i32, i32* @LOG_CONS
%5 = or i32 %4, %3
%6 = load i32, i32* @LOG_DAEMON
%7 = tail call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
switch i32 %1, label %13 [
i32 0, label %9
i32 1, label %8
]
8: ; preds = %2
br label %9
9: ; preds = %2, %8
%10 = phi i32* [ @LOG_ERR, %8 ], [ @LOG_INFO, %2 ]
%11 = load i32, i32* %10
%12 = tail call i32 @syslog(i32 %11, i8* %0)
br label %13
13: ; preds = %9, %2
%14 = tail call i32 (...) @closelog()
ret void
}