#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*/ efree(char *);
scalar_t__ emalloc(scalar_t__);
char *extract_colon_unit(char const *, int *);
scalar_t__ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *get_next_path_element(const char *path_list, int *path_index_pointer) {
  char *path;
  path = extract_colon_unit(path_list, path_index_pointer);
  if (!path)
    return (path);
  if (!*path) {
    efree(path);
    path = (char *)strcpy((char *)emalloc(1 + strlen(".")), ("."));
  }
  return (path);
}


x86 assembly (clang, -O0):
<get_next_path_element>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <extract_colon_unit@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1189 <get_next_path_element+0x39>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d2 <get_next_path_element+0x82>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11ca <get_next_path_element+0x7a>
mov    -0x20(%rbp),%rdi
call   1060 <efree@plt>
lea    0xe5a(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <emalloc@plt>
mov    %rax,%rdi
lea    0xe3f(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_path_element>:
push   %rax
call   1040 <extract_colon_unit@plt>
test   %rax,%rax
je     1152 <get_next_path_element+0x12>
cmpb   $0x0,(%rax)
je     1156 <get_next_path_element+0x16>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
mov    %rax,%rdi
call   1050 <efree@plt>
mov    $0x2,%edi
call   1060 <emalloc@plt>
lea    0xe91(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
pop    %rcx
ret

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

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