#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_DEBUG;
int /*<<< orphan*/ LOG_INFO;
int LOG_PID;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *, ...);
int main(int argc, char **argv) {
  openlog("TestLog", LOG_CONS | LOG_PID, LOG_USER);
  if (argc != 2) {
    syslog(LOG_INFO, "error in %s\n", argv[0]);
    closelog();
    return 0;
  }
  syslog(LOG_DEBUG, "log in %s  message: %s\n", argv[0], argv[1]);
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    0x2e82(%rip),%rax
or     (%rax),%esi
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
lea    0xe98(%rip),%rdi
call   1050 <openlog@plt>
cmpl   $0x2,-0x8(%rbp)
je     11a8 <main+0x78>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dc <main+0xac>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e91(%rip),%rax
mov    0x2e92(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0xea6(%rip),%rdi
call   1050 <openlog@plt>
cmp    $0x2,%ebp
jne    1184 <main+0x54>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
jmp    119e <main+0x6e>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe71(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"TestLog\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [13 x i8] c"error in %s\0A\00"
@LOG_DEBUG = global i32 0
@.str.2 = [24 x i8] c"log in %s message: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @LOG_CONS
%7 = load i32, i32* @LOG_PID
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_USER
%10 = call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @LOG_INFO
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (...) @closelog()
store i32 0, i32* %3
br label %30
20: ; preds = %2
%21 = load i32, i32* @LOG_DEBUG
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %27)
%29 = call i32 (...) @closelog()
store i32 0, i32* %3
br label %30
30: ; preds = %20, %13
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [8 x i8] c"TestLog\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [13 x i8] c"error in %s\0A\00"
@LOG_DEBUG = global i32 0
@.str.2 = [24 x i8] c"log in %s message: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @LOG_CONS
%4 = load i32, i32* @LOG_PID
%5 = or i32 %4, %3
%6 = load i32, i32* @LOG_USER
%7 = tail call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = icmp eq i32 %0, 2
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @LOG_INFO
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %19
13: ; preds = %2
%14 = load i32, i32* @LOG_DEBUG
%15 = load i8*, i8** %1
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %17)
br label %19
19: ; preds = %13, %9
%20 = tail call i32 (...) @closelog()
ret i32 0
}