#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*/ strcpy(char *, char const *);
char *strtok(char *, char *);
void get_name(const char *filename, int n, char *instance) {
  char buf[n];
  char *aux = NULL;
  strcpy(buf, filename);
  aux = strtok(buf, "/");
  do {
    strcpy(instance, aux);
  } while ((aux = strtok(NULL, "/")) != NULL);
  strcpy(buf, instance);
  aux = strtok(buf, ".");
  strcpy(instance, aux);
}


x86 assembly (clang, -O0):
<get_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6a(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    117e <get_name+0x5e>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_name>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%rax
mov    %esi,%ecx
mov    %rsp,%r14
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0xeab(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1160 <get_name+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe76(%rip),%rsi
mov    %r14,%rdi
call   1040 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
define void @get_name(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i8, i64 %11
store i64 %11, i64* %8
store i8* null, i8** %9
%14 = load i8*, i8** %4
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %9
br label %17
17: ; preds = %21, %3
%18 = load i8*, i8** %6
%19 = load i8*, i8** %9
%20 = call i32 @strcpy(i8* %18, i8* %19)
br label %21
21: ; preds = %17
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %17, label %24
24: ; preds = %21
%25 = load i8*, i8** %6
%26 = call i32 @strcpy(i8* %13, i8* %25)
%27 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %9
%28 = load i8*, i8** %6
%29 = load i8*, i8** %9
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
define void @get_name(i8* %0, i32 %1, i8* %2) {
%4 = zext i32 %1 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %8, %3
%9 = phi i8* [ %7, %3 ], [ %11, %8 ]
%10 = call i32 @strcpy(i8* %2, i8* %9)
%11 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = call i32 @strcpy(i8* %5, i8* %2)
%15 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @strcpy(i8* %2, i8* %15)
ret void
}