#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 *, ...);
char *test_condition(int /*<<< orphan*/);
char *test_thread_id(int /*<<< orphan*/);
int thread_tests() {
  int result = 0;
  char *test_group = "thread_tests";
  do {
    char *r = test_thread_id(0);
    printf("Test Case %s.%s: ", test_group, "test_thread_id");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  do {
    char *r = test_condition(0);
    printf("Test Case %s.%s: ", test_group, "test_condition");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  return result;
}


x86 assembly (clang, -O0):
<thread_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
call   1030 <test_thread_id@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xead(%rip),%rdi
lea    0xeb8(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     1199 <thread_tests+0x69>
mov    -0x18(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <thread_tests+0x77>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11ac <thread_tests+0x7c>
jmp    11b1 <thread_tests+0x81>
xor    %edi,%edi
call   1040 <test_condition@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe46(%rip),%rdi
lea    0xe70(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1200 <thread_tests+0xd0>
mov    -0x20(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120e <thread_tests+0xde>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1213 <thread_tests+0xe3>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thread_tests>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %edi,%edi
call   1030 <test_thread_id@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rdi
lea    0xea3(%rip),%rsi
lea    0xebb(%rip),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     1188 <thread_tests+0x48>
lea    0xeb7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebp
jmp    1194 <thread_tests+0x54>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <test_condition@plt>
mov    %rax,%rbx
lea    0xe68(%rip),%rdi
lea    0xe54(%rip),%rsi
lea    0xe85(%rip),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     11d5 <thread_tests+0x95>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
jmp    11e1 <thread_tests+0xa1>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"thread_tests\00"
@.str.1 = [18 x i8] c"Test Case %s.%s: \00"
@.str.2 = [15 x i8] c"test_thread_id\00"
@.str.3 = [10 x i8] c"FAIL: %s\0A\00"
@.str.4 = [6 x i8] c"PASS\0A\00"
@.str.5 = [15 x i8] c"test_condition\00"
define i32 @thread_tests() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %5
5: ; preds = %0
%6 = call i8* @test_thread_id(i32 0)
store i8* %6, i8** %3
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = load i8*, i8** %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %18
16: ; preds = %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = call i8* @test_condition(i32 0)
store i8* %21, i8** %4
%22 = load i8*, i8** %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%24 = load i8*, i8** %4
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %33
31: ; preds = %20
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %26
br label %34
34: ; preds = %33
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"thread_tests\00"
@.str.1 = [18 x i8] c"Test Case %s.%s: \00"
@.str.2 = [15 x i8] c"test_thread_id\00"
@.str.3 = [10 x i8] c"FAIL: %s\0A\00"
@.str.5 = [15 x i8] c"test_condition\00"
@str.6 = [5 x i8] c"PASS\00"
define i32 @thread_tests() {
%1 = tail call i8* @test_thread_id(i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i8* %1, null
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ 1, %4 ], [ 0, %6 ]
%10 = tail call i8* @test_condition(i32 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i8* %10, null
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%15 = add nuw nsw i32 %9, 1
br label %18
16: ; preds = %8
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %15, %13 ], [ %9, %16 ]
ret i32 %19
}