#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 */
char *basename(char const *);
char *strdup(char *);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
char *deduce_lv(const char *filename) {
  char *base = basename(filename);
  char *result = NULL;
  if (!strncasecmp("TouchPadBuntuRootfs", base, 19))
    result = strdup("ubuntu-root");
  else if (!strncasecmp("ArchLinuxARM-touchpad", base, 21))
    result = strdup("arch-root");
  else if (!strncasecmp("bodhi-touchpad", base, 14))
    result = strdup("bodhi-root");
  else if (!strncasecmp("HPTPSlackware", base, 13))
    result = strdup("slackware-root");
  else if (!strncasecmp("HPTPFedora", base, 10))
    result = strdup("fedora-root");
  return result;
}


x86 assembly (clang, -O0):
<deduce_lv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <basename@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea4(%rip),%rdi
mov    $0x13,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1184 <deduce_lv+0x54>
lea    0xe9e(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    125f <deduce_lv+0x12f>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x15,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11b7 <deduce_lv+0x87>
lea    0xe8d(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    125a <deduce_lv+0x12a>
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0xe,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11ea <deduce_lv+0xba>
lea    0xe73(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    1255 <deduce_lv+0x125>
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0xd,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    121d <deduce_lv+0xed>
lea    0xe59(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    1250 <deduce_lv+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdi
mov    $0xa,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    124b <deduce_lv+0x11b>
lea    0xe40(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    1250 <deduce_lv+0x120>
jmp    1255 <deduce_lv+0x125>
jmp    125a <deduce_lv+0x12a>
jmp    125f <deduce_lv+0x12f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deduce_lv>:
push   %rbx
call   1030 <basename@plt>
mov    %rax,%rbx
lea    0xec0(%rip),%rdi
mov    %rax,%rsi
mov    $0x13,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11b5 <deduce_lv+0x85>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
mov    $0x15,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11c2 <deduce_lv+0x92>
lea    0xed0(%rip),%rdi
mov    %rbx,%rsi
mov    $0xe,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11cf <deduce_lv+0x9f>
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
mov    $0xd,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11dc <deduce_lv+0xac>
lea    0xed7(%rip),%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11e9 <deduce_lv+0xb9>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe58(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>
lea    0xe6d(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>
lea    0xe79(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>
lea    0xe85(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>
lea    0xe92(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"TouchPadBuntuRootfs\00"
@.str.1 = [12 x i8] c"ubuntu-root\00"
@.str.2 = [22 x i8] c"ArchLinuxARM-touchpad\00"
@.str.3 = [10 x i8] c"arch-root\00"
@.str.4 = [15 x i8] c"bodhi-touchpad\00"
@.str.5 = [11 x i8] c"bodhi-root\00"
@.str.6 = [14 x i8] c"HPTPSlackware\00"
@.str.7 = [15 x i8] c"slackware-root\00"
@.str.8 = [11 x i8] c"HPTPFedora\00"
@.str.9 = [12 x i8] c"fedora-root\00"
define i8* @deduce_lv(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @basename(i8* %5)
store i8* %6, i8** %3
store i8* null, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strncasecmp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %7, i32 19)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = call i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %4
br label %40
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @strncasecmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 21)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* %17, i8** %4
br label %39
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = call i32 @strncasecmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %19, i32 14)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = call i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
store i8* %23, i8** %4
br label %38
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = call i32 @strncasecmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %25, i32 13)
%27 = icmp ne i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i8* @strdup(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i8* %29, i8** %4
br label %37
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = call i32 @strncasecmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %31, i32 10)
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = call i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i8* %35, i8** %4
br label %36
36: ; preds = %34, %30
br label %37
37: ; preds = %36, %28
br label %38
38: ; preds = %37, %22
br label %39
39: ; preds = %38, %16
br label %40
40: ; preds = %39, %10
%41 = load i8*, i8** %4
ret i8* %41
}

LLVM IR (-O2):
@.str = [20 x i8] c"TouchPadBuntuRootfs\00"
@.str.1 = [12 x i8] c"ubuntu-root\00"
@.str.2 = [22 x i8] c"ArchLinuxARM-touchpad\00"
@.str.3 = [10 x i8] c"arch-root\00"
@.str.4 = [15 x i8] c"bodhi-touchpad\00"
@.str.5 = [11 x i8] c"bodhi-root\00"
@.str.6 = [14 x i8] c"HPTPSlackware\00"
@.str.7 = [15 x i8] c"slackware-root\00"
@.str.8 = [11 x i8] c"HPTPFedora\00"
@.str.9 = [12 x i8] c"fedora-root\00"
define noalias i8* @deduce_lv(i8* %0) {
%2 = tail call i8* @basename(i8* %0)
%3 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %2, i32 19)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call dereferenceable_or_null(12) i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %27
7: ; preds = %1
%8 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 21)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call dereferenceable_or_null(10) i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %27
12: ; preds = %7
%13 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 14)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call dereferenceable_or_null(11) i8* @strdup(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %27
17: ; preds = %12
%18 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %2, i32 13)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call dereferenceable_or_null(15) i8* @strdup(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %27
22: ; preds = %17
%23 = tail call i32 @strncasecmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %2, i32 10)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call dereferenceable_or_null(12) i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %27
27: ; preds = %10, %20, %25, %22, %15, %5
%28 = phi i8* [ null, %22 ], [ %26, %25 ], [ %21, %20 ], [ %16, %15 ], [ %11, %10 ], [ %6, %5 ]
ret i8* %28
}