#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strrchr(char *, char);
void getrootl(char *filespc, char *filroot) {
  char *str;
  strcpy(filroot, filespc);
  while (str = strrchr(filroot, '.')) {
    if (!strcmp(str, ".rec"))
      *str = '\0';
    else if (!strcmp(str, ".dat"))
      *str = '\0';
    else if (!strcmp(str, ".txt"))
      *str = '\0';
    else
      break;
  }
}


x86 assembly (clang, -O0):
<getrootl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ec <getrootl+0xbc>
mov    -0x18(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    118e <getrootl+0x5e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e7 <getrootl+0xb7>
mov    -0x18(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11b3 <getrootl+0x83>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e2 <getrootl+0xb2>
mov    -0x18(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d8 <getrootl+0xa8>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11dd <getrootl+0xad>
jmp    11ec <getrootl+0xbc>
jmp    11e2 <getrootl+0xb2>
jmp    11e7 <getrootl+0xb7>
jmp    114d <getrootl+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getrootl>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11c5 <getrootl+0x95>
mov    %rax,%rbx
lea    0xe9d(%rip),%r14
lea    0xe9b(%rip),%r12
lea    0xe99(%rip),%r13
jmp    1198 <getrootl+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%rbx)
mov    %r15,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c5 <getrootl+0x95>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1180 <getrootl+0x50>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1180 <getrootl+0x50>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1180 <getrootl+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c".rec\00"
@.str.1 = [5 x i8] c".dat\00"
@.str.2 = [5 x i8] c".txt\00"
define void @getrootl(i8* %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* %0)
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %2, %16
%7 = phi i8* [ %17, %16 ], [ %4, %2 ]
%8 = tail call i32 @strcmp(i8* %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = tail call i32 @strcmp(i8* %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %10, %6
store i8 0, i8* %7
%17 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 46)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %6
19: ; preds = %16, %13, %2
ret void
}