#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*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int create_path_file_name(char *path, const int path_max, const char *paths,
                          const int paths_len, const char *file_name,
                          const int file_name_len) {
  int len;
  if (paths_len < 1)
    return 0;
  for (len = 0; len < paths_len; len++)
    if (paths[len] == ':')
      break;
  if (len >= path_max - (file_name_len + 1))
    return 0;
  {}
  memcpy(path, paths, len);
  path[len] = '/';
  strcpy(&path[len + 1], file_name);
  return len;
}


x86 assembly (clang, -O0):
<create_path_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
cmpl   $0x1,-0x24(%rbp)
jge    1154 <create_path_file_name+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <create_path_file_name+0xd0>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1194 <create_path_file_name+0x74>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1181 <create_path_file_name+0x61>
jmp    1194 <create_path_file_name+0x74>
jmp    1186 <create_path_file_name+0x66>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    115b <create_path_file_name+0x3b>
mov    -0x38(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    -0x34(%rbp),%edx
add    $0x1,%edx
sub    %edx,%ecx
cmp    %ecx,%eax
jl     11b6 <create_path_file_name+0x96>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <create_path_file_name+0xd0>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_path_file_name>:
push   %r15
push   %r14
push   %rbx
test   %ecx,%ecx
jle    1186 <create_path_file_name+0x66>
mov    %r8,%r14
mov    %rdi,%r15
mov    %ecx,%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x3a,(%rdx,%rbx,1)
je     1151 <create_path_file_name+0x31>
add    $0x1,%rbx
cmp    %rbx,%rax
jne    1140 <create_path_file_name+0x20>
mov    %eax,%ebx
not    %r9d
add    %esi,%r9d
xor    %eax,%eax
cmp    %r9d,%ebx
jge    1188 <create_path_file_name+0x68>
mov    %r15,%rdi
mov    %rdx,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
mov    %ebx,%eax
movb   $0x2f,(%r15,%rax,1)
lea    (%r15,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %ebx,%eax
jmp    1188 <create_path_file_name+0x68>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @create_path_file_name(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %18
17: ; preds = %6
store i32 0, i32* %7
br label %61
18: ; preds = %6
store i32 0, i32* %14
br label %19
19: ; preds = %33, %18
%20 = load i32, i32* %14
%21 = load i32, i32* %11
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i8*, i8** %10
%25 = load i32, i32* %14
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 58
br i1 %30, label %31, label %32
31: ; preds = %23
br label %36
32: ; preds = %23
br label %33
33: ; preds = %32
%34 = load i32, i32* %14
%35 = add nsw i32 %34, 1
store i32 %35, i32* %14
br label %19
36: ; preds = %31, %19
%37 = load i32, i32* %14
%38 = load i32, i32* %9
%39 = load i32, i32* %13
%40 = add nsw i32 %39, 1
%41 = sub nsw i32 %38, %40
%42 = icmp sge i32 %37, %41
br i1 %42, label %43, label %44
43: ; preds = %36
store i32 0, i32* %7
br label %61
44: ; preds = %36
%45 = load i8*, i8** %8
%46 = load i8*, i8** %10
%47 = load i32, i32* %14
%48 = call i32 @memcpy(i8* %45, i8* %46, i32 %47)
%49 = load i8*, i8** %8
%50 = load i32, i32* %14
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 47, i8* %52
%53 = load i8*, i8** %8
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = load i8*, i8** %12
%59 = call i32 @strcpy(i8* %57, i8* %58)
%60 = load i32, i32* %14
store i32 %60, i32* %7
br label %61
61: ; preds = %44, %43, %17
%62 = load i32, i32* %7
ret i32 %62
}

LLVM IR (-O2):
define i32 @create_path_file_name(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = icmp slt i32 %3, 1
br i1 %7, label %33, label %8
8: ; preds = %6
%9 = zext i32 %3 to i64
br label %10
10: ; preds = %8, %15
%11 = phi i64 [ 0, %8 ], [ %16, %15 ]
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 58
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %20, label %10
18: ; preds = %10
%19 = trunc i64 %11 to i32
br label %20
20: ; preds = %15, %18
%21 = phi i32 [ %19, %18 ], [ %3, %15 ]
%22 = xor i32 %5, -1
%23 = add i32 %22, %1
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = tail call i32 @memcpy(i8* %0, i8* %2, i32 %21)
%27 = zext i32 %21 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 47, i8* %28
%29 = add nuw nsw i32 %21, 1
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = tail call i32 @strcpy(i8* %31, i8* %4)
br label %33
33: ; preds = %20, %6, %25
%34 = phi i32 [ %21, %25 ], [ 0, %6 ], [ 0, %20 ]
ret i32 %34
}