#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 *extension(char *);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ strncpy(char *, char *, int);
void class_name(char *buf, char *filename) {
  char *p, *s;
  for (s = p = extension(filename);
       --s >= filename && (isalpha(*s) || isdigit(*s) || (*s) == '_');)
    ;
  s++;
  strncpy(buf, s, p - s);
  buf[p - s] = '\0';
}


x86 assembly (clang, -O0):
<class_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <extension@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     11ce <class_name+0x8e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x22(%rbp)
jne    11c8 <class_name+0x88>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x22(%rbp)
jne    11c8 <class_name+0x88>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11de <class_name+0x9e>
jmp    11e3 <class_name+0xa3>
jmp    1161 <class_name+0x21>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<class_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <extension@plt>
mov    %rax,%r15
lea    -0x1(%rax),%rbx
mov    %rax,%rsi
cmp    %r12,%rbx
jae    1179 <class_name+0x39>
jmp    119f <class_name+0x5f>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
cmp    %r12,%rbx
jb     1198 <class_name+0x58>
movsbl (%rbx),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1170 <class_name+0x30>
movsbl (%rbx),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
jne    1170 <class_name+0x30>
cmpb   $0x5f,(%rbx)
je     1170 <class_name+0x30>
add    $0x1,%rbx
mov    %rbx,%rsi
sub    %rsi,%r15
mov    %r14,%rdi
mov    %r15d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r14,%r15,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @class_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i8* @extension(i8* %7)
store i8* %8, i8** %5
store i8* %8, i8** %6
br label %9
9: ; preds = %33, %2
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i32 -1
store i8* %11, i8** %6
%12 = load i8*, i8** %4
%13 = icmp uge i8* %11, %12
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i8*, i8** %6
%16 = load i8, i8* %15
%17 = call i64 @isalpha(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 95
br label %29
29: ; preds = %24, %19, %14
%30 = phi i1 [ true, %19 ], [ true, %14 ], [ %28, %24 ]
br label %31
31: ; preds = %29, %9
%32 = phi i1 [ false, %9 ], [ %30, %29 ]
br i1 %32, label %33, label %34
33: ; preds = %31
br label %9
34: ; preds = %31
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
%37 = load i8*, i8** %3
%38 = load i8*, i8** %6
%39 = load i8*, i8** %5
%40 = load i8*, i8** %6
%41 = ptrtoint i8* %39 to i64
%42 = ptrtoint i8* %40 to i64
%43 = sub i64 %41, %42
%44 = trunc i64 %43 to i32
%45 = call i32 @strncpy(i8* %37, i8* %38, i32 %44)
%46 = load i8*, i8** %3
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = ptrtoint i8* %47 to i64
%50 = ptrtoint i8* %48 to i64
%51 = sub i64 %49, %50
%52 = getelementptr inbounds i8, i8* %46, i64 %51
store i8 0, i8* %52
ret void
}

LLVM IR (-O2):
define void @class_name(i8* %0, i8* %1) {
%3 = tail call i8* @extension(i8* %1)
%4 = getelementptr inbounds i8, i8* %3, i64 -1
%5 = icmp ult i8* %4, %1
br i1 %5, label %22, label %6
6: ; preds = %2, %19
%7 = phi i8* [ %20, %19 ], [ %4, %2 ]
%8 = phi i8* [ %7, %19 ], [ %3, %2 ]
%9 = load i8, i8* %7
%10 = tail call i64 @isalpha(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = load i8, i8* %7
%14 = tail call i64 @isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8, i8* %7
%18 = icmp eq i8 %17, 95
br i1 %18, label %19, label %22
19: ; preds = %6, %12, %16
%20 = getelementptr inbounds i8, i8* %7, i64 -1
%21 = icmp ult i8* %20, %1
br i1 %21, label %22, label %6
22: ; preds = %16, %19, %2
%23 = phi i8* [ %3, %2 ], [ %7, %19 ], [ %8, %16 ]
%24 = ptrtoint i8* %3 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = tail call i32 @strncpy(i8* %0, i8* %23, i32 %27)
%29 = getelementptr inbounds i8, i8* %0, i64 %26
store i8 0, i8* %29
ret void
}