#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*/ fileExists(char const *);
char *getEnvironment(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ traceInit();
const char *traceLibraryLocation(const char *lib) {
  const char *ret = NULL;
  static char buffer[1024];
  traceInit();
  if (!strcmp(lib, "Cg")) {
    ret = getEnvironment("CG_TRACE_CG_LIBRARY");
    if (!ret) {
      ret = getEnvironment("CG_LIB_PATH");
      if (ret) {
        snprintf(buffer, 1024, "%s/libCg.so", ret);
        ret = buffer;
      }
    }
    if (!ret) {
      ret = "/usr/lib/amd64/libCg.so";
      if (!fileExists(ret))
        ret = "/usr/lib64/libCg.so";
      if (!fileExists(ret))
        ret = "/usr/lib/libCg.so";
    }
  }
  if (!strcmp(lib, "CgGL")) {
    ret = getEnvironment("CG_TRACE_CGGL_LIBRARY");
    if (!ret) {
      ret = getEnvironment("CG_LIB_PATH");
      if (ret) {
        snprintf(buffer, 1024, "%s/libCgGL.so", ret);
        ret = buffer;
      }
    }
    if (!ret) {
      ret = "/usr/lib/amd64/libCgGL.so";
      if (!fileExists(ret))
        ret = "/usr/lib64/libCgGL.so";
      if (!fileExists(ret))
        ret = "/usr/lib/libCgGL.so";
    }
  }
  if (!strcmp(lib, "GL") || !strcmp(lib, "WGL") || !strcmp(lib, "GLX")) {
    ret = getEnvironment("CG_TRACE_GL_LIBRARY");
    if (!ret) {
      ret = "/usr/lib/amd64/libGL.so.1";
      if (!fileExists(ret))
        ret = "/usr/lib64/libGL.so.1";
      if (!fileExists(ret))
        ret = "/usr/lib/nvidia-current/libGL.so.1";
      if (!fileExists(ret))
        ret = "/usr/lib/libGL.so.1";
    }
  }
  if (!strcmp(lib, "GLUT")) {
    ret = getEnvironment("CG_TRACE_GLUT_LIBRARY");
    if (!ret) {
    }
    if (!ret) {
      ret = "/usr/lib/amd64/libglut.so.3";
      if (!fileExists(ret))
        ret = "/usr/lib64/libglut.so.3";
      if (!fileExists(ret))
        ret = "/usr/lib/libglut.so.3";
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<traceLibraryLocation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <traceInit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1240 <traceLibraryLocation+0xf0>
lea    0xe78(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e6 <traceLibraryLocation+0x96>
lea    0xe71(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e1 <traceLibraryLocation+0x91>
mov    -0x10(%rbp),%rcx
lea    0x2e9b(%rip),%rdi
mov    $0x400,%esi
lea    0xe52(%rip),%rdx
call   1050 <snprintf@plt>
lea    0x2e83(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11e6 <traceLibraryLocation+0x96>
cmpq   $0x0,-0x10(%rbp)
jne    123b <traceLibraryLocation+0xeb>
lea    0xe37(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    1219 <traceLibraryLocation+0xc9>
lea    0xe32(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    1236 <traceLibraryLocation+0xe6>
lea    0xe29(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    123b <traceLibraryLocation+0xeb>
jmp    1240 <traceLibraryLocation+0xf0>
mov    -0x8(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1315 <traceLibraryLocation+0x1c5>
lea    0xe12(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12bb <traceLibraryLocation+0x16b>
lea    0xd9c(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12b6 <traceLibraryLocation+0x166>
mov    -0x10(%rbp),%rcx
lea    0x2dc6(%rip),%rdi
mov    $0x400,%esi
lea    0xde2(%rip),%rdx
call   1050 <snprintf@plt>
lea    0x2dae(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12bb <traceLibraryLocation+0x16b>
cmpq   $0x0,-0x10(%rbp)
jne    1310 <traceLibraryLocation+0x1c0>
lea    0xdc9(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    12ee <traceLibraryLocation+0x19e>
lea    0xdc6(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    130b <traceLibraryLocation+0x1bb>
lea    0xdbf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1310 <traceLibraryLocation+0x1c0>
jmp    1315 <traceLibraryLocation+0x1c5>
mov    -0x8(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1360 <traceLibraryLocation+0x210>
mov    -0x8(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
je     1360 <traceLibraryLocation+0x210>
mov    -0x8(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13e7 <traceLibraryLocation+0x297>
lea    0xd7b(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    13e2 <traceLibraryLocation+0x292>
lea    0xd74(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    13a3 <traceLibraryLocation+0x253>
lea    0xd71(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    13c0 <traceLibraryLocation+0x270>
lea    0xd6a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    13dd <traceLibraryLocation+0x28d>
lea    0xd70(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    13e2 <traceLibraryLocation+0x292>
jmp    13e7 <traceLibraryLocation+0x297>
mov    -0x8(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    147a <traceLibraryLocation+0x32a>
lea    0xd5b(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1420 <traceLibraryLocation+0x2d0>
jmp    1420 <traceLibraryLocation+0x2d0>
cmpq   $0x0,-0x10(%rbp)
jne    1475 <traceLibraryLocation+0x325>
lea    0xd46(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    1453 <traceLibraryLocation+0x303>
lea    0xd45(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%eax
jne    1470 <traceLibraryLocation+0x320>
lea    0xd40(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1475 <traceLibraryLocation+0x325>
jmp    147a <traceLibraryLocation+0x32a>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<traceLibraryLocation>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <traceInit@plt>
lea    0xe98(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ea <traceLibraryLocation+0x9a>
lea    0xe88(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ea <traceLibraryLocation+0x9a>
lea    0xe88(%rip),%rdi
call   1070 <getEnvironment@plt>
test   %rax,%rax
je     11b9 <traceLibraryLocation+0x69>
lea    0x2ec0(%rip),%rbx
lea    0xe7c(%rip),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
jmp    11ea <traceLibraryLocation+0x9a>
lea    0xe6f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe76(%rip),%r15
cmovne %rbx,%r15
mov    %r15,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe75(%rip),%rbx
cmovne %r15,%rbx
lea    0xe7c(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1273 <traceLibraryLocation+0x123>
lea    0xe6e(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1273 <traceLibraryLocation+0x123>
lea    0xdff(%rip),%rdi
call   1070 <getEnvironment@plt>
test   %rax,%rax
je     1242 <traceLibraryLocation+0xf2>
lea    0x2e37(%rip),%rbx
lea    0xe58(%rip),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
jmp    1273 <traceLibraryLocation+0x123>
lea    0xe4d(%rip),%rbx
mov    %rbx,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe56(%rip),%r15
cmovne %rbx,%r15
mov    %r15,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe57(%rip),%rbx
cmovne %r15,%rbx
lea    0xe61(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12ac <traceLibraryLocation+0x15c>
lea    0xe4d(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     12ac <traceLibraryLocation+0x15c>
lea    0xe3e(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1306 <traceLibraryLocation+0x1b6>
lea    0xe2f(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1306 <traceLibraryLocation+0x1b6>
lea    0xe2f(%rip),%r15
mov    %r15,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe38(%rip),%rbx
cmovne %r15,%rbx
mov    %rbx,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe39(%rip),%r15
cmovne %rbx,%r15
mov    %r15,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe47(%rip),%rbx
cmovne %r15,%rbx
lea    0xe50(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    135e <traceLibraryLocation+0x20e>
lea    0xe42(%rip),%rdi
call   1070 <getEnvironment@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    135e <traceLibraryLocation+0x20e>
lea    0xe44(%rip),%rbx
mov    %rbx,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe4f(%rip),%r14
cmovne %rbx,%r14
mov    %r14,%rdi
call   1030 <fileExists@plt>
test   %eax,%eax
lea    0xe52(%rip),%rbx
cmovne %r14,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@traceLibraryLocation.buffer = internal global [1024 x i8] zeroinitializer
@.str = [3 x i8] c"Cg\00"
@.str.1 = [20 x i8] c"CG_TRACE_CG_LIBRARY\00"
@.str.2 = [12 x i8] c"CG_LIB_PATH\00"
@.str.3 = [12 x i8] c"%s/libCg.so\00"
@.str.4 = [24 x i8] c"/usr/lib/amd64/libCg.so\00"
@.str.5 = [20 x i8] c"/usr/lib64/libCg.so\00"
@.str.6 = [18 x i8] c"/usr/lib/libCg.so\00"
@.str.7 = [5 x i8] c"CgGL\00"
@.str.8 = [22 x i8] c"CG_TRACE_CGGL_LIBRARY\00"
@.str.9 = [14 x i8] c"%s/libCgGL.so\00"
@.str.10 = [26 x i8] c"/usr/lib/amd64/libCgGL.so\00"
@.str.11 = [22 x i8] c"/usr/lib64/libCgGL.so\00"
@.str.12 = [20 x i8] c"/usr/lib/libCgGL.so\00"
@.str.13 = [3 x i8] c"GL\00"
@.str.14 = [4 x i8] c"WGL\00"
@.str.15 = [4 x i8] c"GLX\00"
@.str.16 = [20 x i8] c"CG_TRACE_GL_LIBRARY\00"
@.str.17 = [26 x i8] c"/usr/lib/amd64/libGL.so.1\00"
@.str.18 = [22 x i8] c"/usr/lib64/libGL.so.1\00"
@.str.19 = [35 x i8] c"/usr/lib/nvidia-current/libGL.so.1\00"
@.str.20 = [20 x i8] c"/usr/lib/libGL.so.1\00"
@.str.21 = [5 x i8] c"GLUT\00"
@.str.22 = [22 x i8] c"CG_TRACE_GLUT_LIBRARY\00"
@.str.23 = [28 x i8] c"/usr/lib/amd64/libglut.so.3\00"
@.str.24 = [24 x i8] c"/usr/lib64/libglut.so.3\00"
@.str.25 = [22 x i8] c"/usr/lib/libglut.so.3\00"
define i8* @traceLibraryLocation(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
%4 = call i32 (...) @traceInit()
%5 = load i8*, i8** %2
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %35, label %8
8: ; preds = %1
%9 = call i8* @getEnvironment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = call i8* @getEnvironment(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %17)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i8** %3
br label %19
19: ; preds = %16, %12
br label %20
20: ; preds = %19, %8
%21 = load i8*, i8** %3
%22 = icmp ne i8* %21, null
br i1 %22, label %34, label %23
23: ; preds = %20
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8** %3
%24 = load i8*, i8** %3
%25 = call i32 @fileExists(i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %28
28: ; preds = %27, %23
%29 = load i8*, i8** %3
%30 = call i32 @fileExists(i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %33
33: ; preds = %32, %28
br label %34
34: ; preds = %33, %20
br label %35
35: ; preds = %34, %1
%36 = load i8*, i8** %2
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %66, label %39
39: ; preds = %35
%40 = call i8* @getEnvironment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
store i8* %40, i8** %3
%41 = load i8*, i8** %3
%42 = icmp ne i8* %41, null
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = call i8* @getEnvironment(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i8* %44, i8** %3
%45 = load i8*, i8** %3
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i8*, i8** %3
%49 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %48)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i8** %3
br label %50
50: ; preds = %47, %43
br label %51
51: ; preds = %50, %39
%52 = load i8*, i8** %3
%53 = icmp ne i8* %52, null
br i1 %53, label %65, label %54
54: ; preds = %51
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8** %3
%55 = load i8*, i8** %3
%56 = call i32 @fileExists(i8* %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %59, label %58
58: ; preds = %54
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %59
59: ; preds = %58, %54
%60 = load i8*, i8** %3
%61 = call i32 @fileExists(i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %59
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %64
64: ; preds = %63, %59
br label %65
65: ; preds = %64, %51
br label %66
66: ; preds = %65, %35
%67 = load i8*, i8** %2
%68 = call i32 @strcmp(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %78
70: ; preds = %66
%71 = load i8*, i8** %2
%72 = call i32 @strcmp(i8* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i8*, i8** %2
%76 = call i32 @strcmp(i8* %75, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%77 = icmp ne i32 %76, 0
br i1 %77, label %99, label %78
78: ; preds = %74, %70, %66
%79 = call i8* @getEnvironment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
store i8* %79, i8** %3
%80 = load i8*, i8** %3
%81 = icmp ne i8* %80, null
br i1 %81, label %98, label %82
82: ; preds = %78
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0), i8** %3
%83 = load i8*, i8** %3
%84 = call i32 @fileExists(i8* %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %87, label %86
86: ; preds = %82
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.18, i64 0, i64 0), i8** %3
br label %87
87: ; preds = %86, %82
%88 = load i8*, i8** %3
%89 = call i32 @fileExists(i8* %88)
%90 = icmp ne i32 %89, 0
br i1 %90, label %92, label %91
91: ; preds = %87
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.19, i64 0, i64 0), i8** %3
br label %92
92: ; preds = %91, %87
%93 = load i8*, i8** %3
%94 = call i32 @fileExists(i8* %93)
%95 = icmp ne i32 %94, 0
br i1 %95, label %97, label %96
96: ; preds = %92
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i8** %3
br label %97
97: ; preds = %96, %92
br label %98
98: ; preds = %97, %78
br label %99
99: ; preds = %98, %74
%100 = load i8*, i8** %2
%101 = call i32 @strcmp(i8* %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
%102 = icmp ne i32 %101, 0
br i1 %102, label %123, label %103
103: ; preds = %99
%104 = call i8* @getEnvironment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.22, i64 0, i64 0))
store i8* %104, i8** %3
%105 = load i8*, i8** %3
%106 = icmp ne i8* %105, null
br i1 %106, label %108, label %107
107: ; preds = %103
br label %108
108: ; preds = %107, %103
%109 = load i8*, i8** %3
%110 = icmp ne i8* %109, null
br i1 %110, label %122, label %111
111: ; preds = %108
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.23, i64 0, i64 0), i8** %3
%112 = load i8*, i8** %3
%113 = call i32 @fileExists(i8* %112)
%114 = icmp ne i32 %113, 0
br i1 %114, label %116, label %115
115: ; preds = %111
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.24, i64 0, i64 0), i8** %3
br label %116
116: ; preds = %115, %111
%117 = load i8*, i8** %3
%118 = call i32 @fileExists(i8* %117)
%119 = icmp ne i32 %118, 0
br i1 %119, label %121, label %120
120: ; preds = %116
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0), i8** %3
br label %121
121: ; preds = %120, %116
br label %122
122: ; preds = %121, %108
br label %123
123: ; preds = %122, %99
%124 = load i8*, i8** %3
ret i8* %124
}

LLVM IR (-O2):
@traceLibraryLocation.buffer = internal global [1024 x i8] zeroinitializer
@.str = [3 x i8] c"Cg\00"
@.str.1 = [20 x i8] c"CG_TRACE_CG_LIBRARY\00"
@.str.2 = [12 x i8] c"CG_LIB_PATH\00"
@.str.3 = [12 x i8] c"%s/libCg.so\00"
@.str.4 = [24 x i8] c"/usr/lib/amd64/libCg.so\00"
@.str.5 = [20 x i8] c"/usr/lib64/libCg.so\00"
@.str.6 = [18 x i8] c"/usr/lib/libCg.so\00"
@.str.7 = [5 x i8] c"CgGL\00"
@.str.8 = [22 x i8] c"CG_TRACE_CGGL_LIBRARY\00"
@.str.9 = [14 x i8] c"%s/libCgGL.so\00"
@.str.10 = [26 x i8] c"/usr/lib/amd64/libCgGL.so\00"
@.str.11 = [22 x i8] c"/usr/lib64/libCgGL.so\00"
@.str.12 = [20 x i8] c"/usr/lib/libCgGL.so\00"
@.str.13 = [3 x i8] c"GL\00"
@.str.14 = [4 x i8] c"WGL\00"
@.str.15 = [4 x i8] c"GLX\00"
@.str.16 = [20 x i8] c"CG_TRACE_GL_LIBRARY\00"
@.str.17 = [26 x i8] c"/usr/lib/amd64/libGL.so.1\00"
@.str.18 = [22 x i8] c"/usr/lib64/libGL.so.1\00"
@.str.19 = [35 x i8] c"/usr/lib/nvidia-current/libGL.so.1\00"
@.str.20 = [20 x i8] c"/usr/lib/libGL.so.1\00"
@.str.21 = [5 x i8] c"GLUT\00"
@.str.22 = [22 x i8] c"CG_TRACE_GLUT_LIBRARY\00"
@.str.23 = [28 x i8] c"/usr/lib/amd64/libglut.so.3\00"
@.str.24 = [24 x i8] c"/usr/lib64/libglut.so.3\00"
@.str.25 = [22 x i8] c"/usr/lib/libglut.so.3\00"
define i8* @traceLibraryLocation(i8* nocapture %0) {
%2 = tail call i32 (...) @traceInit()
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %20
13: ; preds = %8
%14 = tail call i32 @fileExists(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0)
%17 = tail call i32 @fileExists(i8* %16)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %16
br label %20
20: ; preds = %11, %5, %13, %1
%21 = phi i8* [ null, %1 ], [ %19, %13 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), %11 ], [ %6, %5 ]
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %20
%25 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %28)
br label %39
32: ; preds = %27
%33 = tail call i32 @fileExists(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0)
%36 = tail call i32 @fileExists(i8* %35)
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* %35
br label %39
39: ; preds = %30, %24, %32, %20
%40 = phi i8* [ %21, %20 ], [ %38, %32 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @traceLibraryLocation.buffer, i64 0, i64 0), %30 ], [ %25, %24 ]
%41 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %39
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %62
49: ; preds = %46, %43, %39
%50 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = tail call i32 @fileExists(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
%55 = select i1 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.17, i64 0, i64 0)
%56 = tail call i32 @fileExists(i8* %55)
%57 = icmp eq i32 %56, 0
%58 = select i1 %57, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.19, i64 0, i64 0), i8* %55
%59 = tail call i32 @fileExists(i8* %58)
%60 = icmp eq i32 %59, 0
%61 = select i1 %60, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i8* %58
br label %62
62: ; preds = %52, %49, %46
%63 = phi i8* [ %40, %46 ], [ %50, %49 ], [ %61, %52 ]
%64 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0))
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = tail call i8* @getEnvironment(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.22, i64 0, i64 0))
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %76
69: ; preds = %66
%70 = tail call i32 @fileExists(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.23, i64 0, i64 0))
%71 = icmp eq i32 %70, 0
%72 = select i1 %71, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.23, i64 0, i64 0)
%73 = tail call i32 @fileExists(i8* %72)
%74 = icmp eq i32 %73, 0
%75 = select i1 %74, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0), i8* %72
br label %76
76: ; preds = %69, %66, %62
%77 = phi i8* [ %63, %62 ], [ %67, %66 ], [ %75, %69 ]
ret i8* %77
}