#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int snprintf(char *, int, char *, char *);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void filt_b_message(char *msg, char *keycat) {
  char *p1, *p2, *p3;
  char dst[256];
  char *cur = &dst[0], *pcur;
  int n;
  int check_EZP = 0;
  p1 = strchr(msg, '>') + 1;
  p2 = strchr(msg, '<');
  p3 = strstr(msg, "]: ") + strlen("]: ");
  n = snprintf(cur, 256, "<%s>\t", keycat);
  cur = cur + n;
  memcpy(cur, p1, sizeof("Dec  8 11:12:58 ") - 1);
  cur = cur + (sizeof("Dec  8 11:12:58 ") - 1);
  n = snprintf(cur, 256 - (cur - &dst[0]), "%s", p3);
  strncpy(msg, dst, 256);
  printf("msg:%s\r\n", msg);
}


x86 assembly (clang, -O0):
<filt_b_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
movl   $0x0,-0x148(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3e,%esi
call   1050 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x150(%rbp)
lea    0xe1f(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x150(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xdf4(%rip),%rdx
call   1070 <snprintf@plt>
mov    %eax,-0x144(%rbp)
mov    -0x138(%rbp),%rax
movslq -0x144(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1080 <memcpy@plt>
mov    -0x138(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rdi
mov    -0x138(%rbp),%rcx
lea    -0x130(%rbp),%rax
sub    %rax,%rcx
mov    $0x100,%eax
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rcx
lea    0xd83(%rip),%rdx
call   1070 <snprintf@plt>
mov    %eax,-0x144(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rsi
lea    0xd5b(%rip),%rdi
call   1060 <printf@plt>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filt_b_message>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
mov    $0x3e,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%r13
lea    0xe64(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
add    %r15,%rbp
lea    0xe45(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r12,%rcx
call   1070 <snprintf@plt>
movslq %eax,%rbx
lea    (%rsp,%rbx,1),%rdi
mov    %r13,%rsi
mov    $0x10,%edx
call   1080 <memcpy@plt>
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
mov    %r15d,%esi
sub    %edi,%esi
add    $0x100,%esi
lea    0xe0a(%rip),%rdx
mov    %rbp,%rcx
call   1070 <snprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    0xdee(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"]: \00"
@.str.1 = [6 x i8] c"<%s>\09\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"msg:%s\0D\0A\00"
define void @filt_b_message(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [256 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8* %13, i8** %9
store i32 0, i32* %12
%14 = load i8*, i8** %3
%15 = call i8* @strchr(i8* %14, i8 signext 62)
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %5
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 60)
store i8* %18, i8** %6
%19 = load i8*, i8** %3
%20 = call i8* @strstr(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8* %23, i8** %7
%24 = load i8*, i8** %9
%25 = load i8*, i8** %4
%26 = call i32 @snprintf(i8* %24, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 %26, i32* %11
%27 = load i8*, i8** %9
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = load i8*, i8** %5
%33 = call i32 @memcpy(i8* %31, i8* %32, i32 16)
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i64 16
store i8* %35, i8** %9
%36 = load i8*, i8** %9
%37 = load i8*, i8** %9
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%39 = ptrtoint i8* %37 to i64
%40 = ptrtoint i8* %38 to i64
%41 = sub i64 %39, %40
%42 = sub nsw i64 256, %41
%43 = trunc i64 %42 to i32
%44 = load i8*, i8** %7
%45 = call i32 @snprintf(i8* %36, i32 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %44)
store i32 %45, i32* %11
%46 = load i8*, i8** %3
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%48 = call i32 @strncpy(i8* %46, i8* %47, i32 256)
%49 = load i8*, i8** %3
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %49)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"]: \00"
@.str.1 = [6 x i8] c"<%s>\09\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"msg:%s\0D\0A\00"
define void @filt_b_message(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 62)
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = call i32 @snprintf(i8* %4, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %12
%14 = call i32 @memcpy(i8* %13, i8* %6, i32 16)
%15 = getelementptr inbounds i8, i8* %13, i64 16
%16 = ptrtoint i8* %15 to i64
%17 = ptrtoint [256 x i8]* %3 to i64
%18 = sub i64 %17, %16
%19 = trunc i64 %18 to i32
%20 = add i32 %19, 256
%21 = call i32 @snprintf(i8* %15, i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%22 = call i32 @strncpy(i8* %0, i8* %4, i32 256)
%23 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %0)
ret void
}