#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*/ set_filter();
int /*<<< orphan*/ set_grep();
int /*<<< orphan*/ set_list();
int /*<<< orphan*/ set_view();
char *strrchr(char const *, char);
scalar_t__ strstr(char const *, char *);
void determine_mode_from_name(const char *argv0) {
  const char *p = strrchr(argv0, '/');
  if (!p++)
    p = argv0;
  if (strstr(p, "lsdiff"))
    set_list();
  else if (strstr(p, "grepdiff"))
    set_grep();
  else if (strstr(p, "patchview")) {
    set_view();
  } else
    set_filter();
}


x86 assembly (clang, -O0):
<determine_mode_from_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
jne    119f <determine_mode_from_name+0x3f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11c5 <determine_mode_from_name+0x65>
mov    $0x0,%al
call   1040 <set_list@plt>
jmp    1222 <determine_mode_from_name+0xc2>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11eb <determine_mode_from_name+0x8b>
mov    $0x0,%al
call   1050 <set_grep@plt>
jmp    121d <determine_mode_from_name+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1211 <determine_mode_from_name+0xb1>
mov    $0x0,%al
call   1060 <set_view@plt>
jmp    1218 <determine_mode_from_name+0xb8>
mov    $0x0,%al
call   1070 <set_filter@plt>
jmp    121d <determine_mode_from_name+0xbd>
jmp    1222 <determine_mode_from_name+0xc2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_mode_from_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %r14,%rbx
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     119e <determine_mode_from_name+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <set_list@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     11c0 <determine_mode_from_name+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <set_grep@plt>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     11e2 <determine_mode_from_name+0x82>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <set_view@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <set_filter@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"lsdiff\00"
@.str.1 = [9 x i8] c"grepdiff\00"
@.str.2 = [10 x i8] c"patchview\00"
define void @determine_mode_from_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strrchr(i8* %4, i8 signext 47)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %3
%8 = icmp ne i8* %6, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = load i8*, i8** %2
store i8* %10, i8** %3
br label %11
11: ; preds = %9, %1
%12 = load i8*, i8** %3
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (...) @set_list()
br label %33
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @set_grep()
br label %32
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @set_view()
br label %31
29: ; preds = %23
%30 = call i32 (...) @set_filter()
br label %31
31: ; preds = %29, %27
br label %32
32: ; preds = %31, %21
br label %33
33: ; preds = %32, %15
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"lsdiff\00"
@.str.1 = [9 x i8] c"grepdiff\00"
@.str.2 = [10 x i8] c"patchview\00"
define void @determine_mode_from_name(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = icmp eq i8* %2, null
%5 = select i1 %4, i8* %0, i8* %3
%6 = tail call i64 @strstr(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 (...) @set_list()
br label %22
10: ; preds = %1
%11 = tail call i64 @strstr(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 (...) @set_grep()
br label %22
15: ; preds = %10
%16 = tail call i64 @strstr(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 (...) @set_view()
br label %22
20: ; preds = %15
%21 = tail call i32 (...) @set_filter()
br label %22
22: ; preds = %13, %20, %18, %8
ret void
}