#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 */
scalar_t__ malloc(int);
char *marker_string_filename_get_name(char const *);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
size_t strlen(char *);
char *marker_string_filename_get_name_noext(const char *filename) {
  char *name = marker_string_filename_get_name(filename);
  size_t len = strlen(name);
  for (int i = len; i > 0; --i) {
    if (filename[i] == '.') {
      char *ret = (char *)malloc(i + 1);
      memset(ret, 0, i + 1);
      memcpy(ret, filename, i);
      return ret;
    }
  }
  return name;
}


x86 assembly (clang, -O0):
<marker_string_filename_get_name_noext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <marker_string_filename_get_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11ec <marker_string_filename_get_name_noext+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    11d9 <marker_string_filename_get_name_noext+0x89>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f4 <marker_string_filename_get_name_noext+0xa4>
jmp    11de <marker_string_filename_get_name_noext+0x8e>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    117d <marker_string_filename_get_name_noext+0x2d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<marker_string_filename_get_name_noext>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1070 <marker_string_filename_get_name@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
test   %ebx,%ebx
jle    11bb <marker_string_filename_get_name_noext+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
cmpb   $0x2e,(%r15,%rax,1)
je     1195 <marker_string_filename_get_name_noext+0x45>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
jg     1180 <marker_string_filename_get_name_noext+0x30>
jmp    11bb <marker_string_filename_get_name_noext+0x6b>
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @marker_string_filename_get_name_noext(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @marker_string_filename_get_name(i8* %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = trunc i64 %12 to i32
store i32 %13, i32* %6
br label %14
14: ; preds = %40, %1
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %43
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 46
br i1 %24, label %25, label %39
25: ; preds = %17
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %7
%30 = load i8*, i8** %7
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
%33 = call i32 @memset(i8* %30, i32 0, i32 %32)
%34 = load i8*, i8** %7
%35 = load i8*, i8** %3
%36 = load i32, i32* %6
%37 = call i32 @memcpy(i8* %34, i8* %35, i32 %36)
%38 = load i8*, i8** %7
store i8* %38, i8** %2
br label %45
39: ; preds = %17
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, -1
store i32 %42, i32* %6
br label %14
43: ; preds = %14
%44 = load i8*, i8** %4
store i8* %44, i8** %2
br label %45
45: ; preds = %43, %25
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
define i8* @marker_string_filename_get_name_noext(i8* %0) {
%2 = tail call i8* @marker_string_filename_get_name(i8* %0)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %1, %18
%7 = phi i32 [ %19, %18 ], [ %4, %1 ]
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 46
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = add nuw nsw i32 %7, 1
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 @memset(i8* %15, i32 0, i32 %13)
%17 = tail call i32 @memcpy(i8* %15, i8* %0, i32 %7)
br label %21
18: ; preds = %6
%19 = add nsw i32 %7, -1
%20 = icmp sgt i32 %7, 1
br i1 %20, label %6, label %21
21: ; preds = %18, %1, %12
%22 = phi i8* [ %15, %12 ], [ %2, %1 ], [ %2, %18 ]
ret i8* %22
}