#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*/ free(char *);
int /*<<< orphan*/ getenv(char const *);
int /*<<< orphan*/ lt_debugprintf(char *, int, char *, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
char *lt_extend_str(int /*<<< orphan*/, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ lt_setenv(char const *, char *);
int /*<<< orphan*/ nonnull(char const *);
void lt_update_lib_path(const char *name, const char *value) {
  lt_debugprintf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/ikdekker/stage/refs/heads/"
                 "master/lib/cpputest-3.8/.libs/lt-CppUTestTests.c",
                 687,
                 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
                 nonnull(name), nonnull(value));
  if (name && *name && value && *value) {
    char *new_value = lt_extend_str(getenv(name), value, 0);
    lt_setenv(name, new_value);
    do {
      if (new_value) {
        free(new_value);
        new_value = 0;
      }
    } while (0);
  }
}


x86 assembly (clang, -O0):
<lt_update_lib_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <nonnull@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <nonnull@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%r8d
lea    0xe6e(%rip),%rdi
mov    $0x2af,%esi
lea    0xf07(%rip),%rdx
call   1070 <lt_debugprintf@plt>
cmpq   $0x0,-0x8(%rbp)
je     1226 <lt_update_lib_path+0xc6>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1226 <lt_update_lib_path+0xc6>
cmpq   $0x0,-0x10(%rbp)
je     1226 <lt_update_lib_path+0xc6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1226 <lt_update_lib_path+0xc6>
mov    -0x8(%rbp),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1080 <lt_extend_str@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <lt_setenv@plt>
cmpq   $0x0,-0x18(%rbp)
je     121c <lt_update_lib_path+0xbc>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x18(%rbp)
jmp    1221 <lt_update_lib_path+0xc1>
jmp    1226 <lt_update_lib_path+0xc6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lt_update_lib_path>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <nonnull@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <nonnull@plt>
lea    0xe80(%rip),%rdi
lea    0xf1e(%rip),%rdx
mov    $0x2af,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
call   1070 <lt_debugprintf@plt>
test   %rbx,%rbx
je     11de <lt_update_lib_path+0x7e>
test   %r14,%r14
je     11de <lt_update_lib_path+0x7e>
cmpb   $0x0,(%rbx)
je     11de <lt_update_lib_path+0x7e>
cmpb   $0x0,(%r14)
je     11de <lt_update_lib_path+0x7e>
mov    %rbx,%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1080 <lt_extend_str@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <lt_setenv@plt>
test   %r14,%r14
je     11de <lt_update_lib_path+0x7e>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <free@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ikdekker/stage/refs/heads/master/lib/cpputest-3.8/.libs/lt-CppUTestTests.c\00"
@.str.1 = [56 x i8] c"(lt_update_lib_path) modifying '%s' by prepending '%s'\0A\00"
define void @lt_update_lib_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @nonnull(i8* %6)
%8 = load i8*, i8** %4
%9 = call i32 @nonnull(i8* %8)
%10 = call i32 @lt_debugprintf(i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str, i64 0, i64 0), i32 687, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %9)
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %42
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %42
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %42
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = call i32 @getenv(i8* %27)
%29 = load i8*, i8** %4
%30 = call i8* @lt_extend_str(i32 %28, i8* %29, i32 0)
store i8* %30, i8** %5
%31 = load i8*, i8** %3
%32 = load i8*, i8** %5
%33 = call i32 @lt_setenv(i8* %31, i8* %32)
br label %34
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = call i32 @free(i8* %38)
store i8* null, i8** %5
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41, %21, %18, %13, %2
ret void
}

LLVM IR (-O2):
@.str = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ikdekker/stage/refs/heads/master/lib/cpputest-3.8/.libs/lt-CppUTestTests.c\00"
@.str.1 = [56 x i8] c"(lt_update_lib_path) modifying '%s' by prepending '%s'\0A\00"
define void @lt_update_lib_path(i8* %0, i8* %1) {
%3 = tail call i32 @nonnull(i8* %0)
%4 = tail call i32 @nonnull(i8* %1)
%5 = tail call i32 @lt_debugprintf(i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str, i64 0, i64 0), i32 687, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4)
%6 = icmp eq i8* %0, null
br i1 %6, label %22, label %7
7: ; preds = %2
%8 = load i8, i8* %0
%9 = icmp ne i8 %8, 0
%10 = icmp ne i8* %1, null
%11 = and i1 %10, %9
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = tail call i32 @getenv(i8* %0)
%17 = tail call i8* @lt_extend_str(i32 %16, i8* %1, i32 0)
%18 = tail call i32 @lt_setenv(i8* %0, i8* %17)
%19 = icmp eq i8* %17, null
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = tail call i32 @free(i8* %17)
br label %22
22: ; preds = %15, %20, %12, %7, %2
ret void
}