#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 *malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
scalar_t__ strlen(char const *);
char *iupStrFileGetTitle(const char *file_name) {
  if (!file_name)
    return NULL;
  else {
    int len = (int)strlen(file_name);
    int offset = len - 1;
    while (offset != 0) {
      if (file_name[offset] == '\\' || file_name[offset] == '/') {
        offset++;
        break;
      }
      offset--;
    }
    {
      int title_size = len - offset + 1;
      char *file_title = malloc(title_size);
      memcpy(file_title, file_name + offset, title_size);
      return file_title;
    }
  }
}


x86 assembly (clang, -O0):
<iupStrFileGetTitle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <iupStrFileGetTitle+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11f0 <iupStrFileGetTitle+0xc0>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11b9 <iupStrFileGetTitle+0x89>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
je     119d <iupStrFileGetTitle+0x6d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11ab <iupStrFileGetTitle+0x7b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b9 <iupStrFileGetTitle+0x89>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1169 <iupStrFileGetTitle+0x39>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iupStrFileGetTitle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117b <iupStrFileGetTitle+0x4b>
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%rbx
movslq %ebx,%rax
lea    0x1(%rax),%ebp
add    %r14,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x2,%ebp
je     1180 <iupStrFileGetTitle+0x50>
movzbl (%rax),%ecx
add    $0xffffffff,%ebp
cmp    $0x5c,%cl
je     1182 <iupStrFileGetTitle+0x52>
add    $0xffffffffffffffff,%rax
cmp    $0x2f,%cl
jne    1160 <iupStrFileGetTitle+0x30>
jmp    1182 <iupStrFileGetTitle+0x52>
xor    %r15d,%r15d
jmp    11a4 <iupStrFileGetTitle+0x74>
xor    %ebp,%ebp
sub    %ebp,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
movslq %ebp,%rax
add    %rax,%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @iupStrFileGetTitle(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* null, i8** %2
br label %57
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %5
br label %17
17: ; preds = %39, %11
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %42
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 92
br i1 %27, label %36, label %28
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %39
36: ; preds = %28, %20
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %42
39: ; preds = %28
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
br label %17
42: ; preds = %36, %17
%43 = load i32, i32* %4
%44 = load i32, i32* %5
%45 = sub nsw i32 %43, %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = call i8* @malloc(i32 %47)
store i8* %48, i8** %7
%49 = load i8*, i8** %7
%50 = load i8*, i8** %3
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i32, i32* %6
%55 = call i32 @memcpy(i8* %49, i8* %53, i32 %54)
%56 = load i8*, i8** %7
store i8* %56, i8** %2
br label %57
57: ; preds = %42, %10
%58 = load i8*, i8** %2
ret i8* %58
}

LLVM IR (-O2):
define i8* @iupStrFileGetTitle(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %26, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = trunc i64 %4 to i32
%6 = shl i64 %4, 32
%7 = ashr exact i64 %6, 32
br label %8
8: ; preds = %13, %3
%9 = phi i64 [ %10, %13 ], [ %7, %3 ]
%10 = add nsw i64 %9, -1
%11 = trunc i64 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %0, i64 %10
%15 = load i8, i8* %14
switch i8 %15, label %8 [
i8 92, label %16
i8 47, label %16
]
16: ; preds = %13, %13
%17 = trunc i64 %9 to i32
br label %18
18: ; preds = %8, %16
%19 = phi i32 [ %17, %16 ], [ 0, %8 ]
%20 = sub nsw i32 %5, %19
%21 = add nsw i32 %20, 1
%22 = tail call i8* @malloc(i32 %21)
%23 = sext i32 %19 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = tail call i32 @memcpy(i8* %22, i8* %24, i32 %21)
br label %26
26: ; preds = %1, %18
%27 = phi i8* [ %22, %18 ], [ null, %1 ]
ret i8* %27
}