#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*/ strcmp(char *, char const *);
const char *term_erase_from_name(const char *name) {
  if (!strcmp("end", name))
    return "K";
  if (!strcmp("start", name))
    return "1K";
  if (!strcmp("line", name))
    return "2K";
  if (!strcmp("up", name))
    return "1J";
  if (!strcmp("down", name))
    return "J";
  if (!strcmp("screen", name))
    return "1J";
  return NULL;
}


x86 assembly (clang, -O0):
<term_erase_from_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1145 <term_erase_from_name+0x35>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116e <term_erase_from_name+0x5e>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1197 <term_erase_from_name+0x87>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c0 <term_erase_from_name+0xb0>
lea    0xe61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11e9 <term_erase_from_name+0xd9>
lea    0xe39(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
mov    -0x10(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1212 <term_erase_from_name+0x102>
lea    0xe0f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121a <term_erase_from_name+0x10a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_erase_from_name>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1195 <term_erase_from_name+0x85>
lea    0xed6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119e <term_erase_from_name+0x8e>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a7 <term_erase_from_name+0x97>
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b0 <term_erase_from_name+0xa0>
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b9 <term_erase_from_name+0xa9>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
lea    0xe89(%rip),%rcx
cmove  %rcx,%rax
pop    %rbx
ret
lea    0xe6f(%rip),%rax
pop    %rbx
ret
lea    0xe65(%rip),%rax
pop    %rbx
ret
lea    0xe64(%rip),%rax
pop    %rbx
ret
lea    0xe61(%rip),%rax
pop    %rbx
ret
lea    0xe59(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"end\00"
@.str.1 = [2 x i8] c"K\00"
@.str.2 = [6 x i8] c"start\00"
@.str.3 = [3 x i8] c"1K\00"
@.str.4 = [5 x i8] c"line\00"
@.str.5 = [3 x i8] c"2K\00"
@.str.6 = [3 x i8] c"up\00"
@.str.7 = [3 x i8] c"1J\00"
@.str.8 = [5 x i8] c"down\00"
@.str.9 = [2 x i8] c"J\00"
@.str.10 = [7 x i8] c"screen\00"
define i8* @term_erase_from_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %34
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %34
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %34
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %34
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %34
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %34
33: ; preds = %28
store i8* null, i8** %2
br label %34
34: ; preds = %33, %32, %27, %22, %17, %12, %7
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@.str = [4 x i8] c"end\00"
@.str.1 = [2 x i8] c"K\00"
@.str.2 = [6 x i8] c"start\00"
@.str.3 = [3 x i8] c"1K\00"
@.str.4 = [5 x i8] c"line\00"
@.str.5 = [3 x i8] c"2K\00"
@.str.6 = [3 x i8] c"up\00"
@.str.7 = [3 x i8] c"1J\00"
@.str.8 = [5 x i8] c"down\00"
@.str.9 = [2 x i8] c"J\00"
@.str.10 = [7 x i8] c"screen\00"
define i8* @term_erase_from_name(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(1) %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(1) %0)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* null
br label %20
20: ; preds = %16, %13, %10, %7, %4, %1
%21 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %13 ], [ %19, %16 ]
ret i8* %21
}