#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef int uint32_t;

/* Variables and functions */
int def_region(int, char *, int /*<<< orphan*/, int);
int enter_stacks(int, int /*<<< orphan*/, int);
int exit_stacks(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_category(int, char *);
int /*<<< orphan*/ print_threads();
int /*<<< orphan*/ printf(char *);
int test_dct(uint64_t bid, int message) {
  char *category = "dct";
  int error = 0;
  uint32_t rid = 1;
  print_category(message, category);
  if (message == 1)
    printf("Threads:\n");
  printf("init_dct_threads_before=");
  print_threads();
  printf("\n");
  error |= def_region(message, category, bid, rid);
  error |= enter_stacks(message, bid, rid);
  if (message == 1)
    printf("Threads:\n");
  printf("bin_dct_threads_before=");
  print_threads();
  printf("\n");
  error |= exit_stacks(message, bid, rid);
  if (message == 1)
    printf("Threads:\n");
  printf("bin_dct_threads_after=");
  print_threads();
  printf("\n");
  if (message == 1)
    printf("*********\n");
  return error;
}


x86 assembly (clang, -O0):
<test_dct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <print_category@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11a9 <test_dct+0x49>
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <print_threads@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <def_region@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <enter_stacks@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    120a <test_dct+0xaa>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <print_threads@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <exit_stacks@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1253 <test_dct+0xf3>
lea    0xdb6(%rip),%rdi
call   1040 <printf@plt>
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <print_threads@plt>
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1288 <test_dct+0x128>
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_dct>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r15d
lea    0xe6d(%rip),%rsi
mov    %ebx,%edi
call   1090 <print_category@plt>
cmp    $0x1,%ebx
jne    11ab <test_dct+0x2b>
lea    0xeb0(%rip),%rdi
call   1050 <puts@plt>
lea    0xe52(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <print_threads@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe31(%rip),%rsi
mov    %ebx,%edi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1070 <def_region@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1,%edx
call   1080 <enter_stacks@plt>
mov    %eax,%ebp
cmp    $0x1,%ebx
jne    1203 <test_dct+0x83>
lea    0xe58(%rip),%rdi
call   1050 <puts@plt>
lea    0xe13(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <print_threads@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1,%edx
call   1040 <exit_stacks@plt>
mov    %eax,%r15d
cmp    $0x1,%ebx
jne    126e <test_dct+0xee>
lea    0xe18(%rip),%rdi
call   1050 <puts@plt>
lea    0xdeb(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <print_threads@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde5(%rip),%rdi
call   1050 <puts@plt>
jmp    128b <test_dct+0x10b>
lea    0xdc0(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <print_threads@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
or     %r14d,%ebp
or     %r15d,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"dct\00"
@.str.1 = [10 x i8] c"Threads:\0A\00"
@.str.2 = [25 x i8] c"init_dct_threads_before=\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [24 x i8] c"bin_dct_threads_before=\00"
@.str.5 = [23 x i8] c"bin_dct_threads_after=\00"
@.str.6 = [11 x i8] c"*********\0A\00"
define i32 @test_dct(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5
store i32 0, i32* %6
store i32 1, i32* %7
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = call i32 @print_category(i32 %8, i8* %9)
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @print_threads()
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %3
%22 = load i32, i32* %7
%23 = call i32 @def_region(i32 %19, i8* %20, i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = or i32 %24, %23
store i32 %25, i32* %6
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = load i32, i32* %7
%29 = call i32 @enter_stacks(i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* %6
%31 = or i32 %30, %29
store i32 %31, i32* %6
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %15
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %15
%37 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 (...) @print_threads()
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* %4
%41 = load i32, i32* %3
%42 = load i32, i32* %7
%43 = call i32 @exit_stacks(i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* %6
%45 = or i32 %44, %43
store i32 %45, i32* %6
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %36
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %48, %36
%51 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 (...) @print_threads()
%53 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %58
58: ; preds = %56, %50
%59 = load i32, i32* %6
ret i32 %59
}

LLVM IR (-O2):
@.str = [4 x i8] c"dct\00"
@.str.2 = [25 x i8] c"init_dct_threads_before=\00"
@.str.4 = [24 x i8] c"bin_dct_threads_before=\00"
@.str.5 = [23 x i8] c"bin_dct_threads_after=\00"
@str = [10 x i8] c"*********\00"
@str.9 = [9 x i8] c"Threads:\00"
define i32 @test_dct(i32 %0, i32 %1) {
%3 = tail call i32 @print_category(i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %1, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @print_threads()
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @def_region(i32 %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0, i32 1)
%12 = tail call i32 @enter_stacks(i32 %1, i32 %0, i32 1)
br i1 %4, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 (...) @print_threads()
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @exit_stacks(i32 %1, i32 %0, i32 1)
br i1 %4, label %20, label %26
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i32 (...) @print_threads()
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %30
26: ; preds = %15
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%28 = tail call i32 (...) @print_threads()
%29 = tail call i32 @putchar(i32 10)
br label %30
30: ; preds = %26, %20
%31 = or i32 %12, %11
%32 = or i32 %31, %19
ret i32 %32
}