#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 *);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *strtok(char *, char *);
void divide_dir(char *stringa, char *dir, char *nome) {
  char tok[] = "\\/";
  char tempstr[40], *p;
  strcpy(tempstr, stringa);
  strcpy(dir, "");
  strcpy(nome, stringa);
  p = strtok(tempstr, tok);
  if (p) {
    while ((p = strtok(NULL, tok)) != 0)
      strcpy(nome, p);
    strncpy(dir, stringa, strlen(stringa) - strlen(nome));
    dir[strlen(stringa) - strlen(nome)] = 0;
  }
  return;
}


x86 assembly (clang, -O0):
<divide_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xea2(%rip),%ax
mov    %ax,-0x1b(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x50(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     124d <divide_dir+0x10d>
jmp    11b6 <divide_dir+0x76>
lea    -0x1b(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     11e3 <divide_dir+0xa3>
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11b6 <divide_dir+0x76>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x80(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
sub    %rax,%rdx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rcx
mov    %rax,%rdx
mov    -0x60(%rbp),%rax
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divide_dir>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0xe(%rsp)
movw   $0x2f5c,0xc(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xe8b(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     1219 <divide_dir+0xd9>
lea    0xc(%rsp),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     11da <divide_dir+0x9a>
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11c0 <divide_dir+0x80>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
sub    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
sub    %rax,%rbx
movb   $0x0,(%r14,%rbx,1)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.divide_dir.tok = [3 x i8] c"\\/\00"
@.str = [1 x i8] zeroinitializer
define void @divide_dir(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [3 x i8]
%8 = alloca [40 x i8]
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = bitcast [3 x i8]* %7 to i8*
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %6
%17 = load i8*, i8** %4
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%21 = call i8* @strtok(i8* %19, i8* %20)
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %49
24: ; preds = %3
br label %25
25: ; preds = %29, %24
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%27 = call i8* @strtok(i8* null, i8* %26)
store i8* %27, i8** %9
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = load i8*, i8** %9
%32 = call i32 @strcpy(i8* %30, i8* %31)
br label %25
33: ; preds = %25
%34 = load i8*, i8** %5
%35 = load i8*, i8** %4
%36 = load i8*, i8** %4
%37 = call i64 @strlen(i8* %36)
%38 = load i8*, i8** %6
%39 = call i64 @strlen(i8* %38)
%40 = sub i64 %37, %39
%41 = call i32 @strncpy(i8* %34, i8* %35, i64 %40)
%42 = load i8*, i8** %5
%43 = load i8*, i8** %4
%44 = call i64 @strlen(i8* %43)
%45 = load i8*, i8** %6
%46 = call i64 @strlen(i8* %45)
%47 = sub i64 %44, %46
%48 = getelementptr inbounds i8, i8* %42, i64 %47
store i8 0, i8* %48
br label %49
49: ; preds = %33, %3
ret void
}

LLVM IR (-O2):
@__const.divide_dir.tok = [3 x i8] c"\\/\00"
@.str = [1 x i8] zeroinitializer
define void @divide_dir(i8* %0, i8* %1, i8* %2) {
%4 = alloca [3 x i8]
%5 = alloca [40 x i8]
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcpy(i8* %2, i8* %0)
%11 = call i8* @strtok(i8* %7, i8* %6)
%12 = icmp eq i8* %11, null
br i1 %12, label %30, label %13
13: ; preds = %3
%14 = call i8* @strtok(i8* null, i8* %6)
%15 = icmp eq i8* %14, null
br i1 %15, label %21, label %16
16: ; preds = %13, %16
%17 = phi i8* [ %19, %16 ], [ %14, %13 ]
%18 = call i32 @strcpy(i8* %2, i8* %17)
%19 = call i8* @strtok(i8* null, i8* %6)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %16
21: ; preds = %16, %13
%22 = call i64 @strlen(i8* dereferenceable(1) %0)
%23 = call i64 @strlen(i8* dereferenceable(1) %2)
%24 = sub i64 %22, %23
%25 = call i32 @strncpy(i8* %1, i8* %0, i64 %24)
%26 = call i64 @strlen(i8* dereferenceable(1) %0)
%27 = call i64 @strlen(i8* dereferenceable(1) %2)
%28 = sub i64 %26, %27
%29 = getelementptr inbounds i8, i8* %1, i64 %28
store i8 0, i8* %29
br label %30
30: ; preds = %21, %3
ret void
}