#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 *fizmo_malloc(scalar_t__);
int /*<<< orphan*/ free(char *);
char *get_configuration_value(char *);
int set_configuration_value(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int append_path_value(char *key, char *value_to_append) {
  char *str, *str2;
  int result;
  if ((str = get_configuration_value(key)) != NULL) {
    str2 = fizmo_malloc(strlen(str) + strlen(value_to_append) + 2);
    strcpy(str2, str);
    strcat(str2, ":");
    strcat(str2, value_to_append);
    ;
    ;
    result = set_configuration_value(key, str2);
    free(str2);
    return result;
  } else
    return set_configuration_value(key, value_to_append);
}


x86 assembly (clang, -O0):
<append_path_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <get_configuration_value@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     120f <append_path_value+0x9f>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1080 <fizmo_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <set_configuration_value@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121f <append_path_value+0xaf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <set_configuration_value@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_path_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1070 <get_configuration_value@plt>
test   %rax,%rax
je     11fc <append_path_value+0x8c>
mov    %rax,%r13
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%r12,%rax,1),%rdi
add    $0x2,%rdi
call   1080 <fizmo_malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <set_configuration_value@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <set_configuration_value@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define i32 @append_path_value(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i8* @get_configuration_value(i8* %9)
store i8* %10, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %34
12: ; preds = %2
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %14, %16
%18 = add nsw i64 %17, 2
%19 = call i8* @fizmo_malloc(i64 %18)
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = load i8*, i8** %6
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %7
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %7
%26 = load i8*, i8** %5
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = load i8*, i8** %4
%29 = load i8*, i8** %7
%30 = call i32 @set_configuration_value(i8* %28, i8* %29)
store i32 %30, i32* %8
%31 = load i8*, i8** %7
%32 = call i32 @free(i8* %31)
%33 = load i32, i32* %8
store i32 %33, i32* %3
br label %38
34: ; preds = %2
%35 = load i8*, i8** %4
%36 = load i8*, i8** %5
%37 = call i32 @set_configuration_value(i8* %35, i8* %36)
store i32 %37, i32* %3
br label %38
38: ; preds = %34, %12
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define i32 @append_path_value(i8* %0, i8* %1) {
%3 = tail call i8* @get_configuration_value(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = tail call i64 @strlen(i8* %3)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = add i64 %6, 2
%9 = add i64 %8, %7
%10 = tail call i8* @fizmo_malloc(i64 %9)
%11 = tail call i32 @strcpy(i8* %10, i8* %3)
%12 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %10, i8* %1)
%14 = tail call i32 @set_configuration_value(i8* %0, i8* %10)
%15 = tail call i32 @free(i8* %10)
br label %18
16: ; preds = %2
%17 = tail call i32 @set_configuration_value(i8* %0, i8* %1)
br label %18
18: ; preds = %16, %5
%19 = phi i32 [ %14, %5 ], [ %17, %16 ]
ret i32 %19
}