#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 */
scalar_t__ strcmp(char const *, char *);
char *tgetstr(const char *attr, char **area) {
  if (strcmp(attr, "cm") == 0) {
    return ("\033[%d;%dH");
  }
  if (strcmp(attr, "cd") == 0) {
    return ("\033[0J");
  }
  if (strcmp(attr, "cl") == 0) {
    return ("\033[H\033[2J");
  }
  if (strcmp(attr, "ce") == 0) {
    return ("\033[0K");
  }
  if (strcmp(attr, "ho") == 0) {
    return ("\033[H");
  }
  if (strcmp(attr, "md") == 0) {
    return ("\033[1m");
  }
  if (strcmp(attr, "mr") == 0) {
    return ("\033[7m");
  }
  if (strcmp(attr, "me") == 0) {
    return ("\033[0m");
  }
  return (0);
}


x86 assembly (clang, -O0):
<tgetstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    114a <tgetstr+0x3a>
lea    0xec2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1174 <tgetstr+0x64>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <tgetstr+0x8e>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c8 <tgetstr+0xb8>
lea    0xe63(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f2 <tgetstr+0xe2>
lea    0xe41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <tgetstr+0x10c>
lea    0xe1e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1246 <tgetstr+0x136>
lea    0xdfc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
mov    -0x10(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1270 <tgetstr+0x160>
lea    0xdda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <tgetstr+0x168>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgetstr>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11cd <tgetstr+0xbd>
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d6 <tgetstr+0xc6>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11df <tgetstr+0xcf>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e8 <tgetstr+0xd8>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f1 <tgetstr+0xe1>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fa <tgetstr+0xea>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1203 <tgetstr+0xf3>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
lea    0xe7a(%rip),%rcx
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe2f(%rip),%rax
pop    %rbx
ret
lea    0xe32(%rip),%rax
pop    %rbx
ret
lea    0xe31(%rip),%rax
pop    %rbx
ret
lea    0xe33(%rip),%rax
pop    %rbx
ret
lea    0xe32(%rip),%rax
pop    %rbx
ret
lea    0xe30(%rip),%rax
pop    %rbx
ret
lea    0xe2f(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cm\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [5 x i8] c"\1B[0J\00"
@.str.4 = [3 x i8] c"cl\00"
@.str.5 = [8 x i8] c"\1B[H\1B[2J\00"
@.str.6 = [3 x i8] c"ce\00"
@.str.7 = [5 x i8] c"\1B[0K\00"
@.str.8 = [3 x i8] c"ho\00"
@.str.9 = [4 x i8] c"\1B[H\00"
@.str.10 = [3 x i8] c"md\00"
@.str.11 = [5 x i8] c"\1B[1m\00"
@.str.12 = [3 x i8] c"mr\00"
@.str.13 = [5 x i8] c"\1B[7m\00"
@.str.14 = [3 x i8] c"me\00"
@.str.15 = [5 x i8] c"\1B[0m\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 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %46
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %46
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %46
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %46
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %46
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %46
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %46
40: ; preds = %35
%41 = load i8*, i8** %4
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i8** %3
br label %46
45: ; preds = %40
store i8* null, i8** %3
br label %46
46: ; preds = %45, %44, %39, %34, %29, %24, %19, %14, %9
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"cm\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [3 x i8] c"cd\00"
@.str.3 = [5 x i8] c"\1B[0J\00"
@.str.4 = [3 x i8] c"cl\00"
@.str.5 = [8 x i8] c"\1B[H\1B[2J\00"
@.str.6 = [3 x i8] c"ce\00"
@.str.7 = [5 x i8] c"\1B[0K\00"
@.str.8 = [3 x i8] c"ho\00"
@.str.9 = [4 x i8] c"\1B[H\00"
@.str.10 = [3 x i8] c"md\00"
@.str.11 = [5 x i8] c"\1B[1m\00"
@.str.12 = [3 x i8] c"mr\00"
@.str.13 = [5 x i8] c"\1B[7m\00"
@.str.14 = [3 x i8] c"me\00"
@.str.15 = [5 x i8] c"\1B[0m\00"
define i8* @tgetstr(i8* %0, i8** nocapture readnone %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %27, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %27, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i8* null
br label %27
27: ; preds = %23, %20, %17, %14, %11, %8, %5, %2
%28 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), %17 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), %20 ], [ %26, %23 ]
ret i8* %28
}