char *tgetstr(char *name, char **area) {
  if (name[0] == 'c' && name[1] == 'e')
    return "\33[K";
  if (name[0] == 'c' && name[1] == 'l')
    return "\33[2J";
  if (name[0] == 's' && name[1] == 'o')
    return "\33[7m";
  if (name[0] == 's' && name[1] == 'e')
    return "\33[m";
  if (name[0] == 'h' && name[1] == 'o')
    return "\33[H";
  if (name[0] == 'c' && name[1] == 'd')
    return "\33[J";
  return 0;
}


x86 assembly (clang, -O0):
<tgetstr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    113d <tgetstr+0x3d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x65,%eax
jne    113d <tgetstr+0x3d>
lea    0xecc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    116e <tgetstr+0x6e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6c,%eax
jne    116e <tgetstr+0x6e>
lea    0xe9f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    119f <tgetstr+0x9f>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    119f <tgetstr+0x9f>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    11d0 <tgetstr+0xd0>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x65,%eax
jne    11d0 <tgetstr+0xd0>
lea    0xe47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x68,%eax
jne    1201 <tgetstr+0x101>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    1201 <tgetstr+0x101>
lea    0xe1a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    1232 <tgetstr+0x132>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    1232 <tgetstr+0x132>
lea    0xded(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <tgetstr+0x13a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgetstr>:
mov    (%rdi),%al
cmp    $0x73,%al
je     1125 <tgetstr+0x25>
cmp    $0x68,%al
je     1145 <tgetstr+0x45>
cmp    $0x63,%al
jne    1153 <tgetstr+0x53>
mov    0x1(%rdi),%al
cmp    $0x64,%al
je     1156 <tgetstr+0x56>
cmp    $0x65,%al
je     115e <tgetstr+0x5e>
cmp    $0x6c,%al
jne    1153 <tgetstr+0x53>
lea    0xee0(%rip),%rax
ret
mov    0x1(%rdi),%al
xor    %ecx,%ecx
cmp    $0x65,%al
lea    0xedb(%rip),%rdx
cmove  %rdx,%rcx
cmp    $0x6f,%al
lea    0xec9(%rip),%rax
cmovne %rcx,%rax
ret
cmpb   $0x6f,0x1(%rdi)
jne    1153 <tgetstr+0x53>
lea    0xec0(%rip),%rax
ret
xor    %eax,%eax
ret
lea    0xeb9(%rip),%rax
ret
lea    0xe9b(%rip),%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\1B[K\00"
@.str.1 = [5 x i8] c"\1B[2J\00"
@.str.2 = [5 x i8] c"\1B[7m\00"
@.str.3 = [4 x i8] c"\1B[m\00"
@.str.4 = [4 x i8] c"\1B[H\00"
@.str.5 = [4 x i8] c"\1B[J\00"
define i8* @tgetstr(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 99
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 101
br i1 %16, label %17, label %18
17: ; preds = %11
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %84
18: ; preds = %11, %2
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 99
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 108
br i1 %29, label %30, label %31
30: ; preds = %24
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %84
31: ; preds = %24, %18
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 115
br i1 %36, label %37, label %44
37: ; preds = %31
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 111
br i1 %42, label %43, label %44
43: ; preds = %37
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %84
44: ; preds = %37, %31
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 115
br i1 %49, label %50, label %57
50: ; preds = %44
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 101
br i1 %55, label %56, label %57
56: ; preds = %50
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %84
57: ; preds = %50, %44
%58 = load i8*, i8** %4
%59 = getelementptr inbounds i8, i8* %58, i64 0
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 104
br i1 %62, label %63, label %70
63: ; preds = %57
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 111
br i1 %68, label %69, label %70
69: ; preds = %63
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %84
70: ; preds = %63, %57
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 99
br i1 %75, label %76, label %83
76: ; preds = %70
%77 = load i8*, i8** %4
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 100
br i1 %81, label %82, label %83
82: ; preds = %76
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %84
83: ; preds = %76, %70
store i8* null, i8** %3
br label %84
84: ; preds = %83, %82, %69, %56, %43, %30, %17
%85 = load i8*, i8** %3
ret i8* %85
}

LLVM IR (-O2):
@.str = [4 x i8] c"\1B[K\00"
@.str.1 = [5 x i8] c"\1B[2J\00"
@.str.2 = [5 x i8] c"\1B[7m\00"
@.str.3 = [4 x i8] c"\1B[m\00"
@.str.4 = [4 x i8] c"\1B[H\00"
@.str.5 = [4 x i8] c"\1B[J\00"
define i8* @tgetstr(i8* nocapture %0, i8** nocapture readnone %1) {
%3 = load i8, i8* %0
switch i8 %3, label %18 [
i8 99, label %4
i8 115, label %7
i8 104, label %14
]
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
switch i8 %6, label %18 [
i8 101, label %21
i8 108, label %19
i8 100, label %20
]
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 101
%11 = select i1 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* null
%12 = icmp eq i8 %9, 111
%13 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %11
br label %21
14: ; preds = %2
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 111
br i1 %17, label %21, label %18
18: ; preds = %4, %2, %14
br label %21
19: ; preds = %4
br label %21
20: ; preds = %4
br label %21
21: ; preds = %7, %4, %20, %19, %14, %18
%22 = phi i8* [ null, %18 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %19 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %20 ], [ %13, %7 ]
ret i8* %22
}