#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ get_element_from_path(char *);
int /*<<< orphan*/ memcpy(char *, char *, scalar_t__);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
char *get_father_element(char *path_comp) {
  char *ret = (char *)calloc(256, sizeof(char));
  char element[256];
  strcpy(element, get_element_from_path(path_comp));
  memcpy(ret, path_comp, strlen(path_comp) - strlen(element) - 1);
  return ret;
}


x86 assembly (clang, -O0):
<get_father_element>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <get_element_from_path@plt>
mov    -0x130(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x128(%rbp),%rdx
mov    -0x120(%rbp),%rdi
mov    -0x118(%rbp),%rsi
sub    %rax,%rdx
sub    $0x1,%rdx
call   1070 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_father_element>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r12
mov    $0x100,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1060 <get_element_from_path@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
not    %rax
add    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <memcpy@plt>
mov    %r14,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @get_father_element(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [256 x i8]
store i8* %0, i8** %2
%5 = call i64 @calloc(i32 256, i32 1)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @get_element_from_path(i8* %8)
%10 = call i32 @strcpy(i8* %7, i32 %9)
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = load i8*, i8** %2
%14 = call i64 @strlen(i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = sub nsw i64 %14, %16
%18 = sub nsw i64 %17, 1
%19 = call i32 @memcpy(i8* %11, i8* %12, i64 %18)
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
define i8* @get_father_element(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i64 @calloc(i32 256, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @get_element_from_path(i8* %0)
%7 = call i32 @strcpy(i8* %5, i32 %6)
%8 = call i64 @strlen(i8* dereferenceable(1) %0)
%9 = call i64 @strlen(i8* %5)
%10 = xor i64 %9, -1
%11 = add i64 %8, %10
%12 = call i32 @memcpy(i8* %4, i8* %0, i64 %11)
ret i8* %4
}