#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*/ libirc_colorparser_applymask(unsigned int *, char **,
                                                unsigned int *, int,
                                                int /*<<< orphan*/, char *);
void libirc_colorparser_closetags(unsigned int *mask, char **destline,
                                  unsigned int *destlen) {
  if (*mask & (1 << 1))
    libirc_colorparser_applymask(mask, destline, destlen, (1 << 1), 0, "[/B]");
  if (*mask & (1 << 2))
    libirc_colorparser_applymask(mask, destline, destlen, (1 << 2), 0, "[/U]");
  if (*mask & (1 << 3))
    libirc_colorparser_applymask(mask, destline, destlen, (1 << 3), 0, "[/I]");
  if (*mask & (1 << 4))
    libirc_colorparser_applymask(mask, destline, destlen, (1 << 4), 0,
                                 "[/COLOR]");
}


x86 assembly (clang, -O0):
<libirc_colorparser_closetags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1156 <libirc_colorparser_closetags+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
lea    0xeaf(%rip),%r9
call   1030 <libirc_colorparser_applymask@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1188 <libirc_colorparser_closetags+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x4,%ecx
xor    %r8d,%r8d
lea    0xe82(%rip),%r9
call   1030 <libirc_colorparser_applymask@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ba <libirc_colorparser_closetags+0xaa>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x8,%ecx
xor    %r8d,%r8d
lea    0xe55(%rip),%r9
call   1030 <libirc_colorparser_applymask@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11ec <libirc_colorparser_closetags+0xdc>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x10,%ecx
xor    %r8d,%r8d
lea    0xe28(%rip),%r9
call   1030 <libirc_colorparser_applymask@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libirc_colorparser_closetags>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%eax
test   $0x2,%al
jne    1136 <libirc_colorparser_closetags+0x26>
test   $0x4,%al
jne    1159 <libirc_colorparser_closetags+0x49>
test   $0x8,%al
jne    117c <libirc_colorparser_closetags+0x6c>
test   $0x10,%al
jne    119f <libirc_colorparser_closetags+0x8f>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xec3(%rip),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x2,%ecx
xor    %r8d,%r8d
call   1030 <libirc_colorparser_applymask@plt>
mov    (%rbx),%eax
test   $0x4,%al
je     1128 <libirc_colorparser_closetags+0x18>
lea    0xea5(%rip),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x4,%ecx
xor    %r8d,%r8d
call   1030 <libirc_colorparser_applymask@plt>
mov    (%rbx),%eax
test   $0x8,%al
je     112c <libirc_colorparser_closetags+0x1c>
lea    0xe87(%rip),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x8,%ecx
xor    %r8d,%r8d
call   1030 <libirc_colorparser_applymask@plt>
mov    (%rbx),%eax
test   $0x10,%al
je     1130 <libirc_colorparser_closetags+0x20>
lea    0xe69(%rip),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x10,%ecx
xor    %r8d,%r8d
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <libirc_colorparser_applymask@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"[/B]\00"
@.str.1 = [5 x i8] c"[/U]\00"
@.str.2 = [5 x i8] c"[/I]\00"
@.str.3 = [9 x i8] c"[/COLOR]\00"
define void @libirc_colorparser_closetags(i32* %0, i8** %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32*
store i32* %0, i32** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = and i32 %8, 2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i32*, i32** %4
%13 = load i8**, i8*** %5
%14 = load i32*, i32** %6
%15 = call i32 @libirc_colorparser_applymask(i32* %12, i8** %13, i32* %14, i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %11, %3
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = and i32 %18, 4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = load i8**, i8*** %5
%24 = load i32*, i32** %6
%25 = call i32 @libirc_colorparser_applymask(i32* %22, i8** %23, i32* %24, i32 4, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %21, %16
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = and i32 %28, 8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load i32*, i32** %4
%33 = load i8**, i8*** %5
%34 = load i32*, i32** %6
%35 = call i32 @libirc_colorparser_applymask(i32* %32, i8** %33, i32* %34, i32 8, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %31, %26
%37 = load i32*, i32** %4
%38 = load i32, i32* %37
%39 = and i32 %38, 16
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32*, i32** %4
%43 = load i8**, i8*** %5
%44 = load i32*, i32** %6
%45 = call i32 @libirc_colorparser_applymask(i32* %42, i8** %43, i32* %44, i32 16, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %41, %36
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"[/B]\00"
@.str.1 = [5 x i8] c"[/U]\00"
@.str.2 = [5 x i8] c"[/I]\00"
@.str.3 = [9 x i8] c"[/COLOR]\00"
define void @libirc_colorparser_closetags(i32* %0, i8** %1, i32* %2) {
%4 = load i32, i32* %0
%5 = and i32 %4, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @libirc_colorparser_applymask(i32* %0, i8** %1, i32* %2, i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %0
br label %10
10: ; preds = %7, %3
%11 = phi i32 [ %9, %7 ], [ %4, %3 ]
%12 = and i32 %11, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = tail call i32 @libirc_colorparser_applymask(i32* %0, i8** %1, i32* %2, i32 4, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %0
br label %17
17: ; preds = %14, %10
%18 = phi i32 [ %16, %14 ], [ %11, %10 ]
%19 = and i32 %18, 8
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = tail call i32 @libirc_colorparser_applymask(i32* %0, i8** %1, i32* %2, i32 8, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %0
br label %24
24: ; preds = %21, %17
%25 = phi i32 [ %23, %21 ], [ %18, %17 ]
%26 = and i32 %25, 16
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = tail call i32 @libirc_colorparser_applymask(i32* %0, i8** %1, i32* %2, i32 16, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
ret void
}