#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*/ tmp;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct timeval {
  scalar_t__ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sin;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(int /*<<< orphan*/);
int isatty(int);
scalar_t__ isdigit(char);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int);
int main(void) {
  const int tty = isatty(1);
  struct sockaddr_in sin;
  int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  char buf[2000];
  char tmp[100];
  memset(&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_port = htons(4000);
  struct timeval tv;
  if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
    perror("bind");
  }
  while (1) {
    struct sockaddr_in sin;
    socklen_t slen = sizeof(struct sockaddr_in);
    int len = recvfrom(fd, buf, 2000, 0, (struct sockaddr *)&sin, &slen);
    if (len < 1)
      break;
    int off = 0;
    const char *pfx = "";
    const char *postfix = "";
    if (buf[0] == '<' && isdigit(buf[1])) {
      int num = atoi(buf + 1);
      int pri = num & 7;
      while (buf[off] != '>' && off < len)
        off++;
      off++;
      postfix = tty ? "\033[0m" : "";
      switch (pri) {
      case 0:
        pfx = "\033[31mEMERG      ";
        break;
      case 1:
        pfx = "\033[31mALERT      ";
        break;
      case 2:
        pfx = "\033[31mCRITICAL   ";
        break;
      case 3:
        pfx = "\033[31mERROR      ";
        break;
      case 4:
        pfx = "\033[33mWARNING    ";
        break;
      case 5:
        pfx = "\033[34mNOTICE     ";
        break;
      case 6:
        pfx = "\033[33mINFO       ";
        break;
      case 7:
        pfx = "DEBUG      ";
        break;
      }
      if (pfx[0] == '\033' && !tty)
        pfx += 5;
    }
    if (off == len)
      continue;
    const char *addr = inet_ntoa(sin.sin_addr);
    write(1, addr, strlen(addr));
    write(1, ": ", 2);
    gettimeofday(&tv, NULL);
    time_t now = tv.tv_sec;
    struct tm *tm = localtime(&now);
    snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d.%03d: ", tm->tm_hour, tm->tm_min,
             tm->tm_sec, (int)tv.tv_usec / 1000);
    write(1, tmp, strlen(tmp));
    write(1, pfx, strlen(pfx));
    write(1, buf + off, len - off);
    if (buf[len - 1] != '\n')
      write(1, "\n", 1);
    write(1, postfix, strlen(postfix));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x900,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1050 <isatty@plt>
mov    %eax,-0x8(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
mov    0x2da0(%rip),%rax
mov    (%rax),%edx
call   1110 <socket@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10c0 <memset@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0xfa0,%edi
call   1090 <htons@plt>
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    1282 <main+0x92>
lea    0xda3(%rip),%rdi
call   10f0 <perror@plt>
jmp    1287 <main+0x97>
movl   $0xc,-0x884(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x7f0(%rbp),%rsi
lea    -0x880(%rbp),%r8
mov    $0x7d0,%edx
xor    %ecx,%ecx
lea    -0x884(%rbp),%r9
call   10d0 <recvfrom@plt>
mov    %eax,-0x888(%rbp)
cmpl   $0x1,-0x888(%rbp)
jge    12cd <main+0xdd>
jmp    1682 <main+0x492>
movl   $0x0,-0x88c(%rbp)
lea    0xde6(%rip),%rax
mov    %rax,-0x898(%rbp)
lea    0xdd8(%rip),%rax
mov    %rax,-0x8a0(%rbp)
movsbl -0x7f0(%rbp),%eax
cmp    $0x3c,%eax
jne    14bc <main+0x2cc>
movsbl -0x7ef(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     14bc <main+0x2cc>
lea    -0x7f0(%rbp),%rdi
add    $0x1,%rdi
call   1100 <atoi@plt>
mov    %eax,-0x8a4(%rbp)
mov    -0x8a4(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x8a8(%rbp)
movslq -0x88c(%rbp),%rax
movsbl -0x7f0(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x3e,%ecx
mov    %al,-0x8c1(%rbp)
je     1373 <main+0x183>
mov    -0x88c(%rbp),%eax
cmp    -0x888(%rbp),%eax
setl   %al
mov    %al,-0x8c1(%rbp)
mov    -0x8c1(%rbp),%al
test   $0x1,%al
jne    1386 <main+0x196>
jmp    139a <main+0x1aa>
mov    -0x88c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88c(%rbp)
jmp    133e <main+0x14e>
mov    -0x88c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88c(%rbp)
mov    -0x8(%rbp),%eax
test   %eax,%eax
lea    0xc70(%rip),%rcx
lea    0xd08(%rip),%rax
cmovne %rcx,%rax
mov    %rax,-0x8a0(%rbp)
mov    -0x8a8(%rbp),%eax
mov    %rax,-0x8d0(%rbp)
sub    $0x7,%rax
ja     1488 <main+0x298>
mov    -0x8d0(%rbp),%rax
lea    0xc14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xc2e(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc2c(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc2a(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc28(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc26(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc24(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc22(%rip),%rax
mov    %rax,-0x898(%rbp)
jmp    1488 <main+0x298>
lea    0xc20(%rip),%rax
mov    %rax,-0x898(%rbp)
mov    -0x898(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1b,%eax
jne    14b7 <main+0x2c7>
cmpl   $0x0,-0x8(%rbp)
jne    14b7 <main+0x2c7>
mov    -0x898(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x898(%rbp)
jmp    14bc <main+0x2cc>
mov    -0x88c(%rbp),%eax
cmp    -0x888(%rbp),%eax
jne    14d3 <main+0x2e3>
jmp    1287 <main+0x97>
mov    -0x880(%rbp),%edi
call   1070 <inet_ntoa@plt>
mov    %rax,-0x8b0(%rbp)
mov    -0x8b0(%rbp),%rax
mov    %rax,-0x8e8(%rbp)
mov    -0x8b0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x8e8(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1060 <write@plt>
mov    $0x1,%edi
lea    0xba2(%rip),%rsi
mov    $0x2,%edx
call   1060 <write@plt>
lea    -0x870(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <gettimeofday@plt>
mov    -0x868(%rbp),%eax
mov    %eax,-0x8b4(%rbp)
lea    -0x8b4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8c0(%rbp)
lea    -0x860(%rbp),%rdi
mov    -0x8c0(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8c0(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x8c0(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x870(%rbp),%rax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    $0x64,%esi
lea    0xb15(%rip),%rdx
mov    %eax,(%rsp)
call   10a0 <snprintf@plt>
lea    -0x860(%rbp),%rax
mov    %rax,-0x8e0(%rbp)
lea    -0x860(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x8e0(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1060 <write@plt>
mov    -0x898(%rbp),%rax
mov    %rax,-0x8d8(%rbp)
mov    -0x898(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x8d8(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1060 <write@plt>
lea    -0x7f0(%rbp),%rsi
movslq -0x88c(%rbp),%rax
add    %rax,%rsi
mov    -0x888(%rbp),%edx
sub    -0x88c(%rbp),%edx
mov    $0x1,%edi
call   1060 <write@plt>
mov    -0x888(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x7f0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     1650 <main+0x460>
mov    $0x1,%edx
lea    0xa7a(%rip),%rsi
mov    %edx,%edi
call   1060 <write@plt>
mov    -0x8a0(%rbp),%rax
mov    %rax,-0x8f0(%rbp)
mov    -0x8a0(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x8f0(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1060 <write@plt>
jmp    1287 <main+0x97>
xor    %eax,%eax
add    $0x900,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x898,%rsp
mov    $0x1,%edi
call   1050 <isatty@plt>
mov    %eax,0x10(%rsp)
mov    0x2dd2(%rip),%r14
mov    (%r14),%edi
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
call   1110 <socket@plt>
mov    %eax,%ebx
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10c0 <memset@plt>
mov    (%r14),%eax
mov    %eax,0x38(%rsp)
mov    $0xfa0,%edi
call   1090 <htons@plt>
mov    %eax,0x34(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
js     14e3 <main+0x2f3>
movl   $0xc,0xc(%rsp)
lea    0xc0(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %ebx,%edi
mov    $0x7d0,%edx
xor    %ecx,%ecx
call   10d0 <recvfrom@plt>
test   %eax,%eax
jle    14cf <main+0x2df>
mov    %eax,%r14d
mov    %ebx,%ebp
cmpl   $0x0,0x10(%rsp)
lea    0xd51(%rip),%rax
lea    0xde9(%rip),%rcx
cmove  %rcx,%rax
mov    %rax,0x18(%rsp)
jmp    131a <main+0x12a>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1060 <write@plt>
movl   $0xc,0xc(%rsp)
mov    %ebp,%edi
lea    0xc0(%rsp),%rsi
mov    $0x7d0,%edx
xor    %ecx,%ecx
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
call   10d0 <recvfrom@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    14cf <main+0x2df>
cmpb   $0x3c,0xc0(%rsp)
3c
mov    $0x0,%r15d
lea    0xd75(%rip),%r12
mov    %r12,%r13
jne    13c0 <main+0x1d0>
movsbl 0xc1(%rsp),%edi
call   1040 <isdigit@plt>
mov    $0x0,%r15d
lea    0xd52(%rip),%r12
mov    %r12,%r13
test   %rax,%rax
je     13c0 <main+0x1d0>
lea    0xc1(%rsp),%rdi
call   1100 <atoi@plt>
mov    %r14d,%ecx
xor    %edx,%edx
nopl   0x0(%rax)
lea    0x1(%rdx),%r15
cmpb   $0x3e,0xc0(%rsp,%rdx,1)
3e
je     1386 <main+0x196>
cmp    %rcx,%rdx
mov    %r15,%rdx
jb     1370 <main+0x180>
cmpl   $0x0,0x10(%rsp)
sete   %dl
and    $0x7,%eax
lea    0x2a30(%rip),%rsi
mov    (%rsi,%rax,8),%r13
cmpb   $0x1b,0x0(%r13)
sete   %al
cmp    %r15d,%ecx
je     12e7 <main+0xf7>
and    %dl,%al
movzbl %al,%eax
lea    (%rax,%rax,4),%rax
add    %rax,%r13
mov    0x18(%rsp),%r12
xchg   %ax,%ax
mov    0x20(%rsp),%edi
call   1070 <inet_ntoa@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    $0x1,%edi
lea    0xcb1(%rip),%rsi
mov    $0x2,%edx
call   1060 <write@plt>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
mov    0x48(%rsp),%eax
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    0x4(%rax),%r8d
mov    0x8(%rax),%r9d
movslq 0x40(%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
mov    %eax,(%rsp)
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
lea    0xc3c(%rip),%rdx
call   10a0 <snprintf@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r13,%rdi
call   1080 <strlen@plt>
mov    $0x1,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1060 <write@plt>
movslq %r15d,%rax
lea    (%rsp,%rax,1),%rsi
add    $0xc0,%rsi
mov    %r14d,%edx
sub    %eax,%edx
mov    $0x1,%edi
call   1060 <write@plt>
add    $0xffffffff,%r14d
cmpb   $0xa,0xc0(%rsp,%r14,1)
je     12d0 <main+0xe0>
mov    $0x1,%edi
lea    0xbe3(%rip),%rsi
mov    $0x1,%edx
call   1060 <write@plt>
jmp    12d0 <main+0xe0>
xor    %eax,%eax
add    $0x898,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb16(%rip),%rdi
call   10f0 <perror@plt>
jmp    1273 <main+0x83>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str = [5 x i8] c"bind\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [17 x i8] c"\1B[31mEMERG \00"
@.str.4 = [17 x i8] c"\1B[31mALERT \00"
@.str.5 = [17 x i8] c"\1B[31mCRITICAL \00"
@.str.6 = [17 x i8] c"\1B[31mERROR \00"
@.str.7 = [17 x i8] c"\1B[33mWARNING \00"
@.str.8 = [17 x i8] c"\1B[34mNOTICE \00"
@.str.9 = [17 x i8] c"\1B[33mINFO \00"
@.str.10 = [12 x i8] c"DEBUG \00"
@.str.11 = [3 x i8] c": \00"
@.str.12 = [22 x i8] c"%02d:%02d:%02d.%03d: \00"
@.str.13 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [2000 x i8]
%6 = alloca [100 x i8]
%7 = alloca %struct.timeval
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca %struct.tm*
store i32 0, i32* %1
%19 = call i32 @isatty(i32 1)
store i32 %19, i32* %2
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_DGRAM
%22 = load i32, i32* @IPPROTO_UDP
%23 = call i32 @socket(i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %4
%24 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %25, i32* %26
%27 = call i32 @htons(i32 4000)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* %4
%30 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%31 = call i64 @bind(i32 %29, %struct.sockaddr* %30, i32 12)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %0
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %33, %0
br label %36
36: ; preds = %35, %109, %163
store i32 12, i32* %9
%37 = load i32, i32* %4
%38 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%39 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%40 = call i32 @recvfrom(i32 %37, i8* %38, i32 2000, i32 0, %struct.sockaddr* %39, i32* %9)
store i32 %40, i32* %10
%41 = load i32, i32* %10
%42 = icmp slt i32 %41, 1
br i1 %42, label %43, label %44
43: ; preds = %36
br label %168
44: ; preds = %36
store i32 0, i32* %11
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %13
%45 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 60
br i1 %48, label %49, label %105
49: ; preds = %44
%50 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 1
%51 = load i8, i8* %50
%52 = call i64 @isdigit(i8 signext %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %105
54: ; preds = %49
%55 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = call i32 @atoi(i8* %56)
store i32 %57, i32* %14
%58 = load i32, i32* %14
%59 = and i32 %58, 7
store i32 %59, i32* %15
br label %60
60: ; preds = %73, %54
%61 = load i32, i32* %11
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 62
br i1 %66, label %67, label %71
67: ; preds = %60
%68 = load i32, i32* %11
%69 = load i32, i32* %10
%70 = icmp slt i32 %68, %69
br label %71
71: ; preds = %67, %60
%72 = phi i1 [ false, %60 ], [ %70, %67 ]
br i1 %72, label %73, label %76
73: ; preds = %71
%74 = load i32, i32* %11
%75 = add nsw i32 %74, 1
store i32 %75, i32* %11
br label %60
76: ; preds = %71
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 1
store i32 %78, i32* %11
%79 = load i32, i32* %2
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i64
%82 = select i1 %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
store i8* %82, i8** %13
%83 = load i32, i32* %15
switch i32 %83, label %92 [
i32 0, label %84
i32 1, label %85
i32 2, label %86
i32 3, label %87
i32 4, label %88
i32 5, label %89
i32 6, label %90
i32 7, label %91
]
84: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %12
br label %92
85: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %12
br label %92
86: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %12
br label %92
87: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8** %12
br label %92
88: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8** %12
br label %92
89: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8** %12
br label %92
90: ; preds = %76
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8** %12
br label %92
91: ; preds = %76
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8** %12
br label %92
92: ; preds = %76, %91, %90, %89, %88, %87, %86, %85, %84
%93 = load i8*, i8** %12
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 27
br i1 %97, label %98, label %104
98: ; preds = %92
%99 = load i32, i32* %2
%100 = icmp ne i32 %99, 0
br i1 %100, label %104, label %101
101: ; preds = %98
%102 = load i8*, i8** %12
%103 = getelementptr inbounds i8, i8* %102, i64 5
store i8* %103, i8** %12
br label %104
104: ; preds = %101, %98, %92
br label %105
105: ; preds = %104, %49, %44
%106 = load i32, i32* %11
%107 = load i32, i32* %10
%108 = icmp eq i32 %106, %107
br i1 %108, label %109, label %110
109: ; preds = %105
br label %36
110: ; preds = %105
%111 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%112 = load i32, i32* %111
%113 = call i8* @inet_ntoa(i32 %112)
store i8* %113, i8** %16
%114 = load i8*, i8** %16
%115 = load i8*, i8** %16
%116 = call i32 @strlen(i8* %115)
%117 = call i32 @write(i32 1, i8* %114, i32 %116)
%118 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%119 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%120 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%121 = load i32, i32* %120
store i32 %121, i32* %17
%122 = call %struct.tm* @localtime(i32* %17)
store %struct.tm* %122, %struct.tm** %18
%123 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%124 = load %struct.tm*, %struct.tm** %18
%125 = getelementptr inbounds %struct.tm, %struct.tm* %124, i32 0, i32 0
%126 = load i32, i32* %125
%127 = load %struct.tm*, %struct.tm** %18
%128 = getelementptr inbounds %struct.tm, %struct.tm* %127, i32 0, i32 1
%129 = load i32, i32* %128
%130 = load %struct.tm*, %struct.tm** %18
%131 = getelementptr inbounds %struct.tm, %struct.tm* %130, i32 0, i32 2
%132 = load i32, i32* %131
%133 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%134 = load i64, i64* %133
%135 = trunc i64 %134 to i32
%136 = sdiv i32 %135, 1000
%137 = call i32 @snprintf(i8* %123, i32 100, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %126, i32 %129, i32 %132, i32 %136)
%138 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%139 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%140 = call i32 @strlen(i8* %139)
%141 = call i32 @write(i32 1, i8* %138, i32 %140)
%142 = load i8*, i8** %12
%143 = load i8*, i8** %12
%144 = call i32 @strlen(i8* %143)
%145 = call i32 @write(i32 1, i8* %142, i32 %144)
%146 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%147 = load i32, i32* %11
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %146, i64 %148
%150 = load i32, i32* %10
%151 = load i32, i32* %11
%152 = sub nsw i32 %150, %151
%153 = call i32 @write(i32 1, i8* %149, i32 %152)
%154 = load i32, i32* %10
%155 = sub nsw i32 %154, 1
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %156
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = icmp ne i32 %159, 10
br i1 %160, label %161, label %163
161: ; preds = %110
%162 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 1)
br label %163
163: ; preds = %161, %110
%164 = load i8*, i8** %13
%165 = load i8*, i8** %13
%166 = call i32 @strlen(i8* %165)
%167 = call i32 @write(i32 1, i8* %164, i32 %166)
br label %36
168: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i64, i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32, i32, i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str = [5 x i8] c"bind\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [17 x i8] c"\1B[31mEMERG \00"
@.str.4 = [17 x i8] c"\1B[31mALERT \00"
@.str.5 = [17 x i8] c"\1B[31mCRITICAL \00"
@.str.6 = [17 x i8] c"\1B[31mERROR \00"
@.str.7 = [17 x i8] c"\1B[33mWARNING \00"
@.str.8 = [17 x i8] c"\1B[34mNOTICE \00"
@.str.9 = [17 x i8] c"\1B[33mINFO \00"
@.str.10 = [12 x i8] c"DEBUG \00"
@.str.11 = [3 x i8] c": \00"
@.str.12 = [22 x i8] c"%02d:%02d:%02d.%03d: \00"
@.str.13 = [2 x i8] c"\0A\00"
@switch.table.main = [8 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0)]
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [2000 x i8]
%3 = alloca [100 x i8]
%4 = alloca %struct.timeval
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = tail call i32 @isatty(i32 1)
%9 = bitcast %struct.sockaddr_in* %1 to i8*
%10 = load i32, i32* @AF_INET
%11 = load i32, i32* @SOCK_DGRAM
%12 = load i32, i32* @IPPROTO_UDP
%13 = tail call i32 @socket(i32 %10, i32 %11, i32 %12)
%14 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @htons(i32 4000)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %19, i32* %20
%21 = bitcast %struct.timeval* %4 to i8*
%22 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%23 = call i64 @bind(i32 %13, %struct.sockaddr* %22, i32 12)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %0
%28 = bitcast %struct.sockaddr_in* %5 to i8*
%29 = bitcast i32* %6 to i8*
%30 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
store i32 12, i32* %6
%31 = call i32 @recvfrom(i32 %13, i8* %14, i32 2000, i32 0, %struct.sockaddr* %30, i32* %6)
%32 = icmp slt i32 %31, 1
br i1 %32, label %116, label %33
33: ; preds = %27
%34 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 1
%35 = icmp ne i32 %8, 0
%36 = select i1 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
%38 = bitcast i32* %7 to i8*
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
br label %41
41: ; preds = %33, %113
%42 = phi i32 [ %31, %33 ], [ %114, %113 ]
%43 = load i8, i8* %14
%44 = icmp eq i8 %43, 60
br i1 %44, label %45, label %73
45: ; preds = %41
%46 = load i8, i8* %34
%47 = call i64 @isdigit(i8 signext %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %73, label %49
49: ; preds = %45
%50 = call i32 @atoi(i8* %34)
%51 = zext i32 %42 to i64
br label %52
52: ; preds = %52, %49
%53 = phi i64 [ %59, %52 ], [ 0, %49 ]
%54 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = icmp ne i8 %55, 62
%57 = icmp ult i64 %53, %51
%58 = select i1 %56, i1 %57, i1 false
%59 = add nuw nsw i64 %53, 1
br i1 %58, label %52, label %60
60: ; preds = %52
%61 = and i32 %50, 7
%62 = trunc i64 %53 to i32
%63 = add nuw nsw i32 %62, 1
%64 = zext i32 %61 to i64
%65 = getelementptr inbounds [8 x i8*], [8 x i8*]* @switch.table.main, i64 0, i64 %64
%66 = load i8*, i8** %65
%67 = load i8, i8* %66
%68 = icmp ne i8 %67, 27
%69 = select i1 %68, i1 true, i1 %35
%70 = select i1 %69, i64 0, i64 5
%71 = getelementptr i8, i8* %66, i64 %70
%72 = icmp eq i32 %42, %63
br i1 %72, label %113, label %73
73: ; preds = %41, %45, %60
%74 = phi i32 [ %63, %60 ], [ 0, %45 ], [ 0, %41 ]
%75 = phi i8* [ %71, %60 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %45 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %41 ]
%76 = phi i8* [ %36, %60 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %45 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %41 ]
%77 = load i32, i32* %37
%78 = call i8* @inet_ntoa(i32 %77)
%79 = call i32 @strlen(i8* %78)
%80 = call i32 @write(i32 1, i8* %78, i32 %79)
%81 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%82 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%83 = load i32, i32* %39
store i32 %83, i32* %7
%84 = call %struct.tm* @localtime(i32* %7)
%85 = getelementptr inbounds %struct.tm, %struct.tm* %84, i64 0, i32 0
%86 = load i32, i32* %85
%87 = getelementptr inbounds %struct.tm, %struct.tm* %84, i64 0, i32 1
%88 = load i32, i32* %87
%89 = getelementptr inbounds %struct.tm, %struct.tm* %84, i64 0, i32 2
%90 = load i32, i32* %89
%91 = load i64, i64* %40
%92 = trunc i64 %91 to i32
%93 = sdiv i32 %92, 1000
%94 = call i32 @snprintf(i8* %15, i32 100, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i32 %86, i32 %88, i32 %90, i32 %93)
%95 = call i32 @strlen(i8* %15)
%96 = call i32 @write(i32 1, i8* %15, i32 %95)
%97 = call i32 @strlen(i8* %75)
%98 = call i32 @write(i32 1, i8* %75, i32 %97)
%99 = sext i32 %74 to i64
%100 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %99
%101 = sub nsw i32 %42, %74
%102 = call i32 @write(i32 1, i8* %100, i32 %101)
%103 = add nsw i32 %42, -1
%104 = zext i32 %103 to i64
%105 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %104
%106 = load i8, i8* %105
%107 = icmp eq i8 %106, 10
br i1 %107, label %110, label %108
108: ; preds = %73
%109 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32 1)
br label %110
110: ; preds = %108, %73
%111 = call i32 @strlen(i8* %76)
%112 = call i32 @write(i32 1, i8* %76, i32 %111)
br label %113
113: ; preds = %110, %60
store i32 12, i32* %6
%114 = call i32 @recvfrom(i32 %13, i8* %14, i32 2000, i32 0, %struct.sockaddr* %30, i32* %6)
%115 = icmp slt i32 %114, 1
br i1 %115, label %116, label %41
116: ; preds = %113, %27
ret i32 0
}