#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 *basename(char *);
char *dirname(char *);
int /*<<< orphan*/ errno;
int execv(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int readlink(char *, char *, int);
scalar_t__ setenv(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  static char buf[1023 + 1] = {0}, lib[1023 + 1] = {0}, base[1023 + 1] = {0},
                         exe[1023 + 1] = {0}, *ldp = NULL;
  if (readlink("/proc/self/exe", buf, 1023) == -1) {
    fprintf(stderr, "Failed to read path of executable with error: %s\n",
            strerror(errno));
    return 1;
  }
  strncpy(lib, buf, 1023);
  strncpy(base, dirname(lib), 1023);
  snprintf(exe, 1023, "%s/bin/%s", base, basename(buf));
  memset(lib, 0, 1023);
  snprintf(lib, 1023, "%s/lib", base);
  if (setenv("QT_ACCESSIBILITY", "0", 1) != 0) {
    fprintf(stderr, "Failed to set environment variable with error: %s\n",
            strerror(errno));
    return 1;
  }
  memset(buf, 0, 1023);
  ldp = getenv("QT_PLUGIN_PATH");
  if (ldp == NULL)
    snprintf(buf, 1023, "%s/qt_plugins", lib);
  else
    snprintf(buf, 1023, "%s/qt_plugins:%s", lib, ldp);
  if (setenv("QT_PLUGIN_PATH", buf, 1) != 0) {
    fprintf(stderr, "Failed to set environment variable with error: %s\n",
            strerror(errno));
    return 1;
  };
  memset(buf, 0, 1023);
  ldp = getenv("LD_LIBRARY_PATH");
  if (ldp == NULL)
    strncpy(buf, lib, 1023);
  else
    snprintf(buf, 1023, "%s:%s", lib, ldp);
  if (setenv("LD_LIBRARY_PATH", buf, 1) != 0) {
    fprintf(stderr, "Failed to set environment variable with error: %s\n",
            strerror(errno));
    return 1;
  }
  argv[0] = exe;
  if (execv(exe, argv) == -1) {
    fprintf(stderr, "Failed to execute binary: %s with error: %s\n", exe,
            strerror(errno));
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rdi
lea    0x2ebc(%rip),%rsi
mov    $0x3ff,%edx
call   1050 <readlink@plt>
cmp    $0xffffffff,%eax
jne    1221 <main+0x71>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x38b>
lea    0x3268(%rip),%rdi
lea    0x2e61(%rip),%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
lea    0x3250(%rip),%rdi
call   1080 <dirname@plt>
mov    %rax,%rsi
lea    0x3641(%rip),%rdi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
lea    0x2e30(%rip),%rdi
call   10b0 <basename@plt>
mov    %rax,%r8
lea    0x3a21(%rip),%rdi
mov    $0x3ff,%esi
lea    0xdc6(%rip),%rdx
lea    0x360e(%rip),%rcx
mov    $0x0,%al
call   1070 <snprintf@plt>
lea    0x3200(%rip),%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0x31ed(%rip),%rdi
mov    $0x3ff,%esi
lea    0xd9c(%rip),%rdx
lea    0x35da(%rip),%rcx
mov    $0x0,%al
call   1070 <snprintf@plt>
lea    0xd8e(%rip),%rdi
lea    0xd98(%rip),%rsi
mov    $0x1,%edx
call   1060 <setenv@plt>
cmp    $0x0,%rax
je     1319 <main+0x169>
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x38b>
lea    0x2d70(%rip),%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0xd65(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3d51(%rip)
cmpq   $0x0,0x3d49(%rip)
jne    1373 <main+0x1c3>
lea    0x2d3c(%rip),%rdi
mov    $0x3ff,%esi
lea    0xd47(%rip),%rdx
lea    0x3129(%rip),%rcx
mov    $0x0,%al
call   1070 <snprintf@plt>
jmp    139b <main+0x1eb>
mov    0x3d16(%rip),%r8
lea    0x2d0f(%rip),%rdi
mov    $0x3ff,%esi
lea    0xd28(%rip),%rdx
lea    0x30fc(%rip),%rcx
mov    $0x0,%al
call   1070 <snprintf@plt>
lea    0xcf6(%rip),%rdi
lea    0x2ce7(%rip),%rsi
mov    $0x1,%edx
call   1060 <setenv@plt>
cmp    $0x0,%rax
je     13f7 <main+0x247>
mov    0x2c1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xc81(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x38b>
lea    0x2c92(%rip),%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0xcb5(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3c73(%rip)
cmpq   $0x0,0x3c6b(%rip)
jne    1448 <main+0x298>
lea    0x2c5e(%rip),%rdi
lea    0x3057(%rip),%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
jmp    1470 <main+0x2c0>
mov    0x3c41(%rip),%r8
lea    0x2c3a(%rip),%rdi
mov    $0x3ff,%esi
lea    0xc74(%rip),%rdx
lea    0x3027(%rip),%rcx
mov    $0x0,%al
call   1070 <snprintf@plt>
lea    0xc4f(%rip),%rdi
lea    0x2c12(%rip),%rsi
mov    $0x1,%edx
call   1060 <setenv@plt>
cmp    $0x0,%rax
je     14cc <main+0x31c>
mov    0x2b47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xbac(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x38b>
mov    -0x10(%rbp),%rax
lea    0x37b9(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rsi
lea    0x37ab(%rip),%rdi
call   10d0 <execv@plt>
cmp    $0xffffffff,%eax
jne    1534 <main+0x384>
mov    0x2ae6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rcx
lea    0xbc2(%rip),%rsi
lea    0x376f(%rip),%rdx
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    153b <main+0x38b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
lea    0xe3f(%rip),%rdi
lea    0x2ec8(%rip),%rsi
mov    $0x3ff,%edx
call   1050 <readlink@plt>
cmp    $0xffffffff,%eax
je     12e2 <main+0x132>
lea    0x32ae(%rip),%rbp
lea    0x2ea7(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
call   1080 <dirname@plt>
lea    0x3688(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   10b0 <basename@plt>
lea    0x3a69(%rip),%r14
lea    0xe13(%rip),%rdx
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <snprintf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0xdf2(%rip),%rdx
mov    %rbp,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <snprintf@plt>
lea    0xde0(%rip),%rdi
lea    0xdea(%rip),%rsi
mov    $0x1,%ebp
mov    $0x1,%edx
call   1060 <setenv@plt>
test   %rax,%rax
jne    134f <main+0x19f>
lea    0x2df8(%rip),%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0xded(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3dd9(%rip)
lea    0x2dd2(%rip),%rdi
test   %rax,%rax
je     1313 <main+0x163>
lea    0xdeb(%rip),%rdx
lea    0x31bf(%rip),%rcx
mov    $0x3ff,%esi
mov    %rax,%r8
xor    %eax,%eax
call   1070 <snprintf@plt>
jmp    132d <main+0x17d>
mov    0x2cf7(%rip),%rax
mov    (%rax),%ebx
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd0f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebp
jmp    1379 <main+0x1c9>
lea    0xd8d(%rip),%rdx
lea    0x316f(%rip),%rcx
mov    $0x3ff,%esi
xor    %eax,%eax
call   1070 <snprintf@plt>
lea    0xd64(%rip),%rdi
lea    0x2d55(%rip),%rsi
mov    $0x1,%ebp
mov    $0x1,%edx
call   1060 <setenv@plt>
test   %rax,%rax
je     1386 <main+0x1d6>
mov    0x2c8a(%rip),%rax
mov    (%rax),%ebx
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xcf8(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x2d03(%rip),%rdi
xor    %esi,%esi
mov    $0x3ff,%edx
call   1090 <memset@plt>
lea    0xd26(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3ce4(%rip)
lea    0x2cdd(%rip),%rdi
test   %rax,%rax
je     13d7 <main+0x227>
lea    0xd17(%rip),%rdx
lea    0x30ca(%rip),%rcx
mov    $0x3ff,%esi
mov    %rax,%r8
xor    %eax,%eax
call   1070 <snprintf@plt>
jmp    13e8 <main+0x238>
lea    0x30b2(%rip),%rsi
mov    $0x3ff,%edx
call   1040 <strncpy@plt>
lea    0xcd7(%rip),%rdi
lea    0x2c9a(%rip),%rsi
mov    $0x1,%edx
call   1060 <setenv@plt>
test   %rax,%rax
je     1428 <main+0x278>
mov    0x2bd4(%rip),%rax
mov    (%rax),%ebx
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc42(%rip),%rsi
jmp    1300 <main+0x150>
mov    %r14,(%r15)
mov    %r14,%rdi
mov    %r15,%rsi
call   10d0 <execv@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
jne    1379 <main+0x1c9>
mov    0x2b98(%rip),%rax
mov    (%rax),%ebx
mov    0x2b87(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc7d(%rip),%rsi
lea    0x382a(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    130c <main+0x15c>

LLVM IR (-O0):
@main.buf = internal global [1024 x i8] zeroinitializer
@main.lib = internal global [1024 x i8] zeroinitializer
@main.base = internal global [1024 x i8] zeroinitializer
@main.exe = internal global [1024 x i8] zeroinitializer
@main.ldp = internal global i8* null
@.str = [15 x i8] c"/proc/self/exe\00"
@stderr = global i32 0
@.str.1 = [50 x i8] c"Failed to read path of executable with error: %s\0A\00"
@errno = global i32 0
@.str.2 = [10 x i8] c"%s/bin/%s\00"
@.str.3 = [7 x i8] c"%s/lib\00"
@.str.4 = [17 x i8] c"QT_ACCESSIBILITY\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [51 x i8] c"Failed to set environment variable with error: %s\0A\00"
@.str.7 = [15 x i8] c"QT_PLUGIN_PATH\00"
@.str.8 = [14 x i8] c"%s/qt_plugins\00"
@.str.9 = [17 x i8] c"%s/qt_plugins:%s\00"
@.str.10 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.11 = [6 x i8] c"%s:%s\00"
@.str.12 = [45 x i8] c"Failed to execute binary: %s with error: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 1, i32* %3
br label %76
13: ; preds = %2
%14 = call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023)
%15 = call i8* @dirname(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0))
%16 = call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0), i8* %15, i32 1023)
%17 = call i8* @basename(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0))
%18 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0), i8* %17)
%19 = call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 0, i32 1023)
%20 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0))
%21 = call i64 @setenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %13
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %76
28: ; preds = %13
%29 = call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 0, i32 1023)
%30 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i8* %30, i8** @main.ldp
%31 = load i8*, i8** @main.ldp
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0))
br label %38
35: ; preds = %28
%36 = load i8*, i8** @main.ldp
%37 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %33
%39 = call i64 @setenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %44)
store i32 1, i32* %3
br label %76
46: ; preds = %38
%47 = call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 0, i32 1023)
%48 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
store i8* %48, i8** @main.ldp
%49 = load i8*, i8** @main.ldp
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 1023)
br label %56
53: ; preds = %46
%54 = load i8*, i8** @main.ldp
%55 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %51
%57 = call i64 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %62)
store i32 1, i32* %3
br label %76
64: ; preds = %56
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 0
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8** %66
%67 = load i8**, i8*** %5
%68 = call i32 @execv(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8** %67)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = load i32, i32* @stderr
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8* %73)
store i32 1, i32* %3
br label %76
75: ; preds = %64
store i32 0, i32* %3
br label %76
76: ; preds = %75, %70, %59, %41, %23, %8
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@main.buf = internal global [1024 x i8] zeroinitializer
@main.lib = internal global [1024 x i8] zeroinitializer
@main.base = internal global [1024 x i8] zeroinitializer
@main.exe = internal global [1024 x i8] zeroinitializer
@main.ldp = internal unnamed_addr global i8* null
@.str = [15 x i8] c"/proc/self/exe\00"
@stderr = global i32 0
@.str.1 = [50 x i8] c"Failed to read path of executable with error: %s\0A\00"
@errno = global i32 0
@.str.2 = [10 x i8] c"%s/bin/%s\00"
@.str.3 = [7 x i8] c"%s/lib\00"
@.str.4 = [17 x i8] c"QT_ACCESSIBILITY\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [51 x i8] c"Failed to set environment variable with error: %s\0A\00"
@.str.7 = [15 x i8] c"QT_PLUGIN_PATH\00"
@.str.8 = [14 x i8] c"%s/qt_plugins\00"
@.str.9 = [17 x i8] c"%s/qt_plugins:%s\00"
@.str.10 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.11 = [6 x i8] c"%s:%s\00"
@.str.12 = [45 x i8] c"Failed to execute binary: %s with error: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %65
10: ; preds = %2
%11 = tail call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023)
%12 = tail call i8* @dirname(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0))
%13 = tail call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0), i8* %12, i32 1023)
%14 = tail call i8* @basename(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0))
%15 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0), i8* %14)
%16 = tail call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 0, i32 1023)
%17 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.base, i64 0, i64 0))
%18 = tail call i64 @setenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %23)
br label %65
25: ; preds = %10
%26 = tail call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 0, i32 1023)
%27 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i8* %27, i8** @main.ldp
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0))
br label %33
31: ; preds = %25
%32 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* %27)
br label %33
33: ; preds = %31, %29
%34 = tail call i64 @setenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1)
%35 = icmp eq i64 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = tail call i8* @strerror(i32 %38)
%40 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %39)
br label %65
41: ; preds = %33
%42 = tail call i32 @memset(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 0, i32 1023)
%43 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
store i8* %43, i8** @main.ldp
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = tail call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i32 1023)
br label %49
47: ; preds = %41
%48 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.lib, i64 0, i64 0), i8* %43)
br label %49
49: ; preds = %47, %45
%50 = tail call i64 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.buf, i64 0, i64 0), i32 1)
%51 = icmp eq i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = tail call i8* @strerror(i32 %54)
%56 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* %55)
br label %65
57: ; preds = %49
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8** %1
%58 = tail call i32 @execv(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8** %1)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = tail call i8* @strerror(i32 %62)
%64 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @main.exe, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %57, %60, %52, %36, %20, %5
%66 = phi i32 [ 1, %5 ], [ 1, %20 ], [ 1, %36 ], [ 1, %52 ], [ 1, %60 ], [ 0, %57 ]
ret i32 %66
}