#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*/ print(int, char *, int);
int greyscale(int tty, int fg, int bg) {
  if (fg > -1 && fg < 24)
    print(tty, "\033[38;5;%dm", fg + 232);
  if (bg > -1 && bg < 24)
    print(tty, "\033[48;5;%dm", bg + 232);
  return 0;
}


x86 assembly (clang, -O0):
<greyscale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jle    114d <greyscale+0x3d>
cmpl   $0x18,-0x8(%rbp)
jge    114d <greyscale+0x3d>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
add    $0xe8,%edx
lea    0xeb8(%rip),%rsi
call   1030 <print@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jle    1179 <greyscale+0x69>
cmpl   $0x18,-0xc(%rbp)
jge    1179 <greyscale+0x69>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%edx
add    $0xe8,%edx
lea    0xe97(%rip),%rsi
call   1030 <print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greyscale>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %edi,%ebp
cmp    $0x17,%esi
ja     1132 <greyscale+0x22>
mov    %esi,%edx
add    $0xe8,%edx
lea    0xed5(%rip),%rsi
mov    %ebp,%edi
call   1030 <print@plt>
cmp    $0x17,%ebx
ja     114d <greyscale+0x3d>
add    $0xe8,%ebx
lea    0xec7(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
call   1030 <print@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\1B[38;5;%dm\00"
@.str.1 = [11 x i8] c"\1B[48;5;%dm\00"
define i32 @greyscale(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 24
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 232
%16 = call i32 @print(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12, %9, %3
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 24
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 232
%27 = call i32 @print(i32 %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %23, %20, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"\1B[38;5;%dm\00"
@.str.1 = [11 x i8] c"\1B[48;5;%dm\00"
define i32 @greyscale(i32 %0, i32 %1, i32 %2) {
%4 = icmp ult i32 %1, 24
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = add nuw nsw i32 %1, 232
%7 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %5, %3
%9 = icmp ult i32 %2, 24
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = add nuw nsw i32 %2, 232
%12 = tail call i32 @print(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %8
ret i32 0
}