#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ NvCliCompileLogFree(char *);
int NvCliCompileProgram(char const **, unsigned int const, size_t *, char *,
                        char **, char **);
int /*<<< orphan*/ NvCliCompiledProgramFree(char *);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  char *source;
  char *options;
  const char *strings[1];
  size_t lengths[1];
  const unsigned int count = 1;
  char *binary = NULL;
  char *log = NULL;
  int result;
  FILE *sourceFile = NULL;
  char *sourceFilename = NULL;
  FILE *binaryFile = NULL;
  char *binaryFilename = NULL;
  struct stat sourceStat;
  size_t size;
  if (argc < 3 || argc > 4) {
    printf("Usage: clcc [\"compiler-options\"] input.cl output.ptx\n");
    exit(EXIT_SUCCESS);
  }
  sourceFilename = argv[argc - 2];
  binaryFilename = argv[argc - 1];
  if (argc > 3) {
    options = argv[1];
  } else {
    options = "";
  }
  sourceFile = fopen(sourceFilename, "rb");
  if (sourceFile == NULL) {
    perror(sourceFilename);
    exit(EXIT_FAILURE);
  }
  result = stat(sourceFilename, &sourceStat);
  if (result != 0) {
    perror(sourceFilename);
    exit(EXIT_FAILURE);
  }
  source = (char *)malloc(sourceStat.st_size + 1);
  if (source == NULL) {
    fprintf(stderr, "malloc: Unable to allocate memory for source file.");
    exit(EXIT_FAILURE);
  }
  source[sourceStat.st_size] = 0;
  size = fread(source, sizeof(*source), sourceStat.st_size / sizeof(*source),
               sourceFile);
  if (size != sourceStat.st_size / sizeof(*source)) {
    perror(sourceFilename);
    exit(EXIT_FAILURE);
  }
  strings[0] = source;
  lengths[0] = strlen(source);
  result = NvCliCompileProgram(strings, count, lengths, options, &log, &binary);
  if (result != 0) {
    char *temp;
    temp = strtok(log, "\n");
    while (temp != NULL) {
      if (temp[0] == ':')
        printf("%s", sourceFilename);
      printf("%s\n", temp);
      temp = strtok(NULL, "\n");
    }
    NvCliCompileLogFree(log);
    exit(EXIT_FAILURE);
  }
  assert(binary != NULL);
  binaryFile = fopen(binaryFilename, "w+b");
  if (binaryFile == NULL) {
    perror(binaryFilename);
    exit(EXIT_FAILURE);
  }
  size = fwrite(binary, sizeof(*binary), strlen(binary), binaryFile);
  if (size != strlen(binary)) {
    perror(binaryFilename);
    exit(EXIT_FAILURE);
  }
  free(source);
  fclose(sourceFile);
  NvCliCompiledProgramFree(binary);
  fclose(binaryFile);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1274 <main+0x64>
