int term_type_str(str)
char *str;
{
  if ((strncmp(str, "oldjis", 6) == 0) || (strncmp(str, "jisold", 6) == 0))
    return 1;
  if (strncmp(str, "dec", 6) == 0)
    return 3;
  if ((strncmp(str, "euc", 6) == 0) || (strncmp(str, "att", 6) == 0))
    return 4;
  if ((strncmp(str, "sjis", 6) == 0) || (strncmp(str, "msjis", 6) == 0) ||
      (strncmp(str, "shiftjis", 6) == 0))
    return 5;
  return 2;
}


x86 assembly (clang, -O0):
<term_type_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1158 <term_type_str+0x48>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1164 <term_type_str+0x54>
movl   $0x1,-0x4(%rbp)
jmp    1243 <term_type_str+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    118e <term_type_str+0x7e>
movl   $0x3,-0x4(%rbp)
jmp    1243 <term_type_str+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11ca <term_type_str+0xba>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d6 <term_type_str+0xc6>
movl   $0x4,-0x4(%rbp)
jmp    1243 <term_type_str+0x133>
mov    -0x10(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1230 <term_type_str+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1230 <term_type_str+0x120>
mov    -0x10(%rbp),%rdi
lea    0xe03(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    123c <term_type_str+0x12c>
movl   $0x5,-0x4(%rbp)
jmp    1243 <term_type_str+0x133>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_type_str>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xecc(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xeb7(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f9 <term_type_str+0xe9>
lea    0xe9f(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
mov    $0x4,%ebp
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xe86(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xe73(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
mov    $0x5,%ebp
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xe55(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     11fe <term_type_str+0xee>
lea    0xe43(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,2),%ebp
add    $0x2,%ebp
jmp    11fe <term_type_str+0xee>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"oldjis\00"
@.str.1 = [7 x i8] c"jisold\00"
@.str.2 = [4 x i8] c"dec\00"
@.str.3 = [4 x i8] c"euc\00"
@.str.4 = [4 x i8] c"att\00"
@.str.5 = [5 x i8] c"sjis\00"
@.str.6 = [6 x i8] c"msjis\00"
@.str.7 = [9 x i8] c"shiftjis\00"
define i32 @term_type_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 1, i32* %2
br label %40
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 3, i32* %2
br label %40
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i32 @strncmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = call i32 @strncmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 6)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21, %17
store i32 4, i32* %2
br label %40
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = call i32 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 6)
%29 = icmp eq i32 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 6)
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %3
%36 = call i32 @strncmp(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i64 6)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34, %30, %26
store i32 5, i32* %2
br label %40
39: ; preds = %34
store i32 2, i32* %2
br label %40
40: ; preds = %39, %38, %25, %16, %11
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [7 x i8] c"oldjis\00"
@.str.1 = [7 x i8] c"jisold\00"
@.str.2 = [4 x i8] c"dec\00"
@.str.3 = [4 x i8] c"euc\00"
@.str.4 = [4 x i8] c"att\00"
@.str.5 = [5 x i8] c"sjis\00"
@.str.6 = [6 x i8] c"msjis\00"
@.str.7 = [9 x i8] c"shiftjis\00"
define i32 @term_type_str(i8* nocapture %0) {
%2 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6)
%3 = icmp eq i32 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 6)
%6 = icmp eq i32 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 6)
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 6)
%18 = icmp eq i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 6)
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i64 6)
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i32 5, i32 2
br label %26
26: ; preds = %22, %16, %19, %10, %13, %7, %1, %4
%27 = phi i32 [ 1, %4 ], [ 1, %1 ], [ 3, %7 ], [ 4, %13 ], [ 4, %10 ], [ 5, %19 ], [ 5, %16 ], [ %25, %22 ]
ret i32 %27
}