#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_addorcat(char **, unsigned int *,
                                               char const *);
void libirc_colorparser_applymask(unsigned int *mask, char **destline,
                                  unsigned int *destlen, unsigned int bitmask,
                                  const char *start, const char *end) {
  if ((*mask & bitmask) != 0) {
    *mask &= ~bitmask;
    libirc_colorparser_addorcat(destline, destlen, end);
  } else {
    *mask |= bitmask;
    libirc_colorparser_addorcat(destline, destlen, start);
  }
}


x86 assembly (clang, -O0):
<libirc_colorparser_applymask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    -0x1c(%rbp),%eax
cmp    $0x0,%eax
je     1165 <libirc_colorparser_applymask+0x55>
mov    -0x1c(%rbp),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <libirc_colorparser_addorcat@plt>
jmp    1181 <libirc_colorparser_applymask+0x71>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <libirc_colorparser_addorcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libirc_colorparser_applymask>:
mov    (%rdi),%r11d
mov    %r11d,%r10d
or     %ecx,%r10d
mov    %ecx,%eax
not    %eax
and    %r11d,%eax
test   %ecx,%r11d
cmove  %r10d,%eax
cmovne %r9,%r8
mov    %eax,(%rdi)
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %r8,%rdx
jmp    1030 <libirc_colorparser_addorcat@plt>

LLVM IR (-O0):
define void @libirc_colorparser_applymask(i32* %0, i8** %1, i32* %2, i32 %3, i8* %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%13 = load i32*, i32** %7
%14 = load i32, i32* %13
%15 = load i32, i32* %10
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %6
%19 = load i32, i32* %10
%20 = xor i32 %19, -1
%21 = load i32*, i32** %7
%22 = load i32, i32* %21
%23 = and i32 %22, %20
store i32 %23, i32* %21
%24 = load i8**, i8*** %8
%25 = load i32*, i32** %9
%26 = load i8*, i8** %12
%27 = call i32 @libirc_colorparser_addorcat(i8** %24, i32* %25, i8* %26)
br label %37
28: ; preds = %6
%29 = load i32, i32* %10
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = or i32 %31, %29
store i32 %32, i32* %30
%33 = load i8**, i8*** %8
%34 = load i32*, i32** %9
%35 = load i8*, i8** %11
%36 = call i32 @libirc_colorparser_addorcat(i8** %33, i32* %34, i8* %35)
br label %37
37: ; preds = %28, %18
ret void
}

LLVM IR (-O2):
define void @libirc_colorparser_applymask(i32* nocapture %0, i8** %1, i32* %2, i32 %3, i8* %4, i8* %5) {
%7 = load i32, i32* %0
%8 = and i32 %7, %3
%9 = icmp eq i32 %8, 0
%10 = or i32 %7, %3
%11 = xor i32 %3, -1
%12 = and i32 %7, %11
%13 = select i1 %9, i32 %10, i32 %12
%14 = select i1 %9, i8* %4, i8* %5
store i32 %13, i32* %0
%15 = tail call i32 @libirc_colorparser_addorcat(i8** %1, i32* %2, i8* %14)
ret void
}