#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();
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
    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    118f <determine_mode_from_name+0x3f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11b5 <determine_mode_from_name+0x65>
mov    $0x0,%al
call   1040 <set_list@plt>
jmp    11e7 <determine_mode_from_name+0x97>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11db <determine_mode_from_name+0x8b>
mov    $0x0,%al
call   1050 <set_grep@plt>
jmp    11e2 <determine_mode_from_name+0x92>
mov    $0x0,%al
call   1060 <set_filter@plt>
jmp    11e7 <determine_mode_from_name+0x97>
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    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     118e <determine_mode_from_name+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <set_list@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     11b0 <determine_mode_from_name+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <set_grep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <set_filter@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"lsdiff\00"
@.str.1 = [9 x i8] c"grepdiff\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 %26
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 %25
23: ; preds = %17
%24 = call i32 (...) @set_filter()
br label %25
25: ; preds = %23, %21
br label %26
26: ; preds = %25, %15
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"lsdiff\00"
@.str.1 = [9 x i8] c"grepdiff\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 %17
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 %17
15: ; preds = %10
%16 = tail call i32 (...) @set_filter()
br label %17
17: ; preds = %13, %15, %8
ret void
}