#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*/ add_to_string(char *, char *);
int /*<<< orphan*/ initialize_string(char *);
int /*<<< orphan*/ last_char_pos(int *, char *, char);
int /*<<< orphan*/ substr(char *, char *, int);
void filename_without_extension(char *variable, char *filename) {
  int index;
  last_char_pos(&index, filename, '.');
  if (index == 0) {
    initialize_string(variable);
    add_to_string(variable, filename);
  } else {
    substr(variable, filename, index);
  }
}


x86 assembly (clang, -O0):
<filename_without_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdi
mov    $0x2e,%edx
call   1040 <last_char_pos@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1187 <filename_without_extension+0x47>
mov    -0x8(%rbp),%rdi
call   1060 <initialize_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <add_to_string@plt>
jmp    1197 <filename_without_extension+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <substr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filename_without_extension>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x4(%rsp),%rdi
mov    $0x2e,%edx
call   1040 <last_char_pos@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
je     116e <filename_without_extension+0x2e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <substr@plt>
jmp    1181 <filename_without_extension+0x41>
mov    %r14,%rdi
call   1060 <initialize_string@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <add_to_string@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @filename_without_extension(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @last_char_pos(i32* %5, i8* %6, i8 signext 46)
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @initialize_string(i8* %11)
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @add_to_string(i8* %13, i8* %14)
br label %21
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = call i32 @substr(i8* %17, i8* %18, i32 %19)
br label %21
21: ; preds = %16, %10
ret void
}

LLVM IR (-O2):
define void @filename_without_extension(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @last_char_pos(i32* %3, i8* %1, i8 signext 46)
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @initialize_string(i8* %0)
%10 = call i32 @add_to_string(i8* %0, i8* %1)
br label %13
11: ; preds = %2
%12 = call i32 @substr(i8* %0, i8* %1, i32 %6)
br label %13
13: ; preds = %11, %8
ret void
}