#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
char *get_last(char const *, char);
char *get_last_asm(char const *, char);
char *get_parent_dir(char const *);
char *get_pdir_asm(char const *);
int /*<<< orphan*/ stderr;
int main(void) {
  const char *testpath = "~/Users/nobody1/Desktop/file.jpg";
  fprintf(stderr, "file path: %s\n", testpath);
  fprintf(stderr, "file name (c): %s\n", get_last(testpath, '/') + 1);
  fprintf(stderr, "file name (asm): %s\n", get_last_asm(testpath, '/') + 1);
  fprintf(stderr, "extension (c): %s\n", get_last(testpath, '.'));
  fprintf(stderr, "extension (asm): %s\n", get_last_asm(testpath, '.'));
  fprintf(stderr, "parent dir (c): %s\n", get_parent_dir(testpath));
  fprintf(stderr, "parent dir (asm): %s\n", get_pdir_asm(testpath));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea3(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <get_last@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xe82(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <get_last_asm@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xe65(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <get_last@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe4e(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <get_last_asm@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe35(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <get_parent_dir@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe23(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_pdir_asm@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe10(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e85(%rip),%r14
mov    (%r14),%edi
lea    0xebc(%rip),%rsi
lea    0xe94(%rip),%rbx
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <get_last@plt>
lea    0x1(%rax),%rdx
lea    0xea1(%rip),%rsi
mov    %ebp,%edi
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <get_last_asm@plt>
lea    0x1(%rax),%rdx
lea    0xe92(%rip),%rsi
mov    %ebp,%edi
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <get_last@plt>
lea    0xe89(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <get_last_asm@plt>
lea    0xe7b(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1060 <get_parent_dir@plt>
lea    0xe74(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1040 <get_pdir_asm@plt>
lea    0xe6c(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"~/Users/nobody1/Desktop/file.jpg\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"file path: %s\0A\00"
@.str.2 = [19 x i8] c"file name (c): %s\0A\00"
@.str.3 = [21 x i8] c"file name (asm): %s\0A\00"
@.str.4 = [19 x i8] c"extension (c): %s\0A\00"
@.str.5 = [21 x i8] c"extension (asm): %s\0A\00"
@.str.6 = [20 x i8] c"parent dir (c): %s\0A\00"
@.str.7 = [22 x i8] c"parent dir (asm): %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %2
%8 = call i8* @get_last(i8* %7, i8 signext 47)
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %2
%13 = call i8* @get_last_asm(i8* %12, i8 signext 47)
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i8* @get_last(i8* %17, i8 signext 46)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = call i8* @get_last_asm(i8* %21, i8 signext 46)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %2
%26 = call i8* @get_parent_dir(i8* %25)
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %26)
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %2
%30 = call i8* @get_pdir_asm(i8* %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"~/Users/nobody1/Desktop/file.jpg\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"file path: %s\0A\00"
@.str.2 = [19 x i8] c"file name (c): %s\0A\00"
@.str.3 = [21 x i8] c"file name (asm): %s\0A\00"
@.str.4 = [19 x i8] c"extension (c): %s\0A\00"
@.str.5 = [21 x i8] c"extension (asm): %s\0A\00"
@.str.6 = [20 x i8] c"parent dir (c): %s\0A\00"
@.str.7 = [22 x i8] c"parent dir (asm): %s\0A\00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stderr
%4 = tail call i8* @get_last(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext 47)
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @stderr
%8 = tail call i8* @get_last_asm(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext 47)
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @stderr
%12 = tail call i8* @get_last(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext 46)
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = tail call i8* @get_last_asm(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext 46)
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @stderr
%18 = tail call i8* @get_parent_dir(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = tail call i8* @get_pdir_asm(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %21)
ret i32 0
}