#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 */
struct timespec {
  int dummy;
};
typedef int /*<<< orphan*/ pthread_mutex_t;
typedef int /*<<< orphan*/ pthread_cond_t;
typedef int /*<<< orphan*/ now;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_COND_INITIALIZER;
int /*<<< orphan*/ PTHREAD_MUTEX_INITIALIZER;
int /*<<< orphan*/ memset(struct timespec *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pthread_cond_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_cond_timedwait(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          struct timespec *);
int /*<<< orphan*/ pthread_mutex_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
int main() {
  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
  struct timespec now;
  memset(&now, 0, sizeof(now));
  pthread_mutex_lock(&mutex);
  pthread_cond_timedwait(&cond, &mutex, &now);
  pthread_mutex_unlock(&mutex);
  pthread_mutex_destroy(&mutex);
  pthread_cond_destroy(&cond);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    -0x8(%rbp),%rdi
call   1080 <pthread_mutex_lock@plt>
lea    -0xc(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <pthread_cond_timedwait@plt>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
lea    -0x8(%rbp),%rdi
call   1030 <pthread_mutex_destroy@plt>
lea    -0xc(%rbp),%rdi
call   1070 <pthread_cond_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <pthread_mutex_lock@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <pthread_cond_timedwait@plt>
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %rbx,%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    %r15,%rdi
call   1070 <pthread_cond_destroy@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@PTHREAD_COND_INITIALIZER = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.timespec
store i32 0, i32* %1
%5 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %5, i32* %2
%6 = load i32, i32* @PTHREAD_COND_INITIALIZER
store i32 %6, i32* %3
%7 = call i32 @memset(%struct.timespec* %4, i32 0, i32 4)
%8 = call i32 @pthread_mutex_lock(i32* %2)
%9 = call i32 @pthread_cond_timedwait(i32* %3, i32* %2, %struct.timespec* %4)
%10 = call i32 @pthread_mutex_unlock(i32* %2)
%11 = call i32 @pthread_mutex_destroy(i32* %2)
%12 = call i32 @pthread_cond_destroy(i32* %3)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@PTHREAD_COND_INITIALIZER = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = bitcast i32* %1 to i8*
%5 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %5, i32* %1
%6 = bitcast i32* %2 to i8*
%7 = load i32, i32* @PTHREAD_COND_INITIALIZER
store i32 %7, i32* %2
%8 = bitcast %struct.timespec* %3 to i8*
%9 = call i32 @memset(%struct.timespec* %3, i32 0, i32 4)
%10 = call i32 @pthread_mutex_lock(i32* %1)
%11 = call i32 @pthread_cond_timedwait(i32* %2, i32* %1, %struct.timespec* %3)
%12 = call i32 @pthread_mutex_unlock(i32* %1)
%13 = call i32 @pthread_mutex_destroy(i32* %1)
%14 = call i32 @pthread_cond_destroy(i32* %2)
ret i32 0
}