#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, char *, char *);
int strlen(char *);
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, char);
int /*<<< orphan*/ wattroff(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wattron(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void print_bar(WINDOW *win, char *str, int width, int color) {
  int length = strlen(str);
  int i;
  wattron(win, COLOR_PAIR(color));
  mvwprintw(win, 0, 0, "%s", str);
  for (i = length; i < width; i++)
    waddch(win, ' ');
  wrefresh(win);
  wattroff(win, COLOR_PAIR(color));
}


x86 assembly (clang, -O0):
<print_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <COLOR_PAIR@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1090 <wattron@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%r8
xor    %edx,%edx
lea    0xe42(%rip),%rcx
mov    %edx,%esi
call   1070 <mvwprintw@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f3 <print_bar+0x83>
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <waddch@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cb <print_bar+0x5b>
mov    -0x8(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <COLOR_PAIR@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1080 <wattroff@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14d,%edi
call   1060 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <wattron@plt>
lea    0xe59(%rip),%rcx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r12,%r8
call   1070 <mvwprintw@plt>
cmp    %ebp,%r15d
jge    11d2 <print_bar+0x62>
sub    %r15d,%ebp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <waddch@plt>
add    $0xffffffff,%ebp
jne    11c0 <print_bar+0x50>
mov    %rbx,%rdi
call   1050 <wrefresh@plt>
mov    %r14d,%edi
call   1060 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <wattroff@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @print_bar(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %9
%13 = load i32*, i32** %5
%14 = load i32, i32* %8
%15 = call i32 @COLOR_PAIR(i32 %14)
%16 = call i32 @wattron(i32* %13, i32 %15)
%17 = load i32*, i32** %5
%18 = load i8*, i8** %6
%19 = call i32 @mvwprintw(i32* %17, i32 0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %9
store i32 %20, i32* %10
br label %21
21: ; preds = %28, %4
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = call i32 @waddch(i32* %26, i8 signext 32)
br label %28
28: ; preds = %25
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %21
31: ; preds = %21
%32 = load i32*, i32** %5
%33 = call i32 @wrefresh(i32* %32)
%34 = load i32*, i32** %5
%35 = load i32, i32* %8
%36 = call i32 @COLOR_PAIR(i32 %35)
%37 = call i32 @wattroff(i32* %34, i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @print_bar(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 @COLOR_PAIR(i32 %3)
%7 = tail call i32 @wattron(i32* %0, i32 %6)
%8 = tail call i32 @mvwprintw(i32* %0, i32 0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = icmp slt i32 %5, %2
br i1 %9, label %10, label %15
10: ; preds = %4, %10
%11 = phi i32 [ %13, %10 ], [ %5, %4 ]
%12 = tail call i32 @waddch(i32* %0, i8 signext 32)
%13 = add i32 %11, 1
%14 = icmp eq i32 %13, %2
br i1 %14, label %15, label %10
15: ; preds = %10, %4
%16 = tail call i32 @wrefresh(i32* %0)
%17 = tail call i32 @COLOR_PAIR(i32 %3)
%18 = tail call i32 @wattroff(i32* %0, i32 %17)
ret void
}