#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*/ lou_free();
void *lou_getTable(char const *);
int /*<<< orphan*/ printf(char *, char const *);
int main(int argc, char **argv) {
  const char *goodTable = "en-us-g1.ctb";
  const char *badTable = "bad.ctb";
  void *table = NULL;
  int result = 0;
  table = lou_getTable(goodTable);
  if (!table) {
    printf("Getting %s failed, expected success\n", goodTable);
    result = 1;
  } else
    table = NULL;
  table = lou_getTable(badTable);
  if (table) {
    printf("Getting %s succeeded, expected failure\n", badTable);
    table = NULL;
    result = 1;
  }
  table = lou_getTable(goodTable);
  if (!table) {
    printf("Getting %s failed, expected success\n", goodTable);
    result = 1;
  } else
    table = NULL;
  lou_free();
  return result;
}


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    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb5(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <lou_getTable@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119f <main+0x6f>
mov    -0x18(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    11a7 <main+0x77>
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <lou_getTable@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11de <main+0xae>
mov    -0x20(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <lou_getTable@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1212 <main+0xe2>
mov    -0x18(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    121a <main+0xea>
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <lou_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <lou_getTable@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    115c <main+0x2c>
lea    0xeca(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%ebx
lea    0xeaa(%rip),%rdi
call   1040 <lou_getTable@plt>
test   %rax,%rax
je     1185 <main+0x55>
lea    0xec6(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%ebx
lea    0xe74(%rip),%rdi
call   1040 <lou_getTable@plt>
test   %rax,%rax
jne    11ae <main+0x7e>
lea    0xe78(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%ebx
xor    %eax,%eax
call   1050 <lou_free@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"en-us-g1.ctb\00"
@.str.1 = [8 x i8] c"bad.ctb\00"
@.str.2 = [37 x i8] c"Getting %s failed, expected success\0A\00"
@.str.3 = [40 x i8] c"Getting %s succeeded, expected failure\0A\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* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i8* null, i8** %8
store i32 0, i32* %9
%10 = load i8*, i8** %6
%11 = call i8* @lou_getTable(i8* %10)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 1, i32* %9
br label %18
17: ; preds = %2
store i8* null, i8** %8
br label %18
18: ; preds = %17, %14
%19 = load i8*, i8** %7
%20 = call i8* @lou_getTable(i8* %19)
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %7
%25 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %24)
store i8* null, i8** %8
store i32 1, i32* %9
br label %26
26: ; preds = %23, %18
%27 = load i8*, i8** %6
%28 = call i8* @lou_getTable(i8* %27)
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = load i8*, i8** %6
%33 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %32)
store i32 1, i32* %9
br label %35
34: ; preds = %26
store i8* null, i8** %8
br label %35
35: ; preds = %34, %31
%36 = call i32 (...) @lou_free()
%37 = load i32, i32* %9
ret i32 %37
}

LLVM IR (-O2):
@.str = [13 x i8] c"en-us-g1.ctb\00"
@.str.1 = [8 x i8] c"bad.ctb\00"
@.str.2 = [37 x i8] c"Getting %s failed, expected success\0A\00"
@.str.3 = [40 x i8] c"Getting %s succeeded, expected failure\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @lou_getTable(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %2, %5
%8 = phi i32 [ 1, %5 ], [ 0, %2 ]
%9 = tail call i8* @lou_getTable(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ 1, %11 ], [ %8, %7 ]
%15 = tail call i8* @lou_getTable(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %13, %17
%20 = phi i32 [ 1, %17 ], [ %14, %13 ]
%21 = tail call i32 (...) @lou_free()
ret i32 %20
}