#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) {
  static char string[512];
  int log_level;
  char str_log_level[32];
  log_level = 0;
  str_log_level[0] = '\0';
  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);
    }
  }
  if (command && command[0] && tags && tags[0]) {
    snprintf(string, sizeof(string), "irc_%s,%s%s", command, tags,
             str_log_level);
    return string;
  }
  if (command && command[0]) {
    snprintf(string, sizeof(string), "irc_%s%s", command, str_log_level);
    return string;
  }
  if (tags && tags[0]) {
    snprintf(string, sizeof(string), "%s", tags);
    return string;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<irc_protocol_tags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118b <irc_protocol_tags+0x6b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118b <irc_protocol_tags+0x6b>
mov    -0x10(%rbp),%rdi
call   1030 <irc_protocol_log_level_for_command@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1186 <irc_protocol_tags+0x66>
lea    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%ecx
mov    $0x20,%esi
lea    0xe81(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    118b <irc_protocol_tags+0x6b>
cmpq   $0x0,-0x10(%rbp)
je     11f7 <irc_protocol_tags+0xd7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f7 <irc_protocol_tags+0xd7>
cmpq   $0x0,-0x18(%rbp)
je     11f7 <irc_protocol_tags+0xd7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f7 <irc_protocol_tags+0xd7>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    0x2e6c(%rip),%rdi
mov    $0x200,%esi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2e52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1295 <irc_protocol_tags+0x175>
cmpq   $0x0,-0x10(%rbp)
je     1244 <irc_protocol_tags+0x124>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1244 <irc_protocol_tags+0x124>
mov    -0x10(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    0x2e1f(%rip),%rdi
mov    $0x200,%esi
lea    0xde6(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2e05(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1295 <irc_protocol_tags+0x175>
cmpq   $0x0,-0x18(%rbp)
je     128d <irc_protocol_tags+0x16d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     128d <irc_protocol_tags+0x16d>
mov    -0x18(%rbp),%rcx
lea    0x2dd6(%rip),%rdi
mov    $0x200,%esi
lea    0xd9a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2dbc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1295 <irc_protocol_tags+0x175>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_protocol_tags>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
movb   $0x0,(%rsp)
test   %rdi,%rdi
je     11cb <irc_protocol_tags+0xab>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11cb <irc_protocol_tags+0xab>
mov    %rbx,%rdi
call   1030 <irc_protocol_log_level_for_command@plt>
test   %eax,%eax
jle    1169 <irc_protocol_tags+0x49>
lea    0xea8(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rbx),%al
test   %r14,%r14
je     11a2 <irc_protocol_tags+0x82>
test   %al,%al
je     11a2 <irc_protocol_tags+0x82>
cmpb   $0x0,(%r14)
je     11a6 <irc_protocol_tags+0x86>
lea    0x2ebf(%rip),%r15
lea    0xe7f(%rip),%rdx
mov    %rsp,%r9
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11fb <irc_protocol_tags+0xdb>
test   %al,%al
je     11cb <irc_protocol_tags+0xab>
lea    0x2e93(%rip),%r15
lea    0xe5f(%rip),%rdx
mov    %rsp,%r8
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11fb <irc_protocol_tags+0xdb>
test   %r14,%r14
je     11f8 <irc_protocol_tags+0xd8>
cmpb   $0x0,(%r14)
je     11f8 <irc_protocol_tags+0xd8>
lea    0x2e63(%rip),%r15
lea    0xe2c(%rip),%rdx
mov    %r15,%rdi
mov    $0x200,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11fb <irc_protocol_tags+0xdb>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@irc_protocol_tags.string = internal global [512 x i8] zeroinitializer
@.str = [7 x i8] c",log%d\00"
@.str.1 = [12 x i8] c"irc_%s,%s%s\00"
@.str.2 = [9 x i8] c"irc_%s%s\00"
@.str.3 = [3 x i8] c"%s\00"
define i8* @irc_protocol_tags(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [32 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
store i8 0, i8* %8
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %27
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i32 @irc_protocol_log_level_for_command(i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* %6
%25 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %23, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %17
br label %27
27: ; preds = %26, %11, %2
%28 = load i8*, i8** %4
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %30
%37 = load i8*, i8** %5
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %39
%46 = load i8*, i8** %4
%47 = load i8*, i8** %5
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%49 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i32 512, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* %47, i8* %48)
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i8** %3
br label %76
50: ; preds = %39, %36, %30, %27
%51 = load i8*, i8** %4
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %53
%60 = load i8*, i8** %4
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%62 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i32 512, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %60, i8* %61)
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i8** %3
br label %76
63: ; preds = %53, %50
%64 = load i8*, i8** %5
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %75
66: ; preds = %63
%67 = load i8*, i8** %5
%68 = getelementptr inbounds i8, i8* %67, i64 0
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %66
%73 = load i8*, i8** %5
%74 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i32 512, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %73)
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @irc_protocol_tags.string, i64 0, i64 0), i8** %3
br label %76
75: ; preds = %66, %63
store i8* null, i8** %3
br label %76
76: ; preds = %75, %72, %59, %45
%77 = load i8*, i8** %3
ret i8* %77
}

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