#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*/ A_BOLD;
int /*<<< orphan*/ attrset(int /*<<< orphan*/);
int /*<<< orphan*/ color_set(int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ standend();
void set_ansi_attribute(const int attrib) {
  switch (attrib) {
  case -1:
    return;
  case 0:
    standend();
    return;
  case 1:
    attrset(A_BOLD);
    return;
  }
  if (attrib >= 30 && attrib <= 37) {
    color_set(attrib - 29, NULL);
    return;
  }
}


x86 assembly (clang, -O0):
<set_ansi_attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xffffffff,%eax
je     1170 <set_ansi_attribute+0x40>
jmp    114f <set_ansi_attribute+0x1f>
mov    -0x8(%rbp),%eax
test   %eax,%eax
je     1175 <set_ansi_attribute+0x45>
jmp    115f <set_ansi_attribute+0x2f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     1181 <set_ansi_attribute+0x51>
jmp    1194 <set_ansi_attribute+0x64>
jmp    11b7 <set_ansi_attribute+0x87>
mov    $0x0,%al
call   1030 <standend@plt>
jmp    11b7 <set_ansi_attribute+0x87>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1040 <attrset@plt>
jmp    11b7 <set_ansi_attribute+0x87>
cmpl   $0x1e,-0x4(%rbp)
jl     11b7 <set_ansi_attribute+0x87>
cmpl   $0x25,-0x4(%rbp)
jg     11b7 <set_ansi_attribute+0x87>
mov    -0x4(%rbp),%edi
sub    $0x1d,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <color_set@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ansi_attribute>:
cmp    $0xffffffff,%edi
je     1165 <set_ansi_attribute+0x35>
cmp    $0x1,%edi
je     1145 <set_ansi_attribute+0x15>
test   %edi,%edi
jne    1153 <set_ansi_attribute+0x23>
xor    %eax,%eax
jmp    1030 <standend@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
jmp    1040 <attrset@plt>
lea    -0x1e(%rdi),%eax
cmp    $0x7,%eax
ja     1165 <set_ansi_attribute+0x35>
add    $0xffffffe3,%edi
xor    %esi,%esi
jmp    1050 <color_set@plt>
ret

LLVM IR (-O0):
@A_BOLD = global i32 0
define void @set_ansi_attribute(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %10 [
i32 -1, label %4
i32 0, label %5
i32 1, label %7
]
4: ; preds = %1
br label %20
5: ; preds = %1
%6 = call i32 (...) @standend()
br label %20
7: ; preds = %1
%8 = load i32, i32* @A_BOLD
%9 = call i32 @attrset(i32 %8)
br label %20
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 30
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 37
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 29
%19 = call i32 @color_set(i32 %18, i32* null)
br label %20
20: ; preds = %4, %5, %7, %16, %13, %10
ret void
}

LLVM IR (-O2):
@A_BOLD = global i32 0
define void @set_ansi_attribute(i32 %0) {
switch i32 %0, label %7 [
i32 -1, label %13
i32 0, label %2
i32 1, label %4
]
2: ; preds = %1
%3 = tail call i32 (...) @standend()
br label %13
4: ; preds = %1
%5 = load i32, i32* @A_BOLD
%6 = tail call i32 @attrset(i32 %5)
br label %13
7: ; preds = %1
%8 = add i32 %0, -30
%9 = icmp ult i32 %8, 8
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = add nsw i32 %0, -29
%12 = tail call i32 @color_set(i32 %11, i32* null)
br label %13
13: ; preds = %1, %2, %4, %10, %7
ret void
}