#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 getcolor(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int fcolor = -1;
  int bcolor = -1;
  int x;
  if (argc < 2) {
    usage();
    return 1;
  }
  while ((x = getopt(argc, argv, "f:b:h")) > 0) {
    switch (x) {
    case 'h':
      usage();
      return 0;
      break;
    case 'f':
      if ((fcolor = getcolor(optarg)) == -1) {
        usage();
        return 1;
      }
      break;
    case 'b':
      if ((bcolor = getcolor(optarg)) == -1) {
        usage();
        return 1;
      }
      break;
    }
  }
  if (optind < argc) {
    usage();
    return 1;
  }
  if (fcolor != -1) {
    printf("\33[3%dm", fcolor);
  }
  if (bcolor != -1) {
    printf("\33[4%dm", bcolor);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1181 <main+0x41>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x175>
jmp    1186 <main+0x46>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1257 <main+0x117>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x62,%eax
je     1220 <main+0xe0>
jmp    11b9 <main+0x79>
mov    -0x20(%rbp),%eax
sub    $0x66,%eax
je     11ee <main+0xae>
jmp    11ca <main+0x8a>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
jne    1252 <main+0x112>
jmp    11db <main+0x9b>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b5 <main+0x175>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1030 <getcolor@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    121b <main+0xdb>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x175>
jmp    1252 <main+0x112>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1030 <getcolor@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    124d <main+0x10d>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x175>
jmp    1252 <main+0x112>
jmp    1186 <main+0x46>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    127c <main+0x13c>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x175>
cmpl   $0xffffffff,-0x14(%rbp)
je     1295 <main+0x155>
mov    -0x14(%rbp),%esi
lea    0xd76(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x18(%rbp)
je     12ae <main+0x16e>
mov    -0x18(%rbp),%esi
lea    0xd64(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    116d <main+0x2d>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe87(%rip),%rdx
call   1060 <getopt@plt>
test   %eax,%eax
jle    11f6 <main+0xb6>
mov    $0xffffffff,%r15d
mov    0x2e69(%rip),%r13
lea    0xe6a(%rip),%r12
mov    $0xffffffff,%ebp
jmp    11ba <main+0x7a>
nopl   (%rax)
cmp    $0x68,%eax
je     124e <main+0x10e>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <getopt@plt>
test   %eax,%eax
jle    120c <main+0xcc>
cmp    $0x62,%eax
je     11e0 <main+0xa0>
cmp    $0x66,%eax
jne    11a0 <main+0x60>
mov    0x0(%r13),%edi
call   1030 <getcolor@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11a9 <main+0x69>
jmp    1150 <main+0x10>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
call   1030 <getcolor@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    11a9 <main+0x69>
jmp    1150 <main+0x10>
mov    0x2de3(%rip),%rax
xor    %ebp,%ebp
cmp    %ebx,(%rax)
jl     1150 <main+0x10>
jmp    115c <main+0x1c>
mov    0x2dcd(%rip),%rax
cmp    %ebx,(%rax)
jl     1150 <main+0x10>
cmp    $0xffffffff,%ebp
je     122e <main+0xee>
lea    0xddf(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%r15d
je     115c <main+0x1c>
lea    0xdcc(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
jmp    115c <main+0x1c>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <usage@plt>
jmp    115c <main+0x1c>

LLVM IR (-O0):
@.str = [6 x i8] c"f:b:h\00"
@optarg = global i32 0
@optind = global i32 0
@.str.1 = [7 x i8] c"\1B[3%dm\00"
@.str.2 = [7 x i8] c"\1B[4%dm\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 -1, i32* %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @usage()
store i32 1, i32* %3
br label %57
13: ; preds = %2
br label %14
14: ; preds = %37, %13
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %8
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %14
%20 = load i32, i32* %8
switch i32 %20, label %37 [
i32 104, label %21
i32 102, label %23
i32 98, label %30
]
21: ; preds = %19
%22 = call i32 (...) @usage()
store i32 0, i32* %3
br label %57
23: ; preds = %19
%24 = load i32, i32* @optarg
%25 = call i32 @getcolor(i32 %24)
store i32 %25, i32* %6
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @usage()
store i32 1, i32* %3
br label %57
29: ; preds = %23
br label %37
30: ; preds = %19
%31 = load i32, i32* @optarg
%32 = call i32 @getcolor(i32 %31)
store i32 %32, i32* %7
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (...) @usage()
store i32 1, i32* %3
br label %57
36: ; preds = %30
br label %37
37: ; preds = %19, %36, %29
br label %14
38: ; preds = %14
%39 = load i32, i32* @optind
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (...) @usage()
store i32 1, i32* %3
br label %57
44: ; preds = %38
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %6
%49 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %47, %44
%51 = load i32, i32* %7
%52 = icmp ne i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %7
%55 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %50
store i32 0, i32* %3
br label %57
57: ; preds = %56, %42, %34, %27, %21, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [6 x i8] c"f:b:h\00"
@optarg = global i32 0
@optind = global i32 0
@.str.1 = [7 x i8] c"\1B[3%dm\00"
@.str.2 = [7 x i8] c"\1B[4%dm\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %5, 0
br i1 %6, label %9, label %35
7: ; preds = %2
%8 = tail call i32 (...) @usage()
br label %48
9: ; preds = %4, %27
%10 = phi i32 [ %30, %27 ], [ %5, %4 ]
%11 = phi i32 [ %29, %27 ], [ -1, %4 ]
%12 = phi i32 [ %28, %27 ], [ -1, %4 ]
switch i32 %10, label %27 [
i32 104, label %13
i32 102, label %15
i32 98, label %21
]
13: ; preds = %9
%14 = tail call i32 (...) @usage()
br label %48
15: ; preds = %9
%16 = load i32, i32* @optarg
%17 = tail call i32 @getcolor(i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = tail call i32 (...) @usage()
br label %48
21: ; preds = %9
%22 = load i32, i32* @optarg
%23 = tail call i32 @getcolor(i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = tail call i32 (...) @usage()
br label %48
27: ; preds = %21, %15, %9
%28 = phi i32 [ %12, %9 ], [ %12, %21 ], [ %17, %15 ]
%29 = phi i32 [ %11, %9 ], [ %23, %21 ], [ %11, %15 ]
%30 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%31 = icmp sgt i32 %30, 0
br i1 %31, label %9, label %32
32: ; preds = %27
%33 = load i32, i32* @optind
%34 = icmp slt i32 %33, %0
br i1 %34, label %38, label %40
35: ; preds = %4
%36 = load i32, i32* @optind
%37 = icmp slt i32 %36, %0
br i1 %37, label %38, label %48
38: ; preds = %35, %32
%39 = tail call i32 (...) @usage()
br label %48
40: ; preds = %32
%41 = icmp eq i32 %28, -1
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %44
44: ; preds = %42, %40
%45 = icmp eq i32 %29, -1
br i1 %45, label %48, label %46
46: ; preds = %44
%47 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %48
48: ; preds = %35, %44, %46, %38, %25, %19, %13, %7
%49 = phi i32 [ 1, %7 ], [ 1, %25 ], [ 1, %19 ], [ 0, %13 ], [ 1, %38 ], [ 0, %46 ], [ 0, %44 ], [ 0, %35 ]
ret i32 %49
}