#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 build_link(char *, char const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int main(int argc, char **argv) {
  const char *tmp = 0;
  char *tmp_prefix = 0;
  const char *kde_prefix = 0;
  int res = 0;
  if ((argc != 2) ||
      ((strcmp(argv[1], "tmp") != 0) && (strcmp(argv[1], "socket") != 0) &&
       (strcmp(argv[1], "cache") != 0))) {
    fprintf(stderr, "[lnusertemp] Usage: lnusertemp tmp|socket|cache\n");
    return 1;
  }
  tmp = getenv("TDETMP");
  if (!tmp || !tmp[0])
    tmp = getenv("TMPDIR");
  if (!tmp || !tmp[0])
    tmp = getenv("TEMP");
  if (!tmp || !tmp[0])
    tmp = getenv("TMP");
  if (!tmp || !tmp[0])
    tmp = "/tmp";
  if (strcmp(argv[1], "tmp") == 0) {
    tmp_prefix = (char *)malloc(strlen(tmp) + strlen("/tde-") + 1);
    strcpy(tmp_prefix, tmp);
    strcat(tmp_prefix, "/tde-");
    kde_prefix = "/tmp-";
  } else if (strcmp(argv[1], "socket") == 0) {
    tmp_prefix = (char *)malloc(strlen(tmp) + strlen("/tdesocket-") + 1);
    strcpy(tmp_prefix, tmp);
    strcat(tmp_prefix, "/tdesocket-");
    kde_prefix = "/socket-";
  } else if (strcmp(argv[1], "cache") == 0) {
    tmp = getenv("TDEVARTMP");
    if (!tmp || !tmp[0])
      tmp = "/var/tmp";
    tmp_prefix = (char *)malloc(strlen(tmp) + strlen("/tdecache-") + 1);
    strcpy(tmp_prefix, tmp);
    strcat(tmp_prefix, "/tdecache-");
    kde_prefix = "/cache-";
  }
  res = build_link(tmp_prefix, kde_prefix, 1);
  if (build_link(tmp_prefix, kde_prefix, 0))
    res = 1;
  free(tmp_prefix);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1229 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     124a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe04(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     124a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xded(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     124a <main+0xba>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d8 <main+0x348>
lea    0xded(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1272 <main+0xe2>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1282 <main+0xf2>
lea    0xdcc(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     129a <main+0x10a>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12aa <main+0x11a>
lea    0xdab(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12c2 <main+0x132>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12d2 <main+0x142>
lea    0xd78(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12ea <main+0x15a>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    12f5 <main+0x165>
lea    0xd8f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd7d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    136d <main+0x1dd>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x38(%rbp)
lea    0xd2a(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xcf9(%rip),%rsi
call   10b0 <strcat@plt>
lea    0xcf3(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1495 <main+0x305>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc84(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13e5 <main+0x255>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x40(%rbp)
lea    0xcbe(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xc8d(%rip),%rsi
call   10b0 <strcat@plt>
lea    0xc8d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1490 <main+0x300>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc13(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    148b <main+0x2fb>
lea    0xc68(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     142b <main+0x29b>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1436 <main+0x2a6>
lea    0xc4a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x48(%rbp)
lea    0xc3b(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xc0a(%rip),%rsi
call   10b0 <strcat@plt>
lea    0xc09(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1490 <main+0x300>
jmp    1495 <main+0x305>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <build_link@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
call   10a0 <build_link@plt>
cmp    $0x0,%eax
je     14c9 <main+0x339>
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11de <main+0x4e>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xed7(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11fd <main+0x6d>
mov    0x8(%r14),%rdi
lea    0xe41(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11fd <main+0x6d>
mov    0x8(%r14),%rdi
lea    0xe33(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11fd <main+0x6d>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebp
jmp    13aa <main+0x21a>
lea    0xe3a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1216 <main+0x86>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1268 <main+0xd8>
lea    0xe28(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     122f <main+0x9f>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1268 <main+0xd8>
lea    0xe16(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1248 <main+0xb8>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1268 <main+0xd8>
lea    0xdf2(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1261 <main+0xd1>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1268 <main+0xd8>
lea    0xe18(%rip),%rbx
mov    0x8(%r14),%rdi
lea    0xe0e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12b1 <main+0x121>
mov    0x8(%r14),%rdi
lea    0xd78(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12eb <main+0x15b>
mov    0x8(%r14),%rdi
lea    0xd6a(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1322 <main+0x192>
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1377 <main+0x1e7>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x6(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xd7a(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
lea    0xd71(%rip),%rbx
jmp    1377 <main+0x1e7>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xc(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xd4c(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
lea    0xd49(%rip),%rbx
jmp    1377 <main+0x1e7>
lea    0xd49(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     133b <main+0x1ab>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1342 <main+0x1b2>
lea    0xd3a(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xb(%rax),%rdi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xd1d(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
lea    0xd19(%rip),%rbx
mov    $0x1,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10a0 <build_link@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   10a0 <build_link@plt>
test   %eax,%eax
cmovne %r15d,%ebp
mov    %r14,%rdi
call   1040 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"tmp\00"
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [6 x i8] c"cache\00"
@stderr = global i32 0
@.str.3 = [49 x i8] c"[lnusertemp] Usage: lnusertemp tmp|socket|cache\0A\00"
@.str.4 = [7 x i8] c"TDETMP\00"
@.str.5 = [7 x i8] c"TMPDIR\00"
@.str.6 = [5 x i8] c"TEMP\00"
@.str.7 = [4 x i8] c"TMP\00"
@.str.8 = [5 x i8] c"/tmp\00"
@.str.9 = [6 x i8] c"/tde-\00"
@.str.10 = [6 x i8] c"/tmp-\00"
@.str.11 = [12 x i8] c"/tdesocket-\00"
@.str.12 = [9 x i8] c"/socket-\00"
@.str.13 = [10 x i8] c"TDEVARTMP\00"
@.str.14 = [9 x i8] c"/var/tmp\00"
@.str.15 = [11 x i8] c"/tdecache-\00"
@.str.16 = [8 x i8] c"/cache-\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %30, label %12
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %24, %2
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %155
33: ; preds = %24, %18, %12
%34 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i8* %34, i8** %6
%35 = load i8*, i8** %6
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %37, %33
%43 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i8* %43, i8** %6
br label %44
44: ; preds = %42, %37
%45 = load i8*, i8** %6
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %47, %44
%53 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i8* %53, i8** %6
br label %54
54: ; preds = %52, %47
%55 = load i8*, i8** %6
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i8*, i8** %6
%59 = getelementptr inbounds i8, i8* %58, i64 0
%60 = load i8, i8* %59
%61 = icmp ne i8 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %57, %54
%63 = call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i8* %63, i8** %6
br label %64
64: ; preds = %62, %57
%65 = load i8*, i8** %6
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %72
67: ; preds = %64
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = icmp ne i8 %70, 0
br i1 %71, label %73, label %72
72: ; preds = %67, %64
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %6
br label %73
73: ; preds = %72, %67
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %92
79: ; preds = %73
%80 = load i8*, i8** %6
%81 = call i64 @strlen(i8* %80)
%82 = call i64 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%83 = add nsw i64 %81, %82
%84 = add nsw i64 %83, 1
%85 = call i64 @malloc(i64 %84)
%86 = inttoptr i64 %85 to i8*
store i8* %86, i8** %7
%87 = load i8*, i8** %7
%88 = load i8*, i8** %6
%89 = call i32 @strcpy(i8* %87, i8* %88)
%90 = load i8*, i8** %7
%91 = call i32 @strcat(i8* %90, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8** %8
br label %142
92: ; preds = %73
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i64 @strcmp(i8* %95, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %111
98: ; preds = %92
%99 = load i8*, i8** %6
%100 = call i64 @strlen(i8* %99)
%101 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%102 = add nsw i64 %100, %101
%103 = add nsw i64 %102, 1
%104 = call i64 @malloc(i64 %103)
%105 = inttoptr i64 %104 to i8*
store i8* %105, i8** %7
%106 = load i8*, i8** %7
%107 = load i8*, i8** %6
%108 = call i32 @strcpy(i8* %106, i8* %107)
%109 = load i8*, i8** %7
%110 = call i32 @strcat(i8* %109, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8** %8
br label %141
111: ; preds = %92
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 1
%114 = load i8*, i8** %113
%115 = call i64 @strcmp(i8* %114, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %140
117: ; preds = %111
%118 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
store i8* %118, i8** %6
%119 = load i8*, i8** %6
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %126
121: ; preds = %117
%122 = load i8*, i8** %6
%123 = getelementptr inbounds i8, i8* %122, i64 0
%124 = load i8, i8* %123
%125 = icmp ne i8 %124, 0
br i1 %125, label %127, label %126
126: ; preds = %121, %117
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %6
br label %127
127: ; preds = %126, %121
%128 = load i8*, i8** %6
%129 = call i64 @strlen(i8* %128)
%130 = call i64 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%131 = add nsw i64 %129, %130
%132 = add nsw i64 %131, 1
%133 = call i64 @malloc(i64 %132)
%134 = inttoptr i64 %133 to i8*
store i8* %134, i8** %7
%135 = load i8*, i8** %7
%136 = load i8*, i8** %6
%137 = call i32 @strcpy(i8* %135, i8* %136)
%138 = load i8*, i8** %7
%139 = call i32 @strcat(i8* %138, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8** %8
br label %140
140: ; preds = %127, %111
br label %141
141: ; preds = %140, %98
br label %142
142: ; preds = %141, %79
%143 = load i8*, i8** %7
%144 = load i8*, i8** %8
%145 = call i32 @build_link(i8* %143, i8* %144, i32 1)
store i32 %145, i32* %9
%146 = load i8*, i8** %7
%147 = load i8*, i8** %8
%148 = call i32 @build_link(i8* %146, i8* %147, i32 0)
%149 = icmp ne i32 %148, 0
br i1 %149, label %150, label %151
150: ; preds = %142
store i32 1, i32* %9
br label %151
151: ; preds = %150, %142
%152 = load i8*, i8** %7
%153 = call i32 @free(i8* %152)
%154 = load i32, i32* %9
store i32 %154, i32* %3
br label %155
155: ; preds = %151, %30
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
@.str = [4 x i8] c"tmp\00"
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [6 x i8] c"cache\00"
@stderr = global i32 0
@.str.3 = [49 x i8] c"[lnusertemp] Usage: lnusertemp tmp|socket|cache\0A\00"
@.str.4 = [7 x i8] c"TDETMP\00"
@.str.5 = [7 x i8] c"TMPDIR\00"
@.str.6 = [5 x i8] c"TEMP\00"
@.str.7 = [4 x i8] c"TMP\00"
@.str.8 = [5 x i8] c"/tmp\00"
@.str.9 = [6 x i8] c"/tde-\00"
@.str.10 = [6 x i8] c"/tmp-\00"
@.str.11 = [12 x i8] c"/tdesocket-\00"
@.str.12 = [9 x i8] c"/socket-\00"
@.str.13 = [10 x i8] c"TDEVARTMP\00"
@.str.14 = [9 x i8] c"/var/tmp\00"
@.str.15 = [11 x i8] c"/tdecache-\00"
@.str.16 = [8 x i8] c"/cache-\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13, %2
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %95
20: ; preds = %13, %9, %4
%21 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i8, i8* %21
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %20, %23
%27 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i8, i8* %27
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %26, %29
%33 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i8, i8* %33
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %32, %35
%39 = tail call i8* @getenv(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp eq i8* %39, null
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i8, i8* %39
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41, %38
br label %45
45: ; preds = %29, %23, %35, %44, %41
%46 = phi i8* [ %39, %41 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), %44 ], [ %33, %35 ], [ %21, %23 ], [ %27, %29 ]
%47 = load i8*, i8** %5
%48 = tail call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %57
50: ; preds = %45
%51 = tail call i64 @strlen(i8* dereferenceable(1) %46)
%52 = add nsw i64 %51, 6
%53 = tail call i64 @malloc(i64 %52)
%54 = inttoptr i64 %53 to i8*
%55 = tail call i32 @strcpy(i8* %54, i8* %46)
%56 = tail call i32 @strcat(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
br label %87
57: ; preds = %45
%58 = load i8*, i8** %5
%59 = tail call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = tail call i64 @strlen(i8* dereferenceable(1) %46)
%63 = add nsw i64 %62, 12
%64 = tail call i64 @malloc(i64 %63)
%65 = inttoptr i64 %64 to i8*
%66 = tail call i32 @strcpy(i8* %65, i8* %46)
%67 = tail call i32 @strcat(i8* %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %87
68: ; preds = %57
%69 = load i8*, i8** %5
%70 = tail call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %87
72: ; preds = %68
%73 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
%74 = icmp eq i8* %73, null
br i1 %74, label %78, label %75
75: ; preds = %72
%76 = load i8, i8* %73
%77 = icmp eq i8 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %75, %72
br label %79
79: ; preds = %78, %75
%80 = phi i8* [ %73, %75 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), %78 ]
%81 = tail call i64 @strlen(i8* dereferenceable(1) %80)
%82 = add nsw i64 %81, 11
%83 = tail call i64 @malloc(i64 %82)
%84 = inttoptr i64 %83 to i8*
%85 = tail call i32 @strcpy(i8* %84, i8* %80)
%86 = tail call i32 @strcat(i8* %84, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
br label %87
87: ; preds = %61, %79, %68, %50
%88 = phi i8* [ %54, %50 ], [ %65, %61 ], [ %84, %79 ], [ null, %68 ]
%89 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), %50 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), %61 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), %79 ], [ null, %68 ]
%90 = tail call i32 @build_link(i8* %88, i8* %89, i32 1)
%91 = tail call i32 @build_link(i8* %88, i8* %89, i32 0)
%92 = icmp eq i32 %91, 0
%93 = select i1 %92, i32 %90, i32 1
%94 = tail call i32 @free(i8* %88)
br label %95
95: ; preds = %87, %17
%96 = phi i32 [ 1, %17 ], [ %93, %87 ]
ret i32 %96
}