#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 */
char *appaserver_parameter_file_get_appaserver_mount_point();
char *application_relative_source_directory(char *);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ set_path(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char timlib_get_delimiter(char *);
void add_relative_source_directory_to_path(char *application_name) {
  char *appaserver_mount_point;
  char *relative_source_directory;
  char piece_buffer[128];
  char bin_path[128];
  int index;
  char delimiter;
  appaserver_mount_point =
      appaserver_parameter_file_get_appaserver_mount_point();
  relative_source_directory =
      application_relative_source_directory(application_name);
  if (!(delimiter = timlib_get_delimiter(relative_source_directory))) {
    delimiter = ';';
  }
  for (index = 0;
       piece(piece_buffer, delimiter, relative_source_directory, index);
       index++) {
    sprintf(bin_path, "%s/%s", appaserver_mount_point, piece_buffer);
    set_path(bin_path);
  }
}


x86 assembly (clang, -O0):
<add_relative_source_directory_to_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <appaserver_parameter_file_get_appaserver_mount_point@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <application_relative_source_directory@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <timlib_get_delimiter@plt>
mov    %al,-0x125(%rbp)
cmp    $0x0,%al
jne    11a5 <add_relative_source_directory_to_path+0x45>
movb   $0x3b,-0x125(%rbp)
movl   $0x0,-0x124(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x125(%rbp),%al
mov    -0x18(%rbp),%rdx
mov    -0x124(%rbp),%ecx
movsbl %al,%esi
call   1070 <piece@plt>
cmp    $0x0,%rax
je     1216 <add_relative_source_directory_to_path+0xb6>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0xa0(%rbp),%rcx
lea    0xe0f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1080 <set_path@plt>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11af <add_relative_source_directory_to_path+0x4f>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_relative_source_directory_to_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <appaserver_parameter_file_get_appaserver_mount_point@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <application_relative_source_directory@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <timlib_get_delimiter@plt>
test   %al,%al
movzbl %al,%eax
mov    $0x3b,%ecx
cmovne %eax,%ecx
movsbl %cl,%r13d
mov    %rsp,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1070 <piece@plt>
test   %rax,%rax
je     1205 <add_relative_source_directory_to_path+0xa5>
mov    $0x1,%ebx
lea    0x80(%rsp),%rbp
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0xe26(%rip),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <set_path@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1070 <piece@plt>
add    $0x1,%ebx
test   %rax,%rax
jne    11d0 <add_relative_source_directory_to_path+0x70>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
define void @add_relative_source_directory_to_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %2
%9 = call i8* (...) @appaserver_parameter_file_get_appaserver_mount_point()
store i8* %9, i8** %3
%10 = load i8*, i8** %2
%11 = call i8* @application_relative_source_directory(i8* %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = call signext i8 @timlib_get_delimiter(i8* %12)
store i8 %13, i8* %8
%14 = icmp ne i8 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %1
store i8 59, i8* %8
br label %16
16: ; preds = %15, %1
store i32 0, i32* %7
br label %17
17: ; preds = %31, %16
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%19 = load i8, i8* %8
%20 = load i8*, i8** %4
%21 = load i32, i32* %7
%22 = call i64 @piece(i8* %18, i8 signext %19, i8* %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %17
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%28 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%30 = call i32 @set_path(i8* %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %17
34: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define void @add_relative_source_directory_to_path(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = tail call i8* (...) @appaserver_parameter_file_get_appaserver_mount_point()
%7 = tail call i8* @application_relative_source_directory(i8* %0)
%8 = tail call signext i8 @timlib_get_delimiter(i8* %7)
%9 = icmp eq i8 %8, 0
%10 = select i1 %9, i8 59, i8 %8
%11 = call i64 @piece(i8* %4, i8 signext %10, i8* %7, i32 0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %1, %13
%14 = phi i32 [ %17, %13 ], [ 0, %1 ]
%15 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %4)
%16 = call i32 @set_path(i8* %5)
%17 = add nuw nsw i32 %14, 1
%18 = call i64 @piece(i8* %4, i8 signext %10, i8* %7, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %13, %1
ret void
}