#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*/ COLOR_PAIR(short);
short COLOR_PAIRS;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ mvaddstr(int, int, char const *);
int /*<<< orphan*/ pair_content(short, short *, short *);
void color_str(int y, int x, short fg_color, short bg_color, const char *str) {
  short i;
  for (i = 1; i < COLOR_PAIRS; i++) {
    short f, b;
    pair_content(i, &f, &b);
    if (f == fg_color && b == bg_color)
      break;
  }
  attron(COLOR_PAIR(i));
  mvaddstr(y, x, str);
  attroff(COLOR_PAIR(i));
}


x86 assembly (clang, -O0):
<color_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %cx,-0xa(%rbp)
mov    %ax,-0xc(%rbp)
mov    %r8,-0x18(%rbp)
movw   $0x1,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
mov    0x2e67(%rip),%rcx
movswl (%rcx),%ecx
cmp    %ecx,%eax
jge    11d8 <color_str+0x88>
lea    -0x1c(%rbp),%rsi
lea    -0x1e(%rbp),%rdx
movswl -0x1a(%rbp),%edi
call   1050 <pair_content@plt>
movswl -0x1c(%rbp),%eax
movswl -0xa(%rbp),%ecx
cmp    %ecx,%eax
jne    11c2 <color_str+0x72>
movswl -0x1e(%rbp),%eax
movswl -0xc(%rbp),%ecx
cmp    %ecx,%eax
jne    11c2 <color_str+0x72>
jmp    11d8 <color_str+0x88>
jmp    11c7 <color_str+0x77>
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    1176 <color_str+0x26>
movswl -0x1a(%rbp),%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1070 <mvaddstr@plt>
movswl -0x1a(%rbp),%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %edi,0x8(%rsp)
mov    0x2e76(%rip),%r12
mov    $0x1,%r15w
cmpw   $0x2,(%r12)
jl     11c9 <color_str+0x79>
mov    %ecx,%r13d
mov    %edx,%ebx
mov    $0x1,%r15w
lea    0x6(%rsp),%rbp
lea    0x4(%rsp),%r14
jmp    11ab <color_str+0x5b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15d
cmp    (%r12),%r15w
jge    11c9 <color_str+0x79>
movswl %r15w,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1050 <pair_content@plt>
cmp    %bx,0x6(%rsp)
jne    11a0 <color_str+0x50>
cmp    %r13w,0x4(%rsp)
jne    11a0 <color_str+0x50>
movswl %r15w,%ebx
mov    %ebx,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1040 <attron@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdx
call   1070 <mvaddstr@plt>
mov    %ebx,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLOR_PAIRS = global i16 0
define void @color_str(i32 %0, i32 %1, i16 signext %2, i16 signext %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i16
%9 = alloca i16
%10 = alloca i8*
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
store i32 %0, i32* %6
store i32 %1, i32* %7
store i16 %2, i16* %8
store i16 %3, i16* %9
store i8* %4, i8** %10
store i16 1, i16* %11
br label %14
14: ; preds = %36, %5
%15 = load i16, i16* %11
%16 = sext i16 %15 to i32
%17 = load i16, i16* @COLOR_PAIRS
%18 = sext i16 %17 to i32
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %39
20: ; preds = %14
%21 = load i16, i16* %11
%22 = call i32 @pair_content(i16 signext %21, i16* %12, i16* %13)
%23 = load i16, i16* %12
%24 = sext i16 %23 to i32
%25 = load i16, i16* %8
%26 = sext i16 %25 to i32
%27 = icmp eq i32 %24, %26
br i1 %27, label %28, label %35
28: ; preds = %20
%29 = load i16, i16* %13
%30 = sext i16 %29 to i32
%31 = load i16, i16* %9
%32 = sext i16 %31 to i32
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %35
34: ; preds = %28
br label %39
35: ; preds = %28, %20
br label %36
36: ; preds = %35
%37 = load i16, i16* %11
%38 = add i16 %37, 1
store i16 %38, i16* %11
br label %14
39: ; preds = %34, %14
%40 = load i16, i16* %11
%41 = call i32 @COLOR_PAIR(i16 signext %40)
%42 = call i32 @attron(i32 %41)
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = load i8*, i8** %10
%46 = call i32 @mvaddstr(i32 %43, i32 %44, i8* %45)
%47 = load i16, i16* %11
%48 = call i32 @COLOR_PAIR(i16 signext %47)
%49 = call i32 @attroff(i32 %48)
ret void
}

LLVM IR (-O2):
@COLOR_PAIRS = global i16 0
define void @color_str(i32 %0, i32 %1, i16 signext %2, i16 signext %3, i8* %4) {
%6 = alloca i16
%7 = alloca i16
%8 = load i16, i16* @COLOR_PAIRS
%9 = icmp sgt i16 %8, 1
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = bitcast i16* %6 to i8*
%12 = bitcast i16* %7 to i8*
br label %13
13: ; preds = %10, %21
%14 = phi i16 [ 1, %10 ], [ %22, %21 ]
%15 = call i32 @pair_content(i16 signext %14, i16* %6, i16* %7)
%16 = load i16, i16* %6
%17 = icmp eq i16 %16, %2
%18 = load i16, i16* %7
%19 = icmp eq i16 %18, %3
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %25, label %21
21: ; preds = %13
%22 = add nuw nsw i16 %14, 1
%23 = load i16, i16* @COLOR_PAIRS
%24 = icmp slt i16 %22, %23
br i1 %24, label %13, label %25
25: ; preds = %21, %13, %5
%26 = phi i16 [ 1, %5 ], [ %14, %13 ], [ %22, %21 ]
%27 = call i32 @COLOR_PAIR(i16 signext %26)
%28 = call i32 @attron(i32 %27)
%29 = call i32 @mvaddstr(i32 %0, i32 %1, i8* %4)
%30 = call i32 @COLOR_PAIR(i16 signext %26)
%31 = call i32 @attroff(i32 %30)
ret void
}