#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 EXIT_SUCCESS;
int LOG_CONS;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_LOCAL0;
int LOG_PID;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main() {
  char ident[] = "Examples4C";
  openlog(ident, LOG_CONS | LOG_PID, LOG_LOCAL0);
  char log_msg1[] = "My first info syslog in C.";
  printf("%s\n", log_msg1);
  syslog(LOG_INFO, log_msg1);
  char log_msg2[] = "My first warning syslog in C.";
  printf("%s\n", log_msg2);
  syslog(LOG_WARNING, log_msg2);
  closelog();
  printf("Now, check: /var/log/syslog\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xf(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    0x2e4e(%rip),%rax
or     (%rax),%esi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
call   1060 <openlog@plt>
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe8e(%rip),%ax
mov    %ax,-0x18(%rbp)
mov    0xe86(%rip),%al
mov    %al,-0x16(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1050 <syslog@plt>
mov    0xe5e(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe5b(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe58(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe56(%rip),%eax
mov    %eax,-0x38(%rbp)
mov    0xe50(%rip),%ax
mov    %ax,-0x34(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
call   1050 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movabs $0x73656c706d617845,%rax
6c 65 73
mov    %rax,(%rsp)
movl   $0x433473,0x7(%rsp)
mov    0x2e66(%rip),%rax
mov    0x2e67(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
call   1060 <openlog@plt>
movups 0xeb6(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1050 <syslog@plt>
movups 0xea3(%rip),%xmm0
movups %xmm0,0x3e(%rsp)
movaps 0xe89(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1050 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
lea    0xe13(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.ident = [11 x i8] c"Examples4C\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_LOCAL0 = global i32 0
@__const.main.log_msg1 = [27 x i8] c"My first info syslog in C.\00"
@.str = [4 x i8] c"%s\0A\00"
@LOG_INFO = global i32 0
@__const.main.log_msg2 = [30 x i8] c"My first warning syslog in C.\00"
@LOG_WARNING = global i32 0
@.str.1 = [29 x i8] c"Now, check: /var/log/syslog\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca [27 x i8]
%4 = alloca [30 x i8]
store i32 0, i32* %1
%5 = bitcast [11 x i8]* %2 to i8*
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @LOG_CONS
%8 = load i32, i32* @LOG_PID
%9 = or i32 %7, %8
%10 = load i32, i32* @LOG_LOCAL0
%11 = call i32 @openlog(i8* %6, i32 %9, i32 %10)
%12 = bitcast [27 x i8]* %3 to i8*
%13 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @LOG_INFO
%16 = getelementptr inbounds [27 x i8], [27 x i8]* %3, i64 0, i64 0
%17 = call i32 @syslog(i32 %15, i8* %16)
%18 = bitcast [30 x i8]* %4 to i8*
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @LOG_WARNING
%22 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%23 = call i32 @syslog(i32 %21, i8* %22)
%24 = call i32 (...) @closelog()
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
@__const.main.ident = [11 x i8] c"Examples4C\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_LOCAL0 = global i32 0
@__const.main.log_msg1 = [27 x i8] c"My first info syslog in C.\00"
@LOG_INFO = global i32 0
@__const.main.log_msg2 = [30 x i8] c"My first warning syslog in C.\00"
@LOG_WARNING = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [28 x i8] c"Now, check: /var/log/syslog\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca [27 x i8]
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%5 = load i32, i32* @LOG_CONS
%6 = load i32, i32* @LOG_PID
%7 = or i32 %6, %5
%8 = load i32, i32* @LOG_LOCAL0
%9 = call i32 @openlog(i8* %4, i32 %7, i32 %8)
%10 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%11 = call i32 @puts(i8* %10)
%12 = load i32, i32* @LOG_INFO
%13 = call i32 @syslog(i32 %12, i8* %10)
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%15 = call i32 @puts(i8* %14)
%16 = load i32, i32* @LOG_WARNING
%17 = call i32 @syslog(i32 %16, i8* %14)
%18 = call i32 (...) @closelog()
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}