cmpl   $0x4,-0x8(%rbp)
jle    1290 <main+0x80>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x70(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    12d5 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12e0 <main+0xd0>
lea    0xd96(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x60(%rbp),%rdi
lea    0xd4b(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1316 <main+0x106>
mov    -0x60(%rbp),%rdi
call   10f0 <perror@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x60(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1347 <main+0x137>
mov    -0x60(%rbp),%rdi
call   10f0 <perror@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x78(%rbp),%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1384 <main+0x174>
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
lea    0xcc8(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%rax
movslq -0x78(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
movslq -0x78(%rbp),%rax
shr    $0x0,%rax
mov    %eax,%edx
mov    -0x58(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
movslq -0x78(%rbp),%rcx
shr    $0x0,%rcx
cmp    %rcx,%rax
je     13dc <main+0x1cc>
mov    -0x60(%rbp),%rdi
call   10f0 <perror@plt>
mov    0x2c03(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
lea    -0x48(%rbp),%r8
lea    -0x40(%rbp),%r9
call   1090 <NvCliCompileProgram@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     14ae <main+0x29e>
mov    -0x48(%rbp),%rdi
lea    0xc4a(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1497 <main+0x287>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1466 <main+0x256>
mov    -0x60(%rbp),%rsi
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x88(%rbp),%rsi
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xbeb(%rip),%rsi
call   1100 <strtok@plt>
mov    %rax,-0x88(%rbp)
jmp    1433 <main+0x223>
mov    -0x48(%rbp),%rdi
call   1070 <NvCliCompileLogFree@plt>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
cmpq   $0x0,-0x40(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x70(%rbp),%rdi
lea    0xba8(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    14f6 <main+0x2e6>
mov    -0x70(%rbp),%rdi
call   10f0 <perror@plt>
mov    0x2ae9(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    %rax,%rdx
mov    -0x68(%rbp),%rcx
mov    $0x1,%esi
call   1130 <fwrite@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
cmp    %rcx,%rax
je     1564 <main+0x354>
mov    -0x70(%rbp),%rdi
call   10f0 <perror@plt>
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1110 <NvCliCompiledProgramFree@plt>
mov    -0x68(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a41(%rip),%rax
mov    (%rax),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    -0x5(%rdi),%eax
cmp    $0xfffffffd,%eax
jbe    13b7 <main+0x197>
lea    -0x2(%rdi),%eax
mov    (%rsi,%rax,8),%r15
lea    -0x1(%rdi),%eax
cmp    $0x4,%edi
jb     1260 <main+0x40>
mov    0x8(%rsi),%r13
jmp    1267 <main+0x47>
lea    0xdd0(%rip),%r13
mov    (%rsi,%rax,8),%r14
lea    0xd8e(%rip),%rsi
mov    %r15,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     139c <main+0x17c>
mov    %rax,%r12
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   10d0 <stat@plt>
test   %eax,%eax
jne    139c <main+0x17c>
movslq 0x8(%rsp),%rbp
lea    0x1(%rbp),%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     13d1 <main+0x1b1>
mov    %rax,%rbx
movb   $0x0,(%rax,%rbp,1)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
cmp    %rbp,%rax
jne    139c <main+0x17c>
mov    %rbx,0x20(%rsp)
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %rax,0x18(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%r8
mov    %rsp,%r9
mov    $0x1,%esi
mov    %r13,%rcx
call   10a0 <NvCliCompileProgram@plt>
test   %eax,%eax
jne    13e8 <main+0x1c8>
xor    %edi,%edi
cmpq   $0x0,(%rsp)
setne  %dil
call   10b0 <assert@plt>
lea    0xd18(%rip),%rsi
mov    %r14,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13a1 <main+0x181>
mov    %rax,%r15
mov    (%rsp),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r15,%rcx
call   1140 <fwrite@plt>
mov    %rax,%rbp
mov    (%rsp),%rdi
call   1070 <strlen@plt>
cmp    %rax,%rbp
jne    13a1 <main+0x181>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    (%rsp),%rdi
call   1120 <NvCliCompiledProgramFree@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
jmp    13a4 <main+0x184>
mov    %r14,%rdi
call   1100 <perror@plt>
mov    0x2c28(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xc81(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
lea    0xc22(%rip),%rsi
call   10c0 <fprintf@plt>
jmp    13a9 <main+0x189>
mov    0x10(%rsp),%rdi
lea    0xc42(%rip),%rsi
call   1110 <strtok@plt>
test   %rax,%rax
jne    140a <main+0x1ea>
mov    0x10(%rsp),%rdi
call   1080 <NvCliCompileLogFree@plt>
jmp    13a9 <main+0x189>
mov    %rax,%rbx
lea    0xc24(%rip),%r14
lea    0xc1b(%rip),%r12
jmp    143a <main+0x21a>
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1110 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     13fe <main+0x1de>
cmpb   $0x3a,(%rbx)
jne    1420 <main+0x200>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1420 <main+0x200>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [54 x i8] c"Usage: clcc [\22compiler-options\22] input.cl output.ptx\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"rb\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.3 = [51 x i8] c"malloc: Unable to allocate memory for source file.\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [4 x i8] c"w+b\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 [1 x i8*]
%9 = alloca [1 x i64]
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i8*
%18 = alloca %struct.stat
%19 = alloca i64
%20 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32* null, i32** %14
store i8* null, i8** %15
store i32* null, i32** %16
store i8* null, i8** %17
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 3
br i1 %22, label %26, label %23
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 4
br i1 %25, label %26, label %30
26: ; preds = %23, %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %31, i64 %34
%36 = load i8*, i8** %35
store i8* %36, i8** %15
%37 = load i8**, i8*** %5
%38 = load i32, i32* %4
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
store i8* %42, i8** %17
%43 = load i32, i32* %4
%44 = icmp sgt i32 %43, 3
br i1 %44, label %45, label %49
45: ; preds = %30
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
store i8* %48, i8** %7
br label %50
49: ; preds = %30
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %50
50: ; preds = %49, %45
%51 = load i8*, i8** %15
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %52, i32** %14
%53 = load i32*, i32** %14
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %60
55: ; preds = %50
%56 = load i8*, i8** %15
%57 = call i32 @perror(i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %50
%61 = load i8*, i8** %15
%62 = call i32 @stat(i8* %61, %struct.stat* %18)
store i32 %62, i32* %13
%63 = load i32, i32* %13
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %60
%66 = load i8*, i8** %15
%67 = call i32 @perror(i8* %66)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %60
%71 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%72 = load i32, i32* %71
%73 = add nsw i32 %72, 1
%74 = call i64 @malloc(i32 %73)
%75 = inttoptr i64 %74 to i8*
store i8* %75, i8** %6
%76 = load i8*, i8** %6
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %83
78: ; preds = %70
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %70
%84 = load i8*, i8** %6
%85 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%86 = load i32, i32* %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %84, i64 %87
store i8 0, i8* %88
%89 = load i8*, i8** %6
%90 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = udiv i64 %92, 1
%94 = trunc i64 %93 to i32
%95 = load i32*, i32** %14
%96 = call i64 @fread(i8* %89, i32 1, i32 %94, i32* %95)
store i64 %96, i64* %19
%97 = load i64, i64* %19
%98 = getelementptr inbounds %struct.stat, %struct.stat* %18, i32 0, i32 0
%99 = load i32, i32* %98
%100 = sext i32 %99 to i64
%101 = udiv i64 %100, 1
%102 = icmp ne i64 %97, %101
br i1 %102, label %103, label %108
103: ; preds = %83
%104 = load i8*, i8** %15
%105 = call i32 @perror(i8* %104)
%106 = load i32, i32* @EXIT_FAILURE
%107 = call i32 @exit(i32 %106)
unreachable
108: ; preds = %83
%109 = load i8*, i8** %6
%110 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
store i8* %109, i8** %110
%111 = load i8*, i8** %6
%112 = call i64 @strlen(i8* %111)
%113 = getelementptr inbounds [1 x i64], [1 x i64]* %9, i64 0, i64 0
store i64 %112, i64* %113
%114 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%115 = getelementptr inbounds [1 x i64], [1 x i64]* %9, i64 0, i64 0
%116 = load i8*, i8** %7
%117 = call i32 @NvCliCompileProgram(i8** %114, i32 1, i64* %115, i8* %116, i8** %12, i8** %11)
store i32 %117, i32* %13
%118 = load i32, i32* %13
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %144
120: ; preds = %108
%121 = load i8*, i8** %12
%122 = call i8* @strtok(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %122, i8** %20
br label %123
123: ; preds = %135, %120
%124 = load i8*, i8** %20
%125 = icmp ne i8* %124, null
br i1 %125, label %126, label %139
126: ; preds = %123
%127 = load i8*, i8** %20
%128 = getelementptr inbounds i8, i8* %127, i64 0
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = icmp eq i32 %130, 58
br i1 %131, label %132, label %135
132: ; preds = %126
%133 = load i8*, i8** %15
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %133)
br label %135
135: ; preds = %132, %126
%136 = load i8*, i8** %20
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %136)
%138 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %138, i8** %20
br label %123
139: ; preds = %123
%140 = load i8*, i8** %12
%141 = call i32 @NvCliCompileLogFree(i8* %140)
%142 = load i32, i32* @EXIT_FAILURE
%143 = call i32 @exit(i32 %142)
unreachable
144: ; preds = %108
%145 = load i8*, i8** %11
%146 = icmp ne i8* %145, null
%147 = zext i1 %146 to i32
%148 = call i32 @assert(i32 %147)
%149 = load i8*, i8** %17
%150 = call i32* @fopen(i8* %149, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i32* %150, i32** %16
%151 = load i32*, i32** %16
%152 = icmp eq i32* %151, null
br i1 %152, label %153, label %158
153: ; preds = %144
%154 = load i8*, i8** %17
%155 = call i32 @perror(i8* %154)
%156 = load i32, i32* @EXIT_FAILURE
%157 = call i32 @exit(i32 %156)
unreachable
158: ; preds = %144
%159 = load i8*, i8** %11
%160 = load i8*, i8** %11
%161 = call i64 @strlen(i8* %160)
%162 = load i32*, i32** %16
%163 = call i64 @fwrite(i8* %159, i32 1, i64 %161, i32* %162)
store i64 %163, i64* %19
%164 = load i64, i64* %19
%165 = load i8*, i8** %11
%166 = call i64 @strlen(i8* %165)
%167 = icmp ne i64 %164, %166
br i1 %167, label %168, label %173
168: ; preds = %158
%169 = load i8*, i8** %17
%170 = call i32 @perror(i8* %169)
%171 = load i32, i32* @EXIT_FAILURE
%172 = call i32 @exit(i32 %171)
unreachable
173: ; preds = %158
%174 = load i8*, i8** %6
%175 = call i32 @free(i8* %174)
%176 = load i32*, i32** %14
%177 = call i32 @fclose(i32* %176)
%178 = load i8*, i8** %11
%179 = call i32 @NvCliCompiledProgramFree(i8* %178)
%180 = load i32*, i32** %16
%181 = call i32 @fclose(i32* %180)
%182 = load i32, i32* @EXIT_SUCCESS
ret i32 %182
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@EXIT_SUCCESS = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"rb\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.3 = [51 x i8] c"malloc: Unable to allocate memory for source file.\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.7 = [4 x i8] c"w+b\00"
@str = [53 x i8] c"Usage: clcc [\22compiler-options\22] input.cl output.ptx\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8*]
%4 = alloca [1 x i64]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = bitcast [1 x i8*]* %3 to i8*
%9 = bitcast [1 x i64]* %4 to i8*
%10 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%11 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%12 = bitcast %struct.stat* %7 to i8*
%13 = add i32 %0, -5
%14 = icmp ult i32 %13, -2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_SUCCESS
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = add nsw i32 %0, -2
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = add nsw i32 %0, -1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = icmp ugt i32 %0, 3
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = getelementptr inbounds i8*, i8** %1, i64 1
%31 = load i8*, i8** %30
br label %32
32: ; preds = %19, %29
%33 = phi i8* [ %31, %29 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %19 ]
%34 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = tail call i32 @perror(i8* %23)
%38 = load i32, i32* @EXIT_FAILURE
%39 = tail call i32 @exit(i32 %38)
unreachable
40: ; preds = %32
%41 = call i32 @stat(i8* %23, %struct.stat* %7)
%42 = icmp eq i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %40
%44 = tail call i32 @perror(i8* %23)
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %40
%48 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
%51 = tail call i64 @malloc(i32 %50)
%52 = inttoptr i64 %51 to i8*
%53 = icmp eq i64 %51, 0
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = load i32, i32* @stderr
%56 = tail call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %47
%60 = sext i32 %49 to i64
%61 = getelementptr inbounds i8, i8* %52, i64 %60
store i8 0, i8* %61
%62 = tail call i64 @fread(i8* %52, i32 1, i32 %49, i32* %34)
%63 = icmp eq i64 %62, %60
br i1 %63, label %68, label %64
64: ; preds = %59
%65 = tail call i32 @perror(i8* %23)
%66 = load i32, i32* @EXIT_FAILURE
%67 = tail call i32 @exit(i32 %66)
unreachable
68: ; preds = %59
%69 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
store i8* %52, i8** %69
%70 = tail call i64 @strlen(i8* %52)
%71 = getelementptr inbounds [1 x i64], [1 x i64]* %4, i64 0, i64 0
store i64 %70, i64* %71
%72 = call i32 @NvCliCompileProgram(i8** %69, i32 1, i64* %71, i8* %33, i8** %6, i8** %5)
%73 = icmp eq i32 %72, 0
br i1 %73, label %93, label %74
74: ; preds = %68
%75 = load i8*, i8** %6
%76 = call i8* @strtok(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%77 = icmp eq i8* %76, null
br i1 %77, label %88, label %78
78: ; preds = %74, %84
%79 = phi i8* [ %86, %84 ], [ %76, %74 ]
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 58
br i1 %81, label %82, label %84
82: ; preds = %78
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %23)
br label %84
84: ; preds = %82, %78
%85 = call i32 @puts(i8* %79)
%86 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %78
88: ; preds = %84, %74
%89 = load i8*, i8** %6
%90 = call i32 @NvCliCompileLogFree(i8* %89)
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %68
%94 = load i8*, i8** %5
%95 = icmp ne i8* %94, null
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
%98 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%99 = icmp eq i32* %98, null
br i1 %99, label %100, label %104
100: ; preds = %93
%101 = call i32 @perror(i8* %27)
%102 = load i32, i32* @EXIT_FAILURE
%103 = call i32 @exit(i32 %102)
unreachable
104: ; preds = %93
%105 = load i8*, i8** %5
%106 = call i64 @strlen(i8* dereferenceable(1) %105)
%107 = call i64 @fwrite(i8* %105, i32 1, i64 %106, i32* %98)
%108 = load i8*, i8** %5
%109 = call i64 @strlen(i8* dereferenceable(1) %108)
%110 = icmp eq i64 %107, %109
br i1 %110, label %115, label %111
111: ; preds = %104
%112 = call i32 @perror(i8* %27)
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %104
%116 = call i32 @free(i8* %52)
%117 = call i32 @fclose(i32* %34)
%118 = load i8*, i8** %5
%119 = call i32 @NvCliCompiledProgramFree(i8* %118)
%120 = call i32 @fclose(i32* %98)
%121 = load i32, i32* @EXIT_SUCCESS
ret i32 %121
}