#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 *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *parsename(char *filename) {
  static char copy[1024];
  strcpy(copy, filename);
  char *extension = strchr(copy, '.');
  if (extension == NULL) {
    return NULL;
  }
  if (strcmp(".plr", extension)) {
    return NULL;
  }
  *extension = '\0';
  return copy;
}


x86 assembly (clang, -O0):
<parsename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2f09(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2efd(%rip),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <parsename+0x49>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <parsename+0x82>
mov    -0x18(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11a0 <parsename+0x70>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <parsename+0x82>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ea2(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsename>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
lea    0x2f12(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     116f <parsename+0x3f>
mov    %rax,%r14
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1173 <parsename+0x43>
xor    %ebx,%ebx
jmp    1177 <parsename+0x47>
movb   $0x0,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@parsename.copy = internal global [1024 x i8] zeroinitializer
@.str = [5 x i8] c".plr\00"
define i8* @parsename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), i8* %5)
%7 = call i8* @strchr(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), i8 signext 46)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %18
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* null, i8** %2
br label %18
16: ; preds = %11
%17 = load i8*, i8** %4
store i8 0, i8* %17
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), i8** %2
br label %18
18: ; preds = %16, %15, %10
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@parsename.copy = internal global [1024 x i8] zeroinitializer
@.str = [5 x i8] c".plr\00"
define i8* @parsename(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), i8* %0)
%3 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), i8 signext 46)
%4 = icmp eq i8* %3, null
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i8 0, i8* %3
br label %9
9: ; preds = %5, %1, %8
%10 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @parsename.copy, i64 0, i64 0), %8 ], [ null, %1 ], [ null, %5 ]
ret i8* %10
}