linemod(s) char *s;
{
  putchar(033);
  if (s[0] == 'l')
    putchar('d');
  else if (s[1] == 'h')
    putchar('c');
  else if (s[3] == 'd')
    putchar('b');
  else if (s[0] == 'd')
    putchar('a');
  else
    putchar('e');
}


x86 assembly (clang, -O0):
<linemod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x1b,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6c,%eax
jne    1149 <linemod+0x39>
mov    $0x64,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11c9 <linemod+0xb9>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x68,%eax
jne    116b <linemod+0x5b>
mov    $0x63,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11c4 <linemod+0xb4>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x64,%eax
jne    118d <linemod+0x7d>
mov    $0x62,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11bf <linemod+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    11ae <linemod+0x9e>
mov    $0x61,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11ba <linemod+0xaa>
mov    $0x65,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    11bf <linemod+0xaf>
jmp    11c4 <linemod+0xb4>
jmp    11c9 <linemod+0xb9>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linemod>:
push   %rbx
mov    %rdi,%rbx
mov    $0x1b,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
mov    (%rbx),%al
mov    $0x64,%edi
cmp    $0x6c,%al
je     114f <linemod+0x3f>
mov    $0x63,%edi
cmpb   $0x68,0x1(%rbx)
je     114f <linemod+0x3f>
mov    $0x62,%edi
cmpb   $0x64,0x3(%rbx)
je     114f <linemod+0x3f>
xor    %ecx,%ecx
cmp    $0x64,%al
setne  %cl
lea    0x61(,%rcx,4),%edi
xor    %eax,%eax
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define i32 @linemod(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 27)
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 108
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 100)
br label %41
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 104
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 99)
br label %40
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 100
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 98)
br label %39
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 100
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 97)
br label %38
36: ; preds = %28
%37 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 101)
br label %38
38: ; preds = %36, %34
br label %39
39: ; preds = %38, %26
br label %40
40: ; preds = %39, %18
br label %41
41: ; preds = %40, %10
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
define i32 @linemod(i8* nocapture %0) {
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 27)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 108
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 104
br i1 %8, label %16, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 3
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 100
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = icmp eq i8 %3, 100
%15 = select i1 %14, i32 97, i32 101
br label %16
16: ; preds = %13, %9, %5, %1
%17 = phi i32 [ 100, %1 ], [ 99, %5 ], [ 98, %9 ], [ %15, %13 ]
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %17)
ret i32 undef
}