#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*/ clearScreen();
int /*<<< orphan*/ interrupt(int, int, int, int /*<<< orphan*/, int);
void changeFGcolor(char f, char b) {
  unsigned int fgColor, bgColor, finalVal;
  clearScreen();
  if (f < 0x61) {
    fgColor = f - '0';
  } else if (f < 0x61) {
    fgColor = f - 0x41 + 10;
  } else {
    fgColor = f - 0x61 + 10;
  }
  if (b < 0x41) {
    bgColor = b - '0';
  } else if (b < 0x61) {
    bgColor = b - 0x41 + 10;
  } else {
    bgColor = b - 0x61 + 10;
  }
  finalVal = (bgColor << 4) + fgColor;
  interrupt(0x10, 0x6 * 256, 256 * finalVal, 0, 256 * 25 + 80);
}


x86 assembly (clang, -O0):
<changeFGcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    $0x0,%al
call   1040 <clearScreen@plt>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jge    1157 <changeFGcolor+0x37>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <changeFGcolor+0x68>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jge    1176 <changeFGcolor+0x56>
movsbl -0x1(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1183 <changeFGcolor+0x63>
movsbl -0x1(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <changeFGcolor+0x68>
movsbl -0x2(%rbp),%eax
cmp    $0x41,%eax
jge    11a4 <changeFGcolor+0x84>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    11d5 <changeFGcolor+0xb5>
movsbl -0x2(%rbp),%eax
cmp    $0x61,%eax
jge    11c3 <changeFGcolor+0xa3>
movsbl -0x2(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    11d0 <changeFGcolor+0xb0>
movsbl -0x2(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    11d5 <changeFGcolor+0xb5>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
shl    $0x8,%edx
mov    $0x10,%edi
mov    $0x600,%esi
xor    %ecx,%ecx
mov    $0x1950,%r8d
call   1030 <interrupt@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeFGcolor>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
xor    %eax,%eax
call   1040 <clearScreen@plt>
xor    %eax,%eax
cmp    $0x61,%bl
setb   %al
shl    $0x5,%eax
add    $0xffffffa9,%eax
cmp    $0x41,%bl
mov    $0xffffffd0,%edx
cmovge %eax,%edx
add    %ebx,%edx
lea    -0x57(%r14),%eax
mov    %r14d,%ecx
add    $0xffffffd0,%ecx
cmp    $0x61,%r14b
cmovge %eax,%ecx
shl    $0x4,%edx
add    %ecx,%edx
shl    $0x8,%edx
mov    $0x10,%edi
mov    $0x600,%esi
xor    %ecx,%ecx
mov    $0x1950,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <interrupt@plt>

LLVM IR (-O0):
define void @changeFGcolor(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%8 = call i32 (...) @clearScreen()
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp slt i32 %10, 97
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = sub nsw i32 %14, 48
store i32 %15, i32* %5
br label %31
16: ; preds = %2
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp slt i32 %18, 97
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 65
%24 = add nsw i32 %23, 10
store i32 %24, i32* %5
br label %30
25: ; preds = %16
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 97
%29 = add nsw i32 %28, 10
store i32 %29, i32* %5
br label %30
30: ; preds = %25, %20
br label %31
31: ; preds = %30, %12
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp slt i32 %33, 65
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
store i32 %38, i32* %6
br label %54
39: ; preds = %31
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = icmp slt i32 %41, 97
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load i8, i8* %4
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %45, 65
%47 = add nsw i32 %46, 10
store i32 %47, i32* %6
br label %53
48: ; preds = %39
%49 = load i8, i8* %4
%50 = sext i8 %49 to i32
%51 = sub nsw i32 %50, 97
%52 = add nsw i32 %51, 10
store i32 %52, i32* %6
br label %53
53: ; preds = %48, %43
br label %54
54: ; preds = %53, %35
%55 = load i32, i32* %6
%56 = shl i32 %55, 4
%57 = load i32, i32* %5
%58 = add i32 %56, %57
store i32 %58, i32* %7
%59 = load i32, i32* %7
%60 = mul i32 256, %59
%61 = call i32 @interrupt(i32 16, i32 1536, i32 %60, i32 0, i32 6480)
ret void
}

LLVM IR (-O2):
define void @changeFGcolor(i8 signext %0, i8 signext %1) {
%3 = tail call i32 (...) @clearScreen()
%4 = sext i8 %1 to i32
%5 = icmp slt i8 %1, 65
%6 = icmp ult i8 %1, 97
%7 = select i1 %6, i32 -55, i32 -87
%8 = select i1 %5, i32 -48, i32 %7
%9 = add nsw i32 %8, %4
%10 = icmp slt i8 %0, 97
%11 = sext i8 %0 to i32
%12 = select i1 %10, i32 -48, i32 -87
%13 = add nsw i32 %12, %11
%14 = shl nsw i32 %9, 4
%15 = add nsw i32 %13, %14
%16 = shl nsw i32 %15, 8
%17 = tail call i32 @interrupt(i32 16, i32 1536, i32 %16, i32 0, i32 6480)
ret void
}