#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*/ PR_SET_NAME;
char *getenv(char *);
int getpid();
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ prctl(int /*<<< orphan*/, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int sscanf(char *, char *, char *, int *, char *, int *, int *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchrnul(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ unsetenv(char *);
void _bossname_init() {
  char *keep_vars = getenv("BOSSNAME_KEEPVARS");
  int keep = keep_vars && *keep_vars;
  char *entry = getenv("BOSS_CHILD");
  if (entry) {
    int dlen = strlen(entry);
    char cfgpath[dlen + 1];
    char pname[dlen + 1];
    int bosspid;
    int childpid;
    int instance_index = -1;
    if (sscanf(entry, "%[^,],%d,%[^,],%d,%d", cfgpath, &bosspid, pname,
               &childpid, &instance_index) >= 4 &&
        childpid == getpid()) {
      char *name = getenv("BOSSNAME_OVERRIDE");
      if (!name)
        name = pname;
      prctl(PR_SET_NAME, name);
    }
  } else {
    char *name = getenv("BOSSNAME_OVERRIDE");
    if (name)
      prctl(PR_SET_NAME, name);
  }
  if (keep)
    return;
  unsetenv("BOSS_CHILD");
  unsetenv("BOSSNAME_OVERRIDE");
  char *preload = getenv("LD_PRELOAD");
  if (preload) {
    char *start = preload;
    while (1) {
      char *colon = strchrnul(start, ':');
      char *slash = colon;
      for (; slash > start && *slash != '/'; --slash)
        ;
      if (*slash == '/')
        ++slash;
      if (colon - slash >= 14 && !strncmp("libbossname.so", slash, 14)) {
        if (start == preload && !*colon) {
          unsetenv("LD_PRELOAD");
        } else {
          char newpreload[strlen(preload)];
          memcpy(newpreload, preload, start - preload);
          newpreload[start - preload] = 0;
          if (*colon) {
            strcat(newpreload, colon + 1);
          }
          setenv("LD_PRELOAD", newpreload, 1);
        }
        break;
      }
      if (!*colon)
        break;
      start = colon + 1;
    }
  }
}


x86 assembly (clang, -O0):
<_bossname_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    0xe3e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x89(%rbp)
je     11f1 <_bossname_init+0x41>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
lea    0xe0c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     130c <_bossname_init+0x15c>
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,-0x98(%rbp)
mov    %r8,%rsp
mov    %rax,-0x38(%rbp)
movl   $0xffffffff,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd9b(%rip),%rsi
lea    -0x3c(%rbp),%rcx
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   10b0 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x4,%eax
jl     1300 <_bossname_init+0x150>
mov    -0x40(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    $0x0,%al
call   1070 <getpid@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cmp    %ecx,%eax
jne    1300 <_bossname_init+0x150>
lea    0xd63(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12ee <_bossname_init+0x13e>
mov    -0x98(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rsi
call   10a0 <prctl@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
jmp    133e <_bossname_init+0x18e>
lea    0xd1f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1339 <_bossname_init+0x189>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
call   10a0 <prctl@plt>
jmp    133e <_bossname_init+0x18e>
cmpl   $0x0,-0xc(%rbp)
je     134d <_bossname_init+0x19d>
jmp    153c <_bossname_init+0x38c>
lea    0xcbe(%rip),%rdi
call   10c0 <unsetenv@plt>
lea    0xcd2(%rip),%rdi
call   10c0 <unsetenv@plt>
lea    0xcd8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     153c <_bossname_init+0x38c>
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchrnul@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rcx
xor    %eax,%eax
cmp    -0x68(%rbp),%rcx
mov    %al,-0x9d(%rbp)
jbe    13cb <_bossname_init+0x21b>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x9d(%rbp)
mov    -0x9d(%rbp),%al
test   $0x1,%al
jne    13de <_bossname_init+0x22e>
jmp    13f4 <_bossname_init+0x244>
jmp    13e3 <_bossname_init+0x233>
mov    -0x78(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x78(%rbp)
jmp    13a2 <_bossname_init+0x1f2>
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1410 <_bossname_init+0x260>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x78(%rbp),%rcx
sub    %rcx,%rax
cmp    $0xe,%rax
jl     1514 <_bossname_init+0x364>
mov    -0x78(%rbp),%rsi
lea    0xc1f(%rip),%rdi
mov    $0xe,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1514 <_bossname_init+0x364>
mov    -0x68(%rbp),%rax
cmp    -0x60(%rbp),%rax
jne    146f <_bossname_init+0x2bf>
mov    -0x70(%rbp),%rax
cmpb   $0x0,(%rax)
jne    146f <_bossname_init+0x2bf>
lea    0xbdf(%rip),%rdi
call   10c0 <unsetenv@plt>
jmp    150f <_bossname_init+0x35f>
mov    -0x60(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xa8(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1090 <memcpy@plt>
mov    -0xa8(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    -0x60(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
cmpb   $0x0,(%rax)
je     14f0 <_bossname_init+0x340>
mov    -0xa8(%rbp),%rdi
mov    -0x70(%rbp),%rsi
add    $0x1,%rsi
call   10d0 <strcat@plt>
mov    -0xa8(%rbp),%rsi
lea    0xb46(%rip),%rdi
mov    $0x1,%edx
call   1060 <setenv@plt>
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
jmp    1537 <_bossname_init+0x387>
mov    -0x70(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1526 <_bossname_init+0x376>
jmp    1537 <_bossname_init+0x387>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1388 <_bossname_init+0x1d8>
jmp    153c <_bossname_init+0x38c>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_bossname_init>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe38(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11db <_bossname_init+0x2b>
cmpb   $0x0,(%rax)
setne  %r15b
jmp    11de <_bossname_init+0x2e>
xor    %r15d,%r15d
lea    0xe2d(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1288 <_bossname_init+0xd8>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <strlen@plt>
mov    %rsp,%r12
add    $0x1,%eax
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
movl   $0xffffffff,-0x2c(%rbp)
sub    $0x8,%rsp
lea    -0x2c(%rbp),%rax
lea    0xde9(%rip),%rsi
lea    -0x34(%rbp),%rcx
lea    -0x30(%rbp),%r9
mov    %rbx,%rdi
mov    %r14,%r8
push   %rax
call   10b0 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x4,%eax
jl     1283 <_bossname_init+0xd3>
mov    -0x30(%rbp),%ebx
xor    %eax,%eax
call   1070 <getpid@plt>
cmp    %eax,%ebx
jne    1283 <_bossname_init+0xd3>
lea    0xdcc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
cmovne %rax,%r14
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   10a0 <prctl@plt>
mov    %r12,%rsp
jmp    12aa <_bossname_init+0xfa>
lea    0xda3(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     12aa <_bossname_init+0xfa>
mov    0x2d40(%rip),%rcx
mov    (%rcx),%edi
mov    %rax,%rsi
call   10a0 <prctl@plt>
test   %r15b,%r15b
jne    13c1 <_bossname_init+0x211>
lea    0xd58(%rip),%rdi
call   10c0 <unsetenv@plt>
lea    0xd6c(%rip),%rdi
call   10c0 <unsetenv@plt>
lea    0xd72(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13c1 <_bossname_init+0x211>
mov    %rax,%r14
lea    0xd65(%rip),%r12
mov    %rax,%rbx
jmp    1301 <_bossname_init+0x151>
nop
mov    %r15,%rbx
add    $0x1,%rbx
cmpb   $0x0,(%r15)
je     13c1 <_bossname_init+0x211>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1050 <strchrnul@plt>
mov    %rax,%r15
cmp    %rbx,%rax
jbe    1331 <_bossname_init+0x181>
mov    %r15,%rax
nopl   0x0(%rax)
cmpb   $0x2f,(%rax)
je     1331 <_bossname_init+0x181>
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
ja     1320 <_bossname_init+0x170>
mov    %rbx,%rax
xor    %esi,%esi
cmpb   $0x2f,(%rax)
sete   %sil
add    %rax,%rsi
mov    %r15,%rax
sub    %rsi,%rax
cmp    $0xe,%rax
jl     12f0 <_bossname_init+0x140>
mov    %r12,%rdi
mov    $0xe,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    12f0 <_bossname_init+0x140>
sub    %r14,%rbx
jne    1365 <_bossname_init+0x1b5>
cmpb   $0x0,(%r15)
je     13d0 <_bossname_init+0x220>
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rsp,%r13
mov    %eax,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1090 <memcpy@plt>
movb   $0x0,(%rbx,%r12,1)
cmpb   $0x0,(%r15)
je     13aa <_bossname_init+0x1fa>
add    $0x1,%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   10d0 <strcat@plt>
lea    0xc93(%rip),%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1060 <setenv@plt>
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc6d(%rip),%rdi
call   10c0 <unsetenv@plt>
jmp    13c1 <_bossname_init+0x211>

LLVM IR (-O0):
@.str = [18 x i8] c"BOSSNAME_KEEPVARS\00"
@.str.1 = [11 x i8] c"BOSS_CHILD\00"
@.str.2 = [21 x i8] c"%[^,],%d,%[^,],%d,%d\00"
@.str.3 = [18 x i8] c"BOSSNAME_OVERRIDE\00"
@PR_SET_NAME = global i32 0
@.str.4 = [11 x i8] c"LD_PRELOAD\00"
@.str.5 = [15 x i8] c"libbossname.so\00"
define void @_bossname_init() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i64
%19 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %1
%20 = load i8*, i8** %1
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %0
%23 = load i8*, i8** %1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br label %27
27: ; preds = %22, %0
%28 = phi i1 [ false, %0 ], [ %26, %22 ]
%29 = zext i1 %28 to i32
store i32 %29, i32* %2
%30 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %30, i8** %3
%31 = load i8*, i8** %3
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %63
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i32 @strlen(i8* %34)
store i32 %35, i32* %4
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
%38 = zext i32 %37 to i64
%39 = call i8* @llvm.stacksave()
store i8* %39, i8** %5
%40 = alloca i8, i64 %38
store i64 %38, i64* %6
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
%43 = zext i32 %42 to i64
%44 = alloca i8, i64 %43
store i64 %43, i64* %7
store i32 -1, i32* %10
%45 = load i8*, i8** %3
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32* %8, i8* %44, i32* %9, i32* %10)
%47 = icmp sge i32 %46, 4
br i1 %47, label %48, label %61
48: ; preds = %33
%49 = load i32, i32* %9
%50 = call i32 (...) @getpid()
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %61
52: ; preds = %48
%53 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i8* %53, i8** %11
%54 = load i8*, i8** %11
%55 = icmp ne i8* %54, null
br i1 %55, label %57, label %56
56: ; preds = %52
store i8* %44, i8** %11
br label %57
57: ; preds = %56, %52
%58 = load i32, i32* @PR_SET_NAME
%59 = load i8*, i8** %11
%60 = call i32 @prctl(i32 %58, i8* %59)
br label %61
61: ; preds = %57, %48, %33
%62 = load i8*, i8** %5
br label %72
63: ; preds = %27
%64 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i8* %64, i8** %12
%65 = load i8*, i8** %12
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = load i32, i32* @PR_SET_NAME
%69 = load i8*, i8** %12
%70 = call i32 @prctl(i32 %68, i8* %69)
br label %71
71: ; preds = %67, %63
br label %72
72: ; preds = %71, %61
%73 = load i32, i32* %2
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %72
br label %172
76: ; preds = %72
%77 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%78 = call i32 @unsetenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%79 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i8* %79, i8** %13
%80 = load i8*, i8** %13
%81 = icmp ne i8* %80, null
br i1 %81, label %82, label %172
82: ; preds = %76
%83 = load i8*, i8** %13
store i8* %83, i8** %14
br label %84
84: ; preds = %82, %168
%85 = load i8*, i8** %14
%86 = call i8* @strchrnul(i8* %85, i8 signext 58)
store i8* %86, i8** %15
%87 = load i8*, i8** %15
store i8* %87, i8** %16
br label %88
88: ; preds = %100, %84
%89 = load i8*, i8** %16
%90 = load i8*, i8** %14
%91 = icmp ugt i8* %89, %90
br i1 %91, label %92, label %97
92: ; preds = %88
%93 = load i8*, i8** %16
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %95, 47
br label %97
97: ; preds = %92, %88
%98 = phi i1 [ false, %88 ], [ %96, %92 ]
br i1 %98, label %99, label %103
99: ; preds = %97
br label %100
100: ; preds = %99
%101 = load i8*, i8** %16
%102 = getelementptr inbounds i8, i8* %101, i32 -1
store i8* %102, i8** %16
br label %88
103: ; preds = %97
%104 = load i8*, i8** %16
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 47
br i1 %107, label %108, label %111
108: ; preds = %103
%109 = load i8*, i8** %16
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %16
br label %111
111: ; preds = %108, %103
%112 = load i8*, i8** %15
%113 = load i8*, i8** %16
%114 = ptrtoint i8* %112 to i64
%115 = ptrtoint i8* %113 to i64
%116 = sub i64 %114, %115
%117 = icmp sge i64 %116, 14
br i1 %117, label %118, label %163
118: ; preds = %111
%119 = load i8*, i8** %16
%120 = call i32 @strncmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %119, i32 14)
%121 = icmp ne i32 %120, 0
br i1 %121, label %163, label %122
122: ; preds = %118
%123 = load i8*, i8** %14
%124 = load i8*, i8** %13
%125 = icmp eq i8* %123, %124
br i1 %125, label %126, label %132
126: ; preds = %122
%127 = load i8*, i8** %15
%128 = load i8, i8* %127
%129 = icmp ne i8 %128, 0
br i1 %129, label %132, label %130
130: ; preds = %126
%131 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %162
132: ; preds = %126, %122
%133 = load i8*, i8** %13
%134 = call i32 @strlen(i8* %133)
%135 = zext i32 %134 to i64
%136 = call i8* @llvm.stacksave()
store i8* %136, i8** %17
%137 = alloca i8, i64 %135
store i64 %135, i64* %18
%138 = load i8*, i8** %13
%139 = load i8*, i8** %14
%140 = load i8*, i8** %13
%141 = ptrtoint i8* %139 to i64
%142 = ptrtoint i8* %140 to i64
%143 = sub i64 %141, %142
%144 = trunc i64 %143 to i32
%145 = call i32 @memcpy(i8* %137, i8* %138, i32 %144)
%146 = load i8*, i8** %14
%147 = load i8*, i8** %13
%148 = ptrtoint i8* %146 to i64
%149 = ptrtoint i8* %147 to i64
%150 = sub i64 %148, %149
%151 = getelementptr inbounds i8, i8* %137, i64 %150
store i8 0, i8* %151
%152 = load i8*, i8** %15
%153 = load i8, i8* %152
%154 = icmp ne i8 %153, 0
br i1 %154, label %155, label %159
155: ; preds = %132
%156 = load i8*, i8** %15
%157 = getelementptr inbounds i8, i8* %156, i64 1
%158 = call i32 @strcat(i8* %137, i8* %157)
br label %159
159: ; preds = %155, %132
%160 = call i32 @setenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %137, i32 1)
%161 = load i8*, i8** %17
br label %162
162: ; preds = %159, %130
br label %171
163: ; preds = %118, %111
%164 = load i8*, i8** %15
%165 = load i8, i8* %164
%166 = icmp ne i8 %165, 0
br i1 %166, label %168, label %167
167: ; preds = %163
br label %171
168: ; preds = %163
%169 = load i8*, i8** %15
%170 = getelementptr inbounds i8, i8* %169, i64 1
store i8* %170, i8** %14
br label %84
171: ; preds = %167, %162
br label %172
172: ; preds = %75, %171, %76
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"BOSSNAME_KEEPVARS\00"
@.str.1 = [11 x i8] c"BOSS_CHILD\00"
@.str.2 = [21 x i8] c"%[^,],%d,%[^,],%d,%d\00"
@.str.3 = [18 x i8] c"BOSSNAME_OVERRIDE\00"
@PR_SET_NAME = global i32 0
@.str.4 = [11 x i8] c"LD_PRELOAD\00"
@.str.5 = [15 x i8] c"libbossname.so\00"
define void @_bossname_init() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = load i8, i8* %4
%8 = icmp ne i8 %7, 0
br label %9
9: ; preds = %6, %0
%10 = phi i1 [ false, %0 ], [ %8, %6 ]
%11 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %36, label %13
13: ; preds = %9
%14 = tail call i32 @strlen(i8* %11)
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = tail call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = alloca i8, i64 %16
%20 = bitcast i32* %1 to i8*
%21 = bitcast i32* %2 to i8*
%22 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%23 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32* %1, i8* %19, i32* %2, i32* %3)
%24 = icmp sgt i32 %23, 3
br i1 %24, label %25, label %35
25: ; preds = %13
%26 = load i32, i32* %2
%27 = call i32 (...) @getpid()
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i8* %30, null
%32 = select i1 %31, i8* %19, i8* %30
%33 = load i32, i32* @PR_SET_NAME
%34 = call i32 @prctl(i32 %33, i8* %32)
br label %35
35: ; preds = %29, %25, %13
br label %42
36: ; preds = %9
%37 = tail call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i8* %37, null
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* @PR_SET_NAME
%41 = tail call i32 @prctl(i32 %40, i8* %37)
br label %42
42: ; preds = %36, %39, %35
br i1 %10, label %105, label %43
43: ; preds = %42
%44 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @unsetenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%46 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i8* %46, null
br i1 %47, label %105, label %48
48: ; preds = %43, %101
%49 = phi i8* [ %104, %101 ], [ %46, %43 ]
%50 = call i8* @strchrnul(i8* %49, i8 signext 58)
%51 = ptrtoint i8* %50 to i64
%52 = icmp ugt i8* %50, %49
br i1 %52, label %53, label %64
53: ; preds = %48
%54 = ptrtoint i8* %49 to i64
%55 = sub i64 %54, %51
%56 = getelementptr i8, i8* %50, i64 %55
br label %57
57: ; preds = %53, %61
%58 = phi i8* [ %62, %61 ], [ %50, %53 ]
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 47
br i1 %60, label %64, label %61
61: ; preds = %57
%62 = getelementptr inbounds i8, i8* %58, i64 -1
%63 = icmp ugt i8* %62, %49
br i1 %63, label %57, label %64
64: ; preds = %57, %61, %48
%65 = phi i8* [ %50, %48 ], [ %56, %61 ], [ %58, %57 ]
%66 = load i8, i8* %65
%67 = icmp eq i8 %66, 47
%68 = zext i1 %67 to i64
%69 = getelementptr i8, i8* %65, i64 %68
%70 = ptrtoint i8* %69 to i64
%71 = sub i64 %51, %70
%72 = icmp sgt i64 %71, 13
br i1 %72, label %73, label %101
73: ; preds = %64
%74 = call i32 @strncmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %69, i32 14)
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %101
76: ; preds = %73
%77 = ptrtoint i8* %49 to i64
%78 = icmp eq i8* %49, %46
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = load i8, i8* %50
%81 = icmp eq i8 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %105
84: ; preds = %79, %76
%85 = call i32 @strlen(i8* %46)
%86 = zext i32 %85 to i64
%87 = call i8* @llvm.stacksave()
%88 = alloca i8, i64 %86
%89 = ptrtoint i8* %46 to i64
%90 = sub i64 %77, %89
%91 = trunc i64 %90 to i32
%92 = call i32 @memcpy(i8* %88, i8* %46, i32 %91)
%93 = getelementptr inbounds i8, i8* %88, i64 %90
store i8 0, i8* %93
%94 = load i8, i8* %50
%95 = icmp eq i8 %94, 0
br i1 %95, label %99, label %96
96: ; preds = %84
%97 = getelementptr inbounds i8, i8* %50, i64 1
%98 = call i32 @strcat(i8* %88, i8* %97)
br label %99
99: ; preds = %96, %84
%100 = call i32 @setenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %88, i32 1)
br label %105
101: ; preds = %73, %64
%102 = load i8, i8* %50
%103 = icmp eq i8 %102, 0
%104 = getelementptr inbounds i8, i8* %50, i64 1
br i1 %103, label %105, label %48
105: ; preds = %101, %82, %99, %43, %42
ret void
}