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

/* Variables and functions */
int irc_protocol_log_level_for_command(char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
const char *irc_protocol_tags(const char *command, const char *tags,
                              const char *nick) {
  static char string[1024];
  int log_level;
  char str_log_level[32];
  str_log_level[0] = '\0';
  if (!command && !tags && !nick)
    return NULL;
  if (command && command[0]) {
    log_level = irc_protocol_log_level_for_command(command);
    if (log_level > 0) {
      snprintf(str_log_level, sizeof(str_log_level), ",log%d", log_level);
    }
  }
  snprintf(string, sizeof(string), "%s%s%s%s%s%s%s",
           (command && command[0]) ? "irc_" : "",
           (command && command[0]) ? command : "", (tags && tags[0]) ? "," : "",
           (tags && tags[0]) ? tags : "", (nick && nick[0]) ? ",nick_" : "",
           (nick && nick[0]) ? nick : "", str_log_level);
  return string;
}


x86 assembly (clang, -O0):
<irc_protocol_tags>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movb   $0x0,-0x50(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116a <irc_protocol_tags+0x4a>
cmpq   $0x0,-0x20(%rbp)
jne    116a <irc_protocol_tags+0x4a>
cmpq   $0x0,-0x28(%rbp)
jne    116a <irc_protocol_tags+0x4a>
movq   $0x0,-0x10(%rbp)
jmp    13a1 <irc_protocol_tags+0x281>
cmpq   $0x0,-0x18(%rbp)
je     11ba <irc_protocol_tags+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ba <irc_protocol_tags+0x9a>
mov    -0x18(%rbp),%rdi
call   1030 <irc_protocol_log_level_for_command@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    11b5 <irc_protocol_tags+0x95>
lea    -0x50(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x20,%esi
lea    0xe52(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    11ba <irc_protocol_tags+0x9a>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x51(%rbp)
je     11da <irc_protocol_tags+0xba>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%dl
lea    0xe38(%rip),%rax
lea    0xe2b(%rip),%rcx
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     121e <irc_protocol_tags+0xfe>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     121e <irc_protocol_tags+0xfe>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    122e <irc_protocol_tags+0x10e>
lea    0xdf7(%rip),%rax
mov    %rax,-0x68(%rbp)
jmp    122e <irc_protocol_tags+0x10e>
mov    -0x68(%rbp),%rax
mov    %rax,-0x78(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x69(%rbp)
je     1256 <irc_protocol_tags+0x136>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%dl
lea    0xdbc(%rip),%rax
lea    0xdb4(%rip),%rcx
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     129d <irc_protocol_tags+0x17d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     129d <irc_protocol_tags+0x17d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x88(%rbp)
jmp    12b0 <irc_protocol_tags+0x190>
lea    0xd78(%rip),%rax
mov    %rax,-0x88(%rbp)
jmp    12b0 <irc_protocol_tags+0x190>
mov    -0x88(%rbp),%rax
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x89(%rbp)
je     12e4 <irc_protocol_tags+0x1c4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%dl
lea    0xd2b(%rip),%rax
lea    0xd25(%rip),%rcx
test   $0x1,%dl
cmovne %rcx,%rax
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1331 <irc_protocol_tags+0x211>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1331 <irc_protocol_tags+0x211>
mov    -0x28(%rbp),%rax
mov    %rax,-0xa8(%rbp)
jmp    1344 <irc_protocol_tags+0x224>
lea    0xce4(%rip),%rax
mov    %rax,-0xa8(%rbp)
jmp    1344 <irc_protocol_tags+0x224>
mov    -0xa0(%rbp),%r11
mov    -0x98(%rbp),%rbx
mov    -0x80(%rbp),%r9
mov    -0x78(%rbp),%r8
mov    -0x60(%rbp),%rcx
mov    -0xa8(%rbp),%r10
lea    -0x50(%rbp),%rax
lea    0x2cd0(%rip),%rdi
mov    $0x400,%esi
lea    0xc8b(%rip),%rdx
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2ca3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xc8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_protocol_tags>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movb   $0x0,(%rsp)
test   %rdi,%rdi
jne    114e <irc_protocol_tags+0x2e>
test   %r15,%r15
jne    114e <irc_protocol_tags+0x2e>
test   %r14,%r14
jne    114e <irc_protocol_tags+0x2e>
xor    %ebx,%ebx
jmp    121e <irc_protocol_tags+0xfe>
lea    0xec7(%rip),%r12
mov    %r12,%rcx
mov    %r12,%r8
test   %rbx,%rbx
je     11a5 <irc_protocol_tags+0x85>
cmpb   $0x0,(%rbx)
je     1189 <irc_protocol_tags+0x69>
mov    %rbx,%rdi
call   1030 <irc_protocol_log_level_for_command@plt>
test   %eax,%eax
jle    1189 <irc_protocol_tags+0x69>
lea    0xe88(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
cmpb   $0x0,(%rbx)
lea    0xe89(%rip),%rax
lea    0xe7c(%rip),%rcx
cmove  %rax,%rcx
cmove  %rax,%rbx
mov    %rbx,%r8
mov    %r12,%r9
mov    %r12,%r10
test   %r15,%r15
je     11cd <irc_protocol_tags+0xad>
cmpb   $0x0,(%r15)
lea    0xe61(%rip),%rax
lea    0xe59(%rip),%r9
cmove  %rax,%r9
cmove  %rax,%r15
mov    %r15,%r10
mov    %r12,%r11
test   %r14,%r14
je     11f2 <irc_protocol_tags+0xd2>
cmpb   $0x0,(%r14)
lea    0xe3c(%rip),%rax
lea    0xe36(%rip),%r12
cmove  %rax,%r12
cmove  %rax,%r14
mov    %r14,%r11
mov    %rsp,%r14
lea    0x2e44(%rip),%rbx
lea    0xe04(%rip),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
xor    %eax,%eax
push   %r14
push   %r11
push   %r12
push   %r10
call   1040 <snprintf@plt>
add    $0x20,%rsp
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@irc_protocol_tags.string = internal global [1024 x i8] zeroinitializer
@.str = [7 x i8] c",log%d\00"
@.str.1 = [15 x i8] c"%s%s%s%s%s%s%s\00"
@.str.2 = [5 x i8] c"irc_\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c",\00"
@.str.5 = [7 x i8] c",nick_\00"
define i8* @irc_protocol_tags(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [32 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
store i8 0, i8* %10
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %20, label %13
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %16
store i8* null, i8** %4
br label %117
20: ; preds = %16, %13, %3
%21 = load i8*, i8** %5
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %39
23: ; preds = %20
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i32 @irc_protocol_log_level_for_command(i8* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%36 = load i32, i32* %8
%37 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %35, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %34, %29
br label %39
39: ; preds = %38, %23, %20
%40 = load i8*, i8** %5
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br label %48
48: ; preds = %42, %39
%49 = phi i1 [ false, %39 ], [ %47, %42 ]
%50 = zext i1 %49 to i64
%51 = select i1 %49, 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.3, i64 0, i64 0)
%52 = load i8*, i8** %5
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %62
54: ; preds = %48
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %54
%61 = load i8*, i8** %5
br label %63
62: ; preds = %54, %48
br label %63
63: ; preds = %62, %60
%64 = phi i8* [ %61, %60 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %62 ]
%65 = load i8*, i8** %6
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %73
67: ; preds = %63
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %71, 0
br label %73
73: ; preds = %67, %63
%74 = phi i1 [ false, %63 ], [ %72, %67 ]
%75 = zext i1 %74 to i64
%76 = select i1 %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%77 = load i8*, i8** %6
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %87
79: ; preds = %73
%80 = load i8*, i8** %6
%81 = getelementptr inbounds i8, i8* %80, i64 0
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = load i8*, i8** %6
br label %88
87: ; preds = %79, %73
br label %88
88: ; preds = %87, %85
%89 = phi i8* [ %86, %85 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %87 ]
%90 = load i8*, i8** %7
%91 = icmp ne i8* %90, null
br i1 %91, label %92, label %98
92: ; preds = %88
%93 = load i8*, i8** %7
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp ne i32 %96, 0
br label %98
98: ; preds = %92, %88
%99 = phi i1 [ false, %88 ], [ %97, %92 ]
%100 = zext i1 %99 to i64
%101 = select i1 %99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%102 = load i8*, i8** %7
%103 = icmp ne i8* %102, null
br i1 %103, label %104, label %112
104: ; preds = %98
%105 = load i8*, i8** %7
%106 = getelementptr inbounds i8, i8* %105, i64 0
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %104
%111 = load i8*, i8** %7
br label %113
112: ; preds = %104, %98
br label %113
113: ; preds = %112, %110
%114 = phi i8* [ %111, %110 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %112 ]
%115 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%116 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %64, i8* %76, i8* %89, i8* %101, i8* %114, i8* %115)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i8** %4
br label %117
117: ; preds = %113, %19
%118 = load i8*, i8** %4
ret i8* %118
}

LLVM IR (-O2):
@irc_protocol_tags.string = internal global [1024 x i8] zeroinitializer
@.str = [7 x i8] c",log%d\00"
@.str.1 = [15 x i8] c"%s%s%s%s%s%s%s\00"
@.str.2 = [5 x i8] c"irc_\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c",\00"
@.str.5 = [7 x i8] c",nick_\00"
define i8* @irc_protocol_tags(i8* %0, i8* %1, i8* %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
%6 = icmp ne i8* %0, null
%7 = icmp ne i8* %1, null
%8 = or i1 %6, %7
%9 = icmp ne i8* %2, null
%10 = or i1 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %3
br i1 %6, label %12, label %25
12: ; preds = %11
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = tail call i32 @irc_protocol_log_level_for_command(i8* %0)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %20
20: ; preds = %15, %18, %12
%21 = load i8, i8* %0
%22 = icmp eq i8 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%24 = select i1 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %0
br label %25
25: ; preds = %11, %20
%26 = phi i8* [ %23, %20 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %11 ]
%27 = phi i8* [ %24, %20 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %11 ]
br i1 %7, label %28, label %33
28: ; preds = %25
%29 = load i8, i8* %1
%30 = icmp eq i8 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%32 = select i1 %30, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %1
br label %33
33: ; preds = %25, %28
%34 = phi i8* [ %31, %28 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %25 ]
%35 = phi i8* [ %32, %28 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %25 ]
br i1 %9, label %36, label %41
36: ; preds = %33
%37 = load i8, i8* %2
%38 = icmp eq i8 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%40 = select i1 %38, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %2
br label %41
41: ; preds = %33, %36
%42 = phi i8* [ %39, %36 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %33 ]
%43 = phi i8* [ %40, %36 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), %33 ]
%44 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %27, i8* %34, i8* %35, i8* %42, i8* %43, i8* %5)
br label %45
45: ; preds = %3, %41
%46 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @irc_protocol_tags.string, i64 0, i64 0), %41 ], [ null, %3 ]
ret i8* %46
}