#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 LOG_DEBUG;
int LOG_EMERG;
int LOG_NDELAY;
int LOG_PERROR;
int LOG_PID;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ syslog(int, char *, int);
void main(void) {
  int ix;
  openlog("syslog_test", LOG_PID | LOG_NDELAY | LOG_PERROR | LOG_CONS,
          LOG_DAEMON);
  for (ix = LOG_EMERG; ix <= LOG_DEBUG; ix += 1) {
    sleep(2);
    syslog(ix, "message from test program - log level %d", ix);
  }
  closelog();
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    0x2e50(%rip),%rax
or     (%rax),%esi
mov    0x2e77(%rip),%rax
or     (%rax),%esi
mov    0x2e56(%rip),%rax
or     (%rax),%esi
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
lea    0xe84(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%eax
jg     11c9 <main+0x89>
mov    $0x2,%edi
call   1060 <sleep@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%edx
lea    0xe56(%rip),%rsi
call   1040 <syslog@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118d <main+0x4d>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e7c(%rip),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e7a(%rip),%rax
or     (%rax),%esi
mov    0x2e59(%rip),%rax
or     (%rax),%esi
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
lea    0xe87(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%ebx
mov    0x2e2a(%rip),%r15
cmp    (%r15),%ebx
jg     11c0 <main+0x80>
lea    0xe72(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    $0x2,%edi
call   1060 <sleep@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <syslog@plt>
lea    0x1(%rbx),%eax
cmp    (%r15),%ebx
mov    %eax,%ebx
jl     11a0 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"syslog_test\00"
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_PERROR = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@LOG_EMERG = global i32 0
@LOG_DEBUG = global i32 0
@.str.1 = [41 x i8] c"message from test program - log level %d\00"
define void @main() {
%1 = alloca i32
%2 = load i32, i32* @LOG_PID
%3 = load i32, i32* @LOG_NDELAY
%4 = or i32 %2, %3
%5 = load i32, i32* @LOG_PERROR
%6 = or i32 %4, %5
%7 = load i32, i32* @LOG_CONS
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_DAEMON
%10 = call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* @LOG_EMERG
store i32 %11, i32* %1
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %1
%14 = load i32, i32* @LOG_DEBUG
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = call i32 @sleep(i32 2)
%18 = load i32, i32* %1
%19 = load i32, i32* %1
%20 = call i32 @syslog(i32 %18, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %12
24: ; preds = %12
%25 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"syslog_test\00"
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_PERROR = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
@LOG_EMERG = global i32 0
@LOG_DEBUG = global i32 0
@.str.1 = [41 x i8] c"message from test program - log level %d\00"
define void @main() {
%1 = load i32, i32* @LOG_PID
%2 = load i32, i32* @LOG_NDELAY
%3 = or i32 %2, %1
%4 = load i32, i32* @LOG_PERROR
%5 = or i32 %3, %4
%6 = load i32, i32* @LOG_CONS
%7 = or i32 %5, %6
%8 = load i32, i32* @LOG_DAEMON
%9 = tail 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* @LOG_EMERG
%11 = load i32, i32* @LOG_DEBUG
%12 = icmp sgt i32 %10, %11
br i1 %12, label %20, label %13
13: ; preds = %0, %13
%14 = phi i32 [ %17, %13 ], [ %10, %0 ]
%15 = tail call i32 @sleep(i32 2)
%16 = tail call i32 @syslog(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%17 = add nsw i32 %14, 1
%18 = load i32, i32* @LOG_DEBUG
%19 = icmp slt i32 %14, %18
br i1 %19, label %13, label %20
20: ; preds = %13, %0
%21 = tail call i32 (...) @closelog()
ret void
}