#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*/ pthread_mutex_t;
typedef int /*<<< orphan*/ pthread_cond_t;

/* Variables and functions */
int /*<<< orphan*/ debug(char *);
int /*<<< orphan*/ pthread_cond_broadcast(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_cond_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_cond_init(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_cond_signal(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_init(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
int main() {
  pthread_cond_t cond;
  pthread_mutex_t mutex;
  debug("Testing pthread_cond_*\n");
  pthread_cond_init(&cond, NULL);
  pthread_mutex_init(&mutex, NULL);
  pthread_mutex_lock(&mutex);
  pthread_cond_signal(&cond);
  pthread_cond_broadcast(&cond);
  pthread_mutex_unlock(&mutex);
  pthread_cond_destroy(&cond);
  debug("OK ! \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1040 <debug@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <pthread_cond_init@plt>
lea    -0xc(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <pthread_mutex_init@plt>
lea    -0xc(%rbp),%rdi
call   10a0 <pthread_mutex_lock@plt>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_cond_signal@plt>
lea    -0x8(%rbp),%rdi
call   1030 <pthread_cond_broadcast@plt>
lea    -0xc(%rbp),%rdi
call   1070 <pthread_mutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1080 <pthread_cond_destroy@plt>
lea    0xe2f(%rip),%rdi
call   1040 <debug@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe75(%rip),%rdi
call   1040 <debug@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <pthread_cond_init@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <pthread_mutex_init@plt>
mov    %r14,%rdi
call   10a0 <pthread_mutex_lock@plt>
mov    %rbx,%rdi
call   1050 <pthread_cond_signal@plt>
mov    %rbx,%rdi
call   1030 <pthread_cond_broadcast@plt>
mov    %r14,%rdi
call   1070 <pthread_mutex_unlock@plt>
mov    %rbx,%rdi
call   1080 <pthread_cond_destroy@plt>
lea    0xe3d(%rip),%rdi
call   1040 <debug@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Testing pthread_cond_*\0A\00"
@.str.1 = [7 x i8] c"OK ! \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @debug(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @pthread_cond_init(i32* %2, i32* null)
%6 = call i32 @pthread_mutex_init(i32* %3, i32* null)
%7 = call i32 @pthread_mutex_lock(i32* %3)
%8 = call i32 @pthread_cond_signal(i32* %2)
%9 = call i32 @pthread_cond_broadcast(i32* %2)
%10 = call i32 @pthread_mutex_unlock(i32* %3)
%11 = call i32 @pthread_cond_destroy(i32* %2)
%12 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Testing pthread_cond_*\0A\00"
@.str.1 = [7 x i8] c"OK ! \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @debug(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @pthread_cond_init(i32* %1, i32* null)
%7 = call i32 @pthread_mutex_init(i32* %2, i32* null)
%8 = call i32 @pthread_mutex_lock(i32* %2)
%9 = call i32 @pthread_cond_signal(i32* %1)
%10 = call i32 @pthread_cond_broadcast(i32* %1)
%11 = call i32 @pthread_mutex_unlock(i32* %2)
%12 = call i32 @pthread_cond_destroy(i32* %1)
%13 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}