#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*/ string_dyn_concat(char **, char *, int);
void gui_color_add_ansi_flag(char **output, int flag) {
  switch (flag) {
  case 0x0200000:
    string_dyn_concat(output, "\x1B[1m", -1);
    break;
  case 0x0400000:
    string_dyn_concat(output, "\x1B[7m", -1);
    break;
  case 0x0800000:
    string_dyn_concat(output, "\x1B[3m", -1);
    break;
  case 0x1000000:
    string_dyn_concat(output, "\x1B[4m", -1);
    break;
  case 0x2000000:
    break;
  }
}


x86 assembly (clang, -O0):
<gui_color_add_ansi_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x200000,%eax
je     1181 <gui_color_add_ansi_flag+0x71>
jmp    1135 <gui_color_add_ansi_flag+0x25>
mov    -0x10(%rbp),%eax
sub    $0x400000,%eax
je     119b <gui_color_add_ansi_flag+0x8b>
jmp    1148 <gui_color_add_ansi_flag+0x38>
mov    -0x10(%rbp),%eax
sub    $0x800000,%eax
je     11b5 <gui_color_add_ansi_flag+0xa5>
jmp    115b <gui_color_add_ansi_flag+0x4b>
mov    -0x10(%rbp),%eax
sub    $0x1000000,%eax
je     11cf <gui_color_add_ansi_flag+0xbf>
jmp    116e <gui_color_add_ansi_flag+0x5e>
mov    -0x10(%rbp),%eax
sub    $0x2000000,%eax
je     11e9 <gui_color_add_ansi_flag+0xd9>
jmp    11ee <gui_color_add_ansi_flag+0xde>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0xffffffff,%edx
call   1030 <string_dyn_concat@plt>
jmp    11ee <gui_color_add_ansi_flag+0xde>
mov    -0x8(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0xffffffff,%edx
call   1030 <string_dyn_concat@plt>
jmp    11ee <gui_color_add_ansi_flag+0xde>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0xffffffff,%edx
call   1030 <string_dyn_concat@plt>
jmp    11ee <gui_color_add_ansi_flag+0xde>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0xffffffff,%edx
call   1030 <string_dyn_concat@plt>
jmp    11ee <gui_color_add_ansi_flag+0xde>
jmp    11ee <gui_color_add_ansi_flag+0xde>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_color_add_ansi_flag>:
add    $0xffe00000,%esi
rol    $0xb,%esi
cmp    $0x7,%esi
ja     1128 <gui_color_add_ansi_flag+0x18>
mov    $0x8b,%eax
bt     %esi,%eax
jb     1129 <gui_color_add_ansi_flag+0x19>
ret
movslq %esi,%rax
lea    0xee1(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    $0xffffffff,%edx
jmp    1030 <string_dyn_concat@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\1B[1m\00"
@.str.1 = [5 x i8] c"\1B[7m\00"
@.str.2 = [5 x i8] c"\1B[3m\00"
@.str.3 = [5 x i8] c"\1B[4m\00"
define void @gui_color_add_ansi_flag(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %19 [
i32 2097152, label %6
i32 4194304, label %9
i32 8388608, label %12
i32 16777216, label %15
i32 33554432, label %18
]
6: ; preds = %2
%7 = load i8**, i8*** %3
%8 = call i32 @string_dyn_concat(i8** %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 -1)
br label %19
9: ; preds = %2
%10 = load i8**, i8*** %3
%11 = call i32 @string_dyn_concat(i8** %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 -1)
br label %19
12: ; preds = %2
%13 = load i8**, i8*** %3
%14 = call i32 @string_dyn_concat(i8** %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 -1)
br label %19
15: ; preds = %2
%16 = load i8**, i8*** %3
%17 = call i32 @string_dyn_concat(i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 -1)
br label %19
18: ; preds = %2
br label %19
19: ; preds = %2, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\1B[1m\00"
@.str.1 = [5 x i8] c"\1B[7m\00"
@.str.2 = [5 x i8] c"\1B[3m\00"
@.str.3 = [5 x i8] c"\1B[4m\00"
@reltable.gui_color_add_ansi_flag = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.gui_color_add_ansi_flag to i64)) to i32)]
define void @gui_color_add_ansi_flag(i8** %0, i32 %1) {
%3 = add i32 %1, -2097152
%4 = tail call i32 @llvm.fshl.i32(i32 %3, i32 %3, i32 11)
%5 = icmp ult i32 %4, 8
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = trunc i32 %4 to i8
%8 = lshr i8 -117, %7
%9 = and i8 %8, 1
%10 = icmp eq i8 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = sext i32 %4 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.gui_color_add_ansi_flag to i8*), i64 %13)
%15 = tail call i32 @string_dyn_concat(i8** %0, i8* %14, i32 -1)
br label %16
16: ; preds = %6, %2, %11
ret void
}