#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 A_BOLD;
int A_REVERSE;
int A_STANDOUT;
int A_UNDERLINE;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
const char *attrs_to_str(int attrs) {
  static char result[64];
  result[0] = '\0';
  if (attrs == 0)
    strcpy(result, "none,");
  if ((attrs & A_BOLD) == A_BOLD)
    strcat(result, "bold,");
  if ((attrs & A_UNDERLINE) == A_UNDERLINE)
    strcat(result, "underline,");
  if ((attrs & A_REVERSE) == A_REVERSE)
    strcat(result, "reverse,");
  if ((attrs & A_STANDOUT) == A_STANDOUT)
    strcat(result, "standout,");
  if (result[0] != '\0')
    result[strlen(result) - 1] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<attrs_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f0e(%rip)
cmpl   $0x0,-0x4(%rbp)
jne    115f <attrs_to_str+0x2f>
lea    0x2efd(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    0x2e67(%rip),%rcx
and    (%rcx),%eax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%eax
jne    118d <attrs_to_str+0x5d>
lea    0x2ecf(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    0x2e31(%rip),%rcx
and    (%rcx),%eax
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%eax
jne    11bb <attrs_to_str+0x8b>
lea    0x2ea1(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    0x2e1b(%rip),%rcx
and    (%rcx),%eax
mov    0x2e12(%rip),%rcx
cmp    (%rcx),%eax
jne    11e9 <attrs_to_str+0xb9>
lea    0x2e73(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    0x2de5(%rip),%rcx
and    (%rcx),%eax
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%eax
jne    1217 <attrs_to_str+0xe7>
lea    0x2e45(%rip),%rdi
lea    0xe0e(%rip),%rsi
call   1050 <strcat@plt>
movsbl 0x2e32(%rip),%eax
cmp    $0x0,%eax
je     1244 <attrs_to_str+0x114>
lea    0x2e22(%rip),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2e10(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e05(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attrs_to_str>:
push   %rbx
mov    %edi,%ebx
movb   $0x0,0x2f16(%rip)
test   %edi,%edi
jne    1151 <attrs_to_str+0x21>
lea    0x2f0b(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2e78(%rip),%rax
not    %ebx
test   %ebx,(%rax)
jne    1171 <attrs_to_str+0x41>
lea    0x2eeb(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1050 <strcat@plt>
mov    0x2e50(%rip),%rax
test   %ebx,(%rax)
jne    118f <attrs_to_str+0x5f>
lea    0x2ecd(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1050 <strcat@plt>
mov    0x2e4a(%rip),%rax
test   %ebx,(%rax)
jne    11ad <attrs_to_str+0x7d>
lea    0x2eaf(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <strcat@plt>
mov    0x2e24(%rip),%rax
test   %ebx,(%rax)
jne    11cb <attrs_to_str+0x9b>
lea    0x2e91(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strcat@plt>
cmpb   $0x0,0x2e7e(%rip)
je     11ea <attrs_to_str+0xba>
lea    0x2e75(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x2e5f(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@attrs_to_str.result = internal global [64 x i8] zeroinitializer
@.str = [6 x i8] c"none,\00"
@A_BOLD = global i32 0
@.str.1 = [6 x i8] c"bold,\00"
@A_UNDERLINE = global i32 0
@.str.2 = [11 x i8] c"underline,\00"
@A_REVERSE = global i32 0
@.str.3 = [9 x i8] c"reverse,\00"
@A_STANDOUT = global i32 0
@.str.4 = [10 x i8] c"standout,\00"
define i8* @attrs_to_str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* %2
%9 = load i32, i32* @A_BOLD
%10 = and i32 %8, %9
%11 = load i32, i32* @A_BOLD
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%16 = load i32, i32* %2
%17 = load i32, i32* @A_UNDERLINE
%18 = and i32 %16, %17
%19 = load i32, i32* @A_UNDERLINE
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %15
%24 = load i32, i32* %2
%25 = load i32, i32* @A_REVERSE
%26 = and i32 %24, %25
%27 = load i32, i32* @A_REVERSE
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %23
%32 = load i32, i32* %2
%33 = load i32, i32* @A_STANDOUT
%34 = and i32 %32, %33
%35 = load i32, i32* @A_STANDOUT
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %31
%40 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = call i32 @strlen(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0))
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 %46
store i8 0, i8* %47
br label %48
48: ; preds = %43, %39
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
}

LLVM IR (-O2):
@attrs_to_str.result = internal global [64 x i8] zeroinitializer
@.str = [6 x i8] c"none,\00"
@A_BOLD = global i32 0
@.str.1 = [6 x i8] c"bold,\00"
@A_UNDERLINE = global i32 0
@.str.2 = [11 x i8] c"underline,\00"
@A_REVERSE = global i32 0
@.str.3 = [9 x i8] c"reverse,\00"
@A_STANDOUT = global i32 0
@.str.4 = [10 x i8] c"standout,\00"
define i8* @attrs_to_str(i32 %0) {
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %1
%6 = load i32, i32* @A_BOLD
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, %6
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = load i32, i32* @A_UNDERLINE
%13 = and i32 %12, %0
%14 = icmp eq i32 %13, %12
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = load i32, i32* @A_REVERSE
%19 = and i32 %18, %0
%20 = icmp eq i32 %19, %18
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* @A_STANDOUT
%25 = and i32 %24, %0
%26 = icmp eq i32 %25, %24
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = tail call i32 @strcat(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = load i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
%31 = icmp eq i8 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call i32 @strlen(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0))
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 %35
store i8 0, i8* %36
br label %37
37: ; preds = %32, %29
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @attrs_to_str.result, i64 0, i64 0)
}