#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*/ printf(char *);
int /*<<< orphan*/ test_lock();
int /*<<< orphan*/ test_once();
int /*<<< orphan*/ test_thread_local();
int main(int argc, char **argv) {
  if (!test_lock())
    return 1;
  if (!test_once())
    return 1;
  if (!test_thread_local())
    return 1;
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <test_lock@plt>
cmp    $0x0,%eax
jne    1172 <main+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11bd <main+0x7d>
mov    $0x0,%al
call   1040 <test_once@plt>
cmp    $0x0,%eax
jne    118e <main+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    11bd <main+0x7d>
mov    $0x0,%al
call   1050 <test_thread_local@plt>
cmp    $0x0,%eax
jne    11aa <main+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11bd <main+0x7d>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <test_lock@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     1175 <main+0x35>
xor    %eax,%eax
call   1040 <test_once@plt>
test   %eax,%eax
je     1175 <main+0x35>
xor    %eax,%eax
call   1050 <test_thread_local@plt>
test   %eax,%eax
je     1175 <main+0x35>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"PASS\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 (...) @test_lock()
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 1, i32* %3
br label %19
9: ; preds = %2
%10 = call i32 (...) @test_once()
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9
store i32 1, i32* %3
br label %19
13: ; preds = %9
%14 = call i32 (...) @test_thread_local()
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %13
store i32 1, i32* %3
br label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %19
19: ; preds = %17, %16, %12, %8
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@str = [5 x i8] c"PASS\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @test_lock()
%4 = icmp eq i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = tail call i32 (...) @test_once()
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 (...) @test_thread_local()
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %8, %5, %2, %11
%14 = phi i32 [ 0, %11 ], [ 1, %2 ], [ 1, %5 ], [ 1, %8 ]
ret i32 %14
}