#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 */
typedef int /*<<< orphan*/ bufr;

/* Variables and functions */
int /*<<< orphan*/ LOG_ALERT;
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_EMERG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ LOG_PID;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ feof(int /*<<< orphan*/);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
char *strrchr(char *, char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  auto char *nl, bufr[512];
  auto int logged = 0;
  openlog("DOTEST", LOG_PID, LOG_DAEMON);
  if (argc > 1) {
    if ((*argv[1] == '-') && (*(argv[1] + 1) == '\0')) {
      while (!feof(stdin))
        if (fgets(bufr, sizeof(bufr), stdin) != (char *)0) {
          if ((nl = strrchr(bufr, '\n')) != (char *)0)
            *nl = '\0';
          syslog(LOG_INFO, bufr);
          logged += strlen(bufr);
          if (logged > 1024) {
            sleep(1);
            logged = 0;
          }
        }
    } else
      while (argc-- > 1)
        syslog(LOG_INFO, argv++[1]);
  } else {
    syslog(LOG_EMERG, "EMERG log.");
    syslog(LOG_ALERT, "Alert log.");
    syslog(LOG_CRIT, "Critical log.");
    syslog(LOG_ERR, "Error log.");
    syslog(LOG_WARNING, "Warning log.");
    syslog(LOG_NOTICE, "Notice log.");
    syslog(LOG_INFO, "Info log.");
    syslog(LOG_DEBUG, "Debug log.");
    closelog();
    return (0);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x224(%rbp)
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
lea    0xe44(%rip),%rdi
call   1090 <openlog@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1316 <main+0x196>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12cd <main+0x14d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    12cd <main+0x14d>
jmp    11f9 <main+0x79>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    121c <main+0x9c>
jmp    12c8 <main+0x148>
lea    -0x220(%rbp),%rdi
mov    0x2da6(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12c3 <main+0x143>
lea    -0x220(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1266 <main+0xe6>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rsi
call   1080 <syslog@plt>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
movslq -0x224(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x224(%rbp)
cmpl   $0x400,-0x224(%rbp)
jle    12be <main+0x13e>
mov    $0x1,%edi
call   10a0 <sleep@plt>
movl   $0x0,-0x224(%rbp)
jmp    12c3 <main+0x143>
jmp    11f9 <main+0x79>
jmp    1311 <main+0x191>
jmp    12d2 <main+0x152>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x1,%eax
jle    130c <main+0x18c>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rsi
call   1080 <syslog@plt>
jmp    12d2 <main+0x152>
jmp    1311 <main+0x191>
jmp    13d1 <main+0x251>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xce1(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    0xcd7(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xccd(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xcbc(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xcab(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
lea    0xca0(%rip),%rsi
call   1080 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
movl   $0x0,-0x4(%rbp)
jmp    13d8 <main+0x258>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
lea    0xe55(%rip),%rdi
call   1090 <openlog@plt>
cmp    $0x2,%ebp
jl     120c <main+0x8c>
mov    0x8(%rbx),%rsi
cmpb   $0x2d,(%rsi)
jne    11c8 <main+0x48>
cmpb   $0x0,0x1(%rsi)
je     12cb <main+0x14b>
mov    0x2dc9(%rip),%r14
mov    (%r14),%edi
call   1080 <syslog@plt>
cmp    $0x3,%ebp
jl     12bb <main+0x13b>
add    $0x1,%ebp
add    $0x10,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%rsi
mov    (%r14),%edi
call   1080 <syslog@plt>
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x3,%ebp
jg     11f0 <main+0x70>
jmp    12bb <main+0x13b>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xdb5(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
call   1080 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cfe(%rip),%r15
mov    (%r15),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12bb <main+0x13b>
xor    %ebp,%ebp
mov    %rsp,%rbx
mov    0x2cae(%rip),%r14
jmp    12fc <main+0x17c>
nopl   0x0(%rax)
mov    (%r15),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12bb <main+0x13b>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12f0 <main+0x170>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1326 <main+0x1a6>
movb   $0x0,(%rax)
mov    (%r14),%edi
mov    %rbx,%rsi
call   1080 <syslog@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %eax,%ebp
cmp    $0x401,%ebp
jl     12f0 <main+0x170>
mov    $0x1,%edi
call   10a0 <sleep@plt>
xor    %ebp,%ebp
jmp    12f0 <main+0x170>

LLVM IR (-O0):
@.str = [7 x i8] c"DOTEST\00"
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@stdin = global i32 0
@LOG_INFO = global i32 0
@LOG_EMERG = global i32 0
@.str.1 = [11 x i8] c"EMERG log.\00"
@LOG_ALERT = global i32 0
@.str.2 = [11 x i8] c"Alert log.\00"
@LOG_CRIT = global i32 0
@.str.3 = [14 x i8] c"Critical log.\00"
@LOG_ERR = global i32 0
@.str.4 = [11 x i8] c"Error log.\00"
@LOG_WARNING = global i32 0
@.str.5 = [13 x i8] c"Warning log.\00"
@LOG_NOTICE = global i32 0
@.str.6 = [12 x i8] c"Notice log.\00"
@.str.7 = [10 x i8] c"Info log.\00"
@LOG_DEBUG = global i32 0
@.str.8 = [11 x i8] c"Debug log.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [512 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* @LOG_PID
%10 = load i32, i32* @LOG_DAEMON
%11 = call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %77
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %63
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %63
29: ; preds = %21
br label %30
30: ; preds = %61, %29
%31 = load i32, i32* @stdin
%32 = call i32 @feof(i32 %31)
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
br i1 %34, label %35, label %62
35: ; preds = %30
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%37 = load i32, i32* @stdin
%38 = call i8* @fgets(i8* %36, i32 512, i32 %37)
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %61
40: ; preds = %35
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%42 = call i8* @strrchr(i8* %41, i8 signext 10)
store i8* %42, i8** %6
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i8*, i8** %6
store i8 0, i8* %45
br label %46
46: ; preds = %44, %40
%47 = load i32, i32* @LOG_INFO
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%49 = call i32 @syslog(i32 %47, i8* %48)
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%51 = call i64 @strlen(i8* %50)
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = add nsw i64 %53, %51
%55 = trunc i64 %54 to i32
store i32 %55, i32* %8
%56 = load i32, i32* %8
%57 = icmp sgt i32 %56, 1024
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 @sleep(i32 1)
store i32 0, i32* %8
br label %60
60: ; preds = %58, %46
br label %61
61: ; preds = %60, %35
br label %30
62: ; preds = %30
br label %76
63: ; preds = %21, %14
br label %64
64: ; preds = %68, %63
%65 = load i32, i32* %4
%66 = add nsw i32 %65, -1
store i32 %66, i32* %4
%67 = icmp sgt i32 %65, 1
br i1 %67, label %68, label %75
68: ; preds = %64
%69 = load i32, i32* @LOG_INFO
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i32 1
store i8** %71, i8*** %5
%72 = getelementptr inbounds i8*, i8** %70, i64 1
%73 = load i8*, i8** %72
%74 = call i32 @syslog(i32 %69, i8* %73)
br label %64
75: ; preds = %64
br label %76
76: ; preds = %75, %62
br label %95
77: ; preds = %2
%78 = load i32, i32* @LOG_EMERG
%79 = call i32 @syslog(i32 %78, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%80 = load i32, i32* @LOG_ALERT
%81 = call i32 @syslog(i32 %80, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%82 = load i32, i32* @LOG_CRIT
%83 = call i32 @syslog(i32 %82, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%84 = load i32, i32* @LOG_ERR
%85 = call i32 @syslog(i32 %84, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%86 = load i32, i32* @LOG_WARNING
%87 = call i32 @syslog(i32 %86, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%88 = load i32, i32* @LOG_NOTICE
%89 = call i32 @syslog(i32 %88, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%90 = load i32, i32* @LOG_INFO
%91 = call i32 @syslog(i32 %90, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%92 = load i32, i32* @LOG_DEBUG
%93 = call i32 @syslog(i32 %92, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%94 = call i32 (...) @closelog()
store i32 0, i32* %3
br label %96
95: ; preds = %76
store i32 0, i32* %3
br label %96
96: ; preds = %95, %77
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@.str = [7 x i8] c"DOTEST\00"
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@stdin = global i32 0
@LOG_INFO = global i32 0
@LOG_EMERG = global i32 0
@.str.1 = [11 x i8] c"EMERG log.\00"
@LOG_ALERT = global i32 0
@.str.2 = [11 x i8] c"Alert log.\00"
@LOG_CRIT = global i32 0
@.str.3 = [14 x i8] c"Critical log.\00"
@LOG_ERR = global i32 0
@.str.4 = [11 x i8] c"Error log.\00"
@LOG_WARNING = global i32 0
@.str.5 = [13 x i8] c"Warning log.\00"
@LOG_NOTICE = global i32 0
@.str.6 = [12 x i8] c"Notice log.\00"
@.str.7 = [10 x i8] c"Info log.\00"
@LOG_DEBUG = global i32 0
@.str.8 = [11 x i8] c"Debug log.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @LOG_PID
%6 = load i32, i32* @LOG_DAEMON
%7 = tail call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %59
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %45
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %45
18: ; preds = %14
%19 = load i32, i32* @stdin
%20 = call i32 @feof(i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %77
22: ; preds = %18, %40
%23 = phi i32 [ %41, %40 ], [ 0, %18 ]
%24 = load i32, i32* @stdin
%25 = call i8* @fgets(i8* %4, i32 512, i32 %24)
%26 = icmp eq i8* %25, null
br i1 %26, label %40, label %27
27: ; preds = %22
%28 = call i8* @strrchr(i8* %4, i8 signext 10)
%29 = icmp eq i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %27
store i8 0, i8* %28
br label %31
31: ; preds = %30, %27
%32 = load i32, i32* @LOG_INFO
%33 = call i32 @syslog(i32 %32, i8* %4)
%34 = call i64 @strlen(i8* %4)
%35 = trunc i64 %34 to i32
%36 = add i32 %23, %35
%37 = icmp sgt i32 %36, 1024
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 @sleep(i32 1)
br label %40
40: ; preds = %31, %38, %22
%41 = phi i32 [ 0, %38 ], [ %36, %31 ], [ %23, %22 ]
%42 = load i32, i32* @stdin
%43 = call i32 @feof(i32 %42)
%44 = icmp eq i32 %43, 0
br i1 %44, label %22, label %77
45: ; preds = %9, %14
%46 = load i32, i32* @LOG_INFO
%47 = tail call i32 @syslog(i32 %46, i8* %11)
%48 = icmp sgt i32 %0, 2
br i1 %48, label %49, label %77
49: ; preds = %45, %49
%50 = phi i32 [ %53, %49 ], [ %0, %45 ]
%51 = phi i8** [ %52, %49 ], [ %1, %45 ]
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = add nsw i32 %50, -1
%54 = getelementptr inbounds i8*, i8** %51, i64 2
%55 = load i8*, i8** %54
%56 = load i32, i32* @LOG_INFO
%57 = tail call i32 @syslog(i32 %56, i8* %55)
%58 = icmp sgt i32 %50, 3
br i1 %58, label %49, label %77
59: ; preds = %2
%60 = load i32, i32* @LOG_EMERG
%61 = tail call i32 @syslog(i32 %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%62 = load i32, i32* @LOG_ALERT
%63 = tail call i32 @syslog(i32 %62, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%64 = load i32, i32* @LOG_CRIT
%65 = tail call i32 @syslog(i32 %64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%66 = load i32, i32* @LOG_ERR
%67 = tail call i32 @syslog(i32 %66, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%68 = load i32, i32* @LOG_WARNING
%69 = tail call i32 @syslog(i32 %68, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%70 = load i32, i32* @LOG_NOTICE
%71 = tail call i32 @syslog(i32 %70, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%72 = load i32, i32* @LOG_INFO
%73 = tail call i32 @syslog(i32 %72, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%74 = load i32, i32* @LOG_DEBUG
%75 = tail call i32 @syslog(i32 %74, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%76 = tail call i32 (...) @closelog()
br label %77
77: ; preds = %49, %40, %45, %18, %59
ret i32 0
}