#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 */
unsigned int LOG_ALERT;
unsigned int LOG_CRIT;
unsigned int LOG_DEBUG;
unsigned int LOG_ERR;
unsigned int LOG_INFO;
unsigned int LOG_NOTICE;
unsigned int LOG_WARNING;
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isdigit(char const);
scalar_t__ isspace(char const);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, char const *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
int /*<<< orphan*/ write_message(int, char *, int /*<<< orphan*/);
void main_loop(int fd, const char *prefix, unsigned facility,
               int strip_priority, int preserve_syslog) {
  char inbuf[2048];
  char outbuf[2048];
  while (fgets(inbuf, sizeof inbuf, stdin)) {
    unsigned priority = LOG_INFO;
    const char *msgptr = inbuf;
    int in_preform = 0;
    unsigned int in_val = 0;
    if (*msgptr == '<' && preserve_syslog) {
      const char *endptr = msgptr + 1;
      if (isdigit(*endptr)) {
        do {
          in_val *= 10;
          in_val += *endptr - '0';
          ++endptr;
        } while (isdigit(*endptr));
        if (*endptr == '>') {
          msgptr = endptr + 1;
          in_preform = 1;
        }
      }
    }
    if (in_preform)
      ;
    else if (!strncasecmp(inbuf, "emergency:", 10)) {
      priority = LOG_ALERT;
      msgptr = inbuf + 10;
    } else if (!strncasecmp(inbuf, "alert:", 6)) {
      priority = LOG_ALERT;
      msgptr = inbuf + 6;
    } else if (!strncasecmp(inbuf, "critical:", 9)) {
      priority = LOG_CRIT;
      msgptr = inbuf + 9;
    } else if (!strncasecmp(inbuf, "error:", 6)) {
      priority = LOG_ERR;
      msgptr = inbuf + 6;
    } else if (!strncasecmp(inbuf, "warning:", 8)) {
      priority = LOG_WARNING;
      msgptr = inbuf + 8;
    } else if (!strncasecmp(inbuf, "notice:", 7)) {
      priority = LOG_NOTICE;
      msgptr = inbuf + 7;
    } else if (!strncasecmp(inbuf, "info:", 5)) {
      priority = LOG_INFO;
      msgptr = inbuf + 5;
    } else if (!strncasecmp(inbuf, "debug:", 6)) {
      priority = LOG_DEBUG;
      msgptr = inbuf + 6;
    }
    while (isspace(*msgptr))
      ++msgptr;
    if (in_preform)
      sprintf(outbuf, "<%u>%s", in_val, msgptr);
    else
      sprintf(outbuf, "<%u>%s%s", priority + (facility << 3), prefix,
              strip_priority ? msgptr : inbuf);
    write_message(fd, outbuf, strlen(outbuf));
  }
}


x86 assembly (clang, -O0):
<main_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
lea    -0x820(%rbp),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     164b <main_loop+0x4db>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x1030(%rbp)
movl   $0x0,-0x1034(%rbp)
movl   $0x0,-0x1038(%rbp)
mov    -0x1030(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    12b8 <main_loop+0x148>
cmpl   $0x0,-0x1c(%rbp)
je     12b8 <main_loop+0x148>
mov    -0x1030(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     12b3 <main_loop+0x143>
jmp    122e <main_loop+0xbe>
imul   $0xa,-0x1038(%rbp),%eax
mov    %eax,-0x1038(%rbp)
mov    -0x1040(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
add    -0x1038(%rbp),%eax
mov    %eax,-0x1038(%rbp)
mov    -0x1040(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    122e <main_loop+0xbe>
mov    -0x1040(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    12ae <main_loop+0x13e>
mov    -0x1040(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1030(%rbp)
movl   $0x1,-0x1034(%rbp)
jmp    12b3 <main_loop+0x143>
jmp    12b8 <main_loop+0x148>
cmpl   $0x0,-0x1034(%rbp)
je     12ca <main_loop+0x15a>
jmp    1525 <main_loop+0x3b5>
lea    -0x820(%rbp),%rdi
lea    0xd28(%rip),%rsi
mov    $0xa,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1311 <main_loop+0x1a1>
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x1030(%rbp)
jmp    1520 <main_loop+0x3b0>
lea    -0x820(%rbp),%rdi
lea    0xcec(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1358 <main_loop+0x1e8>
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x1030(%rbp)
jmp    151b <main_loop+0x3ab>
lea    -0x820(%rbp),%rdi
lea    0xcac(%rip),%rsi
mov    $0x9,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    139f <main_loop+0x22f>
mov    0x2c60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x1030(%rbp)
jmp    1516 <main_loop+0x3a6>
lea    -0x820(%rbp),%rdi
lea    0xc6f(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    13e6 <main_loop+0x276>
mov    0x2bd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x1030(%rbp)
jmp    1511 <main_loop+0x3a1>
lea    -0x820(%rbp),%rdi
lea    0xc2f(%rip),%rsi
mov    $0x8,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    142d <main_loop+0x2bd>
mov    0x2bc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x1030(%rbp)
jmp    150c <main_loop+0x39c>
lea    -0x820(%rbp),%rdi
lea    0xbf1(%rip),%rsi
mov    $0x7,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1474 <main_loop+0x304>
mov    0x2b6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x1030(%rbp)
jmp    1507 <main_loop+0x397>
lea    -0x820(%rbp),%rdi
lea    0xbb2(%rip),%rsi
mov    $0x5,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    14bb <main_loop+0x34b>
mov    0x2b14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x1030(%rbp)
jmp    1502 <main_loop+0x392>
lea    -0x820(%rbp),%rdi
lea    0xb71(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
cmp    $0x0,%eax
jne    14fd <main_loop+0x38d>
mov    0x2ad5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
lea    -0x820(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x1030(%rbp)
jmp    1502 <main_loop+0x392>
jmp    1507 <main_loop+0x397>
jmp    150c <main_loop+0x39c>
jmp    1511 <main_loop+0x3a1>
jmp    1516 <main_loop+0x3a6>
jmp    151b <main_loop+0x3ab>
jmp    1520 <main_loop+0x3b0>
jmp    1525 <main_loop+0x3b5>
jmp    152a <main_loop+0x3ba>
mov    -0x1030(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     155a <main_loop+0x3ea>
mov    -0x1030(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1030(%rbp)
jmp    152a <main_loop+0x3ba>
cmpl   $0x0,-0x1034(%rbp)
je     158e <main_loop+0x41e>
lea    -0x1020(%rbp),%rdi
mov    -0x1038(%rbp),%edx
mov    -0x1030(%rbp),%rcx
lea    0xabf(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    160f <main_loop+0x49f>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1024(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
mov    %eax,-0x104c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1048(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     15d8 <main_loop+0x468>
mov    -0x1030(%rbp),%rax
mov    %rax,-0x1060(%rbp)
jmp    15e6 <main_loop+0x476>
lea    -0x820(%rbp),%rax
mov    %rax,-0x1060(%rbp)
mov    -0x1048(%rbp),%rcx
mov    -0x104c(%rbp),%edx
mov    -0x1058(%rbp),%rdi
mov    -0x1060(%rbp),%r8
lea    0xa40(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x106c(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1068(%rbp)
lea    -0x1020(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x106c(%rbp),%edi
mov    -0x1068(%rbp),%rsi
mov    %eax,%edx
call   1080 <write_message@plt>
jmp    118c <main_loop+0x1c>
add    $0x1070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    %r8d,0x14(%rsp)
mov    %ecx,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %rsi,0x18(%rsp)
mov    %edi,0x10(%rsp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x800,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1463 <main_loop+0x2f3>
shll   $0x3,0x8(%rsp)
lea    0x820(%rsp),%r14
jmp    122f <main_loop+0xbf>
nopw   0x0(%rax,%rax,1)
add    0x8(%rsp),%r15d
cmpl   $0x0,0xc(%rsp)
cmove  %r13,%rbx
mov    %r14,%rdi
lea    0xe60(%rip),%rsi
mov    %r15d,%edx
mov    0x18(%rsp),%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    0x10(%rsp),%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1080 <write_message@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    $0x800,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1463 <main_loop+0x2f3>
mov    0x2d7a(%rip),%rax
mov    (%rax),%r15d
mov    $0x0,%r12d
cmpl   $0x0,0x14(%rsp)
je     12a0 <main_loop+0x130>
cmpb   $0x3c,0x20(%rsp)
mov    $0x0,%r12d
jne    12a0 <main_loop+0x130>
movsbl 0x21(%rsp),%edi
call   1030 <isdigit@plt>
mov    $0x0,%r12d
test   %rax,%rax
je     12a0 <main_loop+0x130>
xor    %r12d,%r12d
lea    0x22(%rsp),%rbx
lea    (%r12,%r12,4),%eax
movsbl -0x1(%rbx),%ecx
lea    (%rcx,%rax,2),%r12d
add    $0xffffffd0,%r12d
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1270 <main_loop+0x100>
cmpb   $0x3e,-0x1(%rbx)
jne    12a0 <main_loop+0x130>
xor    %ebp,%ebp
jmp    13e3 <main_loop+0x273>
xchg   %ax,%ax
mov    %r13,%rdi
lea    0xd56(%rip),%rsi
mov    $0xa,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     13a0 <main_loop+0x230>
mov    %r13,%rdi
lea    0xd45(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     13b4 <main_loop+0x244>
mov    %r13,%rdi
lea    0xd30(%rip),%rsi
mov    $0x9,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     13bd <main_loop+0x24d>
mov    %r13,%rdi
lea    0xd1e(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     13d1 <main_loop+0x261>
mov    %r13,%rdi
lea    0xd09(%rip),%rsi
mov    $0x8,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     1427 <main_loop+0x2b7>
mov    %r13,%rdi
lea    0xcf6(%rip),%rsi
mov    $0x7,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     143b <main_loop+0x2cb>
mov    %r13,%rdi
lea    0xce2(%rip),%rsi
mov    $0x5,%edx
call   1070 <strncasecmp@plt>
test   %eax,%eax
je     144f <main_loop+0x2df>
mov    %r13,%rdi
lea    0xccc(%rip),%rsi
mov    $0x6,%edx
call   1070 <strncasecmp@plt>
mov    %r13,%rbx
test   %eax,%eax
jne    138e <main_loop+0x21e>
mov    0x2c32(%rip),%rax
mov    (%rax),%r15d
lea    0x26(%rsp),%rbx
mov    $0x1,%bpl
jmp    13e3 <main_loop+0x273>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2c41(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x2a(%rsp),%rbx
jmp    13e3 <main_loop+0x273>
mov    0x2c2d(%rip),%rax
jmp    13d8 <main_loop+0x268>
mov    0x2c1c(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x29(%rsp),%rbx
jmp    13e3 <main_loop+0x273>
mov    0x2bc8(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x26(%rsp),%rbx
add    $0xffffffffffffffff,%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    13f0 <main_loop+0x280>
test   %bpl,%bpl
jne    11d0 <main_loop+0x60>
mov    %r14,%rdi
lea    0xc2c(%rip),%rsi
mov    %r12d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    11fa <main_loop+0x8a>
mov    0x2ba2(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x28(%rsp),%rbx
jmp    13e3 <main_loop+0x273>
mov    0x2b7e(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x27(%rsp),%rbx
jmp    13e3 <main_loop+0x273>
mov    0x2b5a(%rip),%rax
mov    (%rax),%r15d
mov    $0x1,%bpl
lea    0x25(%rsp),%rbx
jmp    13e3 <main_loop+0x273>
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@LOG_INFO = global i32 0
@.str = [11 x i8] c"emergency:\00"
@LOG_ALERT = global i32 0
@.str.1 = [7 x i8] c"alert:\00"
@.str.2 = [10 x i8] c"critical:\00"
@LOG_CRIT = global i32 0
@.str.3 = [7 x i8] c"error:\00"
@LOG_ERR = global i32 0
@.str.4 = [9 x i8] c"warning:\00"
@LOG_WARNING = global i32 0
@.str.5 = [8 x i8] c"notice:\00"
@LOG_NOTICE = global i32 0
@.str.6 = [6 x i8] c"info:\00"
@.str.7 = [7 x i8] c"debug:\00"
@LOG_DEBUG = global i32 0
@.str.8 = [7 x i8] c"<%u>%s\00"
@.str.9 = [9 x i8] c"<%u>%s%s\00"
define void @main_loop(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2048 x i8]
%12 = alloca [2048 x i8]
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
br label %18
18: ; preds = %176, %5
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i64 @fgets(i8* %19, i32 2048, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %182
23: ; preds = %18
%24 = load i32, i32* @LOG_INFO
store i32 %24, i32* %13
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
store i8* %25, i8** %14
store i32 0, i32* %15
store i32 0, i32* %16
%26 = load i8*, i8** %14
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 60
br i1 %29, label %30, label %67
30: ; preds = %23
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %67
33: ; preds = %30
%34 = load i8*, i8** %14
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %35, i8** %17
%36 = load i8*, i8** %17
%37 = load i8, i8* %36
%38 = call i64 @isdigit(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %66
40: ; preds = %33
br label %41
41: ; preds = %52, %40
%42 = load i32, i32* %16
%43 = mul i32 %42, 10
store i32 %43, i32* %16
%44 = load i8*, i8** %17
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = sub nsw i32 %46, 48
%48 = load i32, i32* %16
%49 = add i32 %48, %47
store i32 %49, i32* %16
%50 = load i8*, i8** %17
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %17
br label %52
52: ; preds = %41
%53 = load i8*, i8** %17
%54 = load i8, i8* %53
%55 = call i64 @isdigit(i8 signext %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %41, label %57
57: ; preds = %52
%58 = load i8*, i8** %17
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 62
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i8*, i8** %17
%64 = getelementptr inbounds i8, i8* %63, i64 1
store i8* %64, i8** %14
store i32 1, i32* %15
br label %65
65: ; preds = %62, %57
br label %66
66: ; preds = %65, %33
br label %67
67: ; preds = %66, %30, %23
%68 = load i32, i32* %15
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %67
br label %143
71: ; preds = %67
%72 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%73 = call i32 @strncasecmp(i8* %72, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%74 = icmp ne i32 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %71
%76 = load i32, i32* @LOG_ALERT
store i32 %76, i32* %13
%77 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%78 = getelementptr inbounds i8, i8* %77, i64 10
store i8* %78, i8** %14
br label %142
79: ; preds = %71
%80 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%81 = call i32 @strncasecmp(i8* %80, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%82 = icmp ne i32 %81, 0
br i1 %82, label %87, label %83
83: ; preds = %79
%84 = load i32, i32* @LOG_ALERT
store i32 %84, i32* %13
%85 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%86 = getelementptr inbounds i8, i8* %85, i64 6
store i8* %86, i8** %14
br label %141
87: ; preds = %79
%88 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%89 = call i32 @strncasecmp(i8* %88, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 9)
%90 = icmp ne i32 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %87
%92 = load i32, i32* @LOG_CRIT
store i32 %92, i32* %13
%93 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds i8, i8* %93, i64 9
store i8* %94, i8** %14
br label %140
95: ; preds = %87
%96 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%97 = call i32 @strncasecmp(i8* %96, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%98 = icmp ne i32 %97, 0
br i1 %98, label %103, label %99
99: ; preds = %95
%100 = load i32, i32* @LOG_ERR
store i32 %100, i32* %13
%101 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%102 = getelementptr inbounds i8, i8* %101, i64 6
store i8* %102, i8** %14
br label %139
103: ; preds = %95
%104 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%105 = call i32 @strncasecmp(i8* %104, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%106 = icmp ne i32 %105, 0
br i1 %106, label %111, label %107
107: ; preds = %103
%108 = load i32, i32* @LOG_WARNING
store i32 %108, i32* %13
%109 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%110 = getelementptr inbounds i8, i8* %109, i64 8
store i8* %110, i8** %14
br label %138
111: ; preds = %103
%112 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%113 = call i32 @strncasecmp(i8* %112, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 7)
%114 = icmp ne i32 %113, 0
br i1 %114, label %119, label %115
115: ; preds = %111
%116 = load i32, i32* @LOG_NOTICE
store i32 %116, i32* %13
%117 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%118 = getelementptr inbounds i8, i8* %117, i64 7
store i8* %118, i8** %14
br label %137
119: ; preds = %111
%120 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%121 = call i32 @strncasecmp(i8* %120, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
%122 = icmp ne i32 %121, 0
br i1 %122, label %127, label %123
123: ; preds = %119
%124 = load i32, i32* @LOG_INFO
store i32 %124, i32* %13
%125 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%126 = getelementptr inbounds i8, i8* %125, i64 5
store i8* %126, i8** %14
br label %136
127: ; preds = %119
%128 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%129 = call i32 @strncasecmp(i8* %128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%130 = icmp ne i32 %129, 0
br i1 %130, label %135, label %131
131: ; preds = %127
%132 = load i32, i32* @LOG_DEBUG
store i32 %132, i32* %13
%133 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
%134 = getelementptr inbounds i8, i8* %133, i64 6
store i8* %134, i8** %14
br label %135
135: ; preds = %131, %127
br label %136
136: ; preds = %135, %123
br label %137
137: ; preds = %136, %115
br label %138
138: ; preds = %137, %107
br label %139
139: ; preds = %138, %99
br label %140
140: ; preds = %139, %91
br label %141
141: ; preds = %140, %83
br label %142
142: ; preds = %141, %75
br label %143
143: ; preds = %142, %70
br label %144
144: ; preds = %149, %143
%145 = load i8*, i8** %14
%146 = load i8, i8* %145
%147 = call i64 @isspace(i8 signext %146)
%148 = icmp ne i64 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %144
%150 = load i8*, i8** %14
%151 = getelementptr inbounds i8, i8* %150, i32 1
store i8* %151, i8** %14
br label %144
152: ; preds = %144
%153 = load i32, i32* %15
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %160
155: ; preds = %152
%156 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i64 0, i64 0
%157 = load i32, i32* %16
%158 = load i8*, i8** %14
%159 = call i32 (i8*, i8*, i32, i8*, ...) @sprintf(i8* %156, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %157, i8* %158)
br label %176
160: ; preds = %152
%161 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i64 0, i64 0
%162 = load i32, i32* %13
%163 = load i32, i32* %8
%164 = shl i32 %163, 3
%165 = add i32 %162, %164
%166 = load i8*, i8** %7
%167 = load i32, i32* %9
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %171
169: ; preds = %160
%170 = load i8*, i8** %14
br label %173
171: ; preds = %160
%172 = getelementptr inbounds [2048 x i8], [2048 x i8]* %11, i64 0, i64 0
br label %173
173: ; preds = %171, %169
%174 = phi i8* [ %170, %169 ], [ %172, %171 ]
%175 = call i32 (i8*, i8*, i32, i8*, ...) @sprintf(i8* %161, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %165, i8* %166, i8* %174)
br label %176
176: ; preds = %173, %155
%177 = load i32, i32* %6
%178 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i64 0, i64 0
%179 = getelementptr inbounds [2048 x i8], [2048 x i8]* %12, i64 0, i64 0
%180 = call i32 @strlen(i8* %179)
%181 = call i32 @write_message(i32 %177, i8* %178, i32 %180)
br label %18
182: ; preds = %18
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@LOG_INFO = global i32 0
@.str = [11 x i8] c"emergency:\00"
@LOG_ALERT = global i32 0
@.str.1 = [7 x i8] c"alert:\00"
@.str.2 = [10 x i8] c"critical:\00"
@LOG_CRIT = global i32 0
@.str.3 = [7 x i8] c"error:\00"
@LOG_ERR = global i32 0
@.str.4 = [9 x i8] c"warning:\00"
@LOG_WARNING = global i32 0
@.str.5 = [8 x i8] c"notice:\00"
@LOG_NOTICE = global i32 0
@.str.6 = [6 x i8] c"info:\00"
@.str.7 = [7 x i8] c"debug:\00"
@LOG_DEBUG = global i32 0
@.str.8 = [7 x i8] c"<%u>%s\00"
@.str.9 = [9 x i8] c"<%u>%s%s\00"
define void @main_loop(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [2048 x i8]
%7 = alloca [2048 x i8]
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i64 @fgets(i8* %8, i32 2048, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %115, label %13
13: ; preds = %5
%14 = icmp ne i32 %4, 0
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 1
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 6
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 5
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 7
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 8
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 9
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 10
%22 = shl i32 %2, 3
%23 = icmp eq i32 %3, 0
br label %24
24: ; preds = %13, %109
%25 = load i32, i32* @LOG_INFO
%26 = load i8, i8* %8
%27 = icmp eq i8 %26, 60
%28 = and i1 %14, %27
br i1 %28, label %29, label %49
29: ; preds = %24
%30 = load i8, i8* %15
%31 = call i64 @isdigit(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %49, label %33
33: ; preds = %29, %33
%34 = phi i32 [ %40, %33 ], [ 0, %29 ]
%35 = phi i8* [ %41, %33 ], [ %15, %29 ]
%36 = mul i32 %34, 10
%37 = load i8, i8* %35
%38 = sext i8 %37 to i32
%39 = add i32 %36, -48
%40 = add i32 %39, %38
%41 = getelementptr inbounds i8, i8* %35, i64 1
%42 = load i8, i8* %41
%43 = call i64 @isdigit(i8 signext %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %33
45: ; preds = %33
%46 = load i8, i8* %41
%47 = icmp eq i8 %46, 62
%48 = getelementptr inbounds i8, i8* %35, i64 2
br i1 %47, label %91, label %49
49: ; preds = %24, %29, %45
%50 = phi i32 [ %40, %45 ], [ 0, %29 ], [ 0, %24 ]
%51 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i32, i32* @LOG_ALERT
br label %91
55: ; preds = %49
%56 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = load i32, i32* @LOG_ALERT
br label %91
60: ; preds = %55
%61 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 9)
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = load i32, i32* @LOG_CRIT
br label %91
65: ; preds = %60
%66 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = load i32, i32* @LOG_ERR
br label %91
70: ; preds = %65
%71 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = load i32, i32* @LOG_WARNING
br label %91
75: ; preds = %70
%76 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 7)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = load i32, i32* @LOG_NOTICE
br label %91
80: ; preds = %75
%81 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = load i32, i32* @LOG_INFO
br label %91
85: ; preds = %80
%86 = call i32 @strncasecmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%87 = icmp eq i32 %86, 0
%88 = load i32, i32* @LOG_DEBUG
%89 = select i1 %87, i32 %88, i32 %25
%90 = select i1 %87, i8* %16, i8* %8
br label %91
91: ; preds = %85, %45, %53, %63, %73, %83, %78, %68, %58
%92 = phi i1 [ true, %83 ], [ true, %78 ], [ true, %73 ], [ true, %68 ], [ true, %63 ], [ true, %58 ], [ true, %53 ], [ false, %45 ], [ true, %85 ]
%93 = phi i32 [ %50, %83 ], [ %50, %78 ], [ %50, %73 ], [ %50, %68 ], [ %50, %63 ], [ %50, %58 ], [ %50, %53 ], [ %40, %45 ], [ %50, %85 ]
%94 = phi i32 [ %84, %83 ], [ %79, %78 ], [ %74, %73 ], [ %69, %68 ], [ %64, %63 ], [ %59, %58 ], [ %54, %53 ], [ %25, %45 ], [ %89, %85 ]
%95 = phi i8* [ %17, %83 ], [ %18, %78 ], [ %19, %73 ], [ %16, %68 ], [ %20, %63 ], [ %16, %58 ], [ %21, %53 ], [ %48, %45 ], [ %90, %85 ]
br label %96
96: ; preds = %96, %91
%97 = phi i8* [ %95, %91 ], [ %101, %96 ]
%98 = load i8, i8* %97
%99 = call i64 @isspace(i8 signext %98)
%100 = icmp eq i64 %99, 0
%101 = getelementptr inbounds i8, i8* %97, i64 1
br i1 %100, label %102, label %96
102: ; preds = %96
br i1 %92, label %105, label %103
103: ; preds = %102
%104 = call i32 (i8*, i8*, i32, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %93, i8* %97)
br label %109
105: ; preds = %102
%106 = add i32 %94, %22
%107 = select i1 %23, i8* %8, i8* %97
%108 = call i32 (i8*, i8*, i32, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %106, i8* %1, i8* %107)
br label %109
109: ; preds = %105, %103
%110 = call i32 @strlen(i8* %9)
%111 = call i32 @write_message(i32 %0, i8* %9, i32 %110)
%112 = load i32, i32* @stdin
%113 = call i64 @fgets(i8* %8, i32 2048, i32 %112)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %24
115: ; preds = %109, %5
ret void
}