#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 /*<<< orphan*/ LOG_LOCAL0;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int);
int main(int __attribute__((unused)) argc,
         char __attribute__((unused)) * argv[]) {
  int i;
  openlog("msggen", 0, LOG_LOCAL0);
  for (i = 0; i < 10; ++i)
    syslog(LOG_NOTICE, "This is message number %d", i);
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
xor    %esi,%esi
call   1050 <openlog@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1194 <main+0x64>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe86(%rip),%rsi
call   1040 <syslog@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x34>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rax
mov    (%rax),%edx
lea    0xebc(%rip),%rdi
xor    %esi,%esi
call   1050 <openlog@plt>
mov    0x2e86(%rip),%rbx
mov    (%rbx),%edi
lea    0xeac(%rip),%r14
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x6,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1040 <syslog@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x9,%edx
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"msggen\00"
@LOG_LOCAL0 = global i32 0
@LOG_NOTICE = global i32 0
@.str.1 = [26 x i8] c"This is message number %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @LOG_LOCAL0
%8 = call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0, i32 %7)
store i32 0, i32* %6
br label %9
9: ; preds = %16, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* @LOG_NOTICE
%14 = load i32, i32* %6
%15 = call i32 @syslog(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %9
19: ; preds = %9
%20 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"msggen\00"
@LOG_LOCAL0 = global i32 0
@LOG_NOTICE = global i32 0
@.str.1 = [26 x i8] c"This is message number %d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @LOG_LOCAL0
%4 = tail call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 0, i32 %3)
%5 = load i32, i32* @LOG_NOTICE
%6 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 0)
%7 = load i32, i32* @LOG_NOTICE
%8 = tail call i32 @syslog(i32 %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 1)
%9 = load i32, i32* @LOG_NOTICE
%10 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 2)
%11 = load i32, i32* @LOG_NOTICE
%12 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 3)
%13 = load i32, i32* @LOG_NOTICE
%14 = tail call i32 @syslog(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 4)
%15 = load i32, i32* @LOG_NOTICE
%16 = tail call i32 @syslog(i32 %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 5)
%17 = load i32, i32* @LOG_NOTICE
%18 = tail call i32 @syslog(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 6)
%19 = load i32, i32* @LOG_NOTICE
%20 = tail call i32 @syslog(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 7)
%21 = load i32, i32* @LOG_NOTICE
%22 = tail call i32 @syslog(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 8)
%23 = load i32, i32* @LOG_NOTICE
%24 = tail call i32 @syslog(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 9)
%25 = tail call i32 (...) @closelog()
ret i32 0
}