#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 */
typedef int /*<<< orphan*/ ruta;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *strtok(char *, char *);
int extraer_camino(const char *camino, char *inicial, char *final) {
  int tipo;
  char ruta[strlen(camino)];
  memset(ruta, 0, sizeof(ruta));
  strcpy(ruta, camino);
  char *PrimeraBarra;
  PrimeraBarra = strchr(ruta, '/') + 1;
  char *segundaBarra;
  segundaBarra = strchr(PrimeraBarra, '/');
  if (segundaBarra == NULL) {
    strcpy(inicial, PrimeraBarra);
    *final = '\0';
    tipo = 1;
  } else {
    strcpy(final, segundaBarra);
    strcpy(inicial, strtok(PrimeraBarra, "/"));
    tipo = 0;
  }
  return tipo;
}


x86 assembly (clang, -O0):
<extraer_camino>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x48(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11fb <extraer_camino+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    1233 <extraer_camino+0xe3>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1070 <strtok@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extraer_camino>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
xor    %r12d,%r12d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e6 <extraer_camino+0x96>
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0xe2f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    11fb <extraer_camino+0xab>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,(%r15)
mov    $0x1,%r12d
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i32 @extraer_camino(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %8
%16 = alloca i8, i64 %14
store i64 %14, i64* %9
%17 = trunc i64 %14 to i32
%18 = call i32 @memset(i8* %16, i32 0, i32 %17)
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %16, i8* %19)
%21 = call i8* @strchr(i8* %16, i8 signext 47)
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %10
%23 = load i8*, i8** %10
%24 = call i8* @strchr(i8* %23, i8 signext 47)
store i8* %24, i8** %11
%25 = load i8*, i8** %11
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %32
27: ; preds = %3
%28 = load i8*, i8** %5
%29 = load i8*, i8** %10
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = load i8*, i8** %6
store i8 0, i8* %31
store i32 1, i32* %7
br label %40
32: ; preds = %3
%33 = load i8*, i8** %6
%34 = load i8*, i8** %11
%35 = call i32 @strcpy(i8* %33, i8* %34)
%36 = load i8*, i8** %5
%37 = load i8*, i8** %10
%38 = call i8* @strtok(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @strcpy(i8* %36, i8* %38)
store i32 0, i32* %7
br label %40
40: ; preds = %32, %27
%41 = load i32, i32* %7
%42 = load i8*, i8** %8
ret i32 %41
}

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