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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int pthread_cond_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_condattr_destroy(int /*<<< orphan*/ *);
int pthread_condattr_init(int /*<<< orphan*/ *);
int pthread_condattr_setclock(int /*<<< orphan*/ *, int /*<<< orphan*/);
int pthread_cond_init_mt(pthread_cond_t *cond) {
  int ret;
  pthread_condattr_t attr;
  ret = pthread_condattr_init(&attr);
  if (ret)
    return ret;
  ret = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
  if (ret) {
    pthread_condattr_destroy(&attr);
    return ret;
  }
  ret = pthread_cond_init(cond, &attr);
  if (ret) {
    pthread_condattr_destroy(&attr);
    return ret;
  }
  pthread_condattr_destroy(&attr);
  return 0;
}


x86 assembly (clang, -O0):
<pthread_cond_init_mt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <pthread_condattr_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116d <pthread_cond_init_mt+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11de <pthread_cond_init_mt+0x9e>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdi
call   1040 <pthread_condattr_setclock@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a0 <pthread_cond_init_mt+0x60>
lea    -0x18(%rbp),%rdi
call   1030 <pthread_condattr_destroy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11de <pthread_cond_init_mt+0x9e>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <pthread_cond_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ce <pthread_cond_init_mt+0x8e>
lea    -0x18(%rbp),%rdi
call   1030 <pthread_condattr_destroy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11de <pthread_cond_init_mt+0x9e>
lea    -0x18(%rbp),%rdi
call   1030 <pthread_condattr_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthread_cond_init_mt>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
call   1060 <pthread_condattr_init@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1188 <pthread_cond_init_mt+0x48>
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdi
call   1040 <pthread_condattr_setclock@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    117e <pthread_cond_init_mt+0x3e>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <pthread_cond_init@plt>
mov    %eax,%ebp
lea    0x4(%rsp),%rdi
call   1030 <pthread_condattr_destroy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@CLOCK_MONOTONIC = global i32 0
define i32 @pthread_cond_init_mt(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = call i32 @pthread_condattr_init(i32* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32, i32* %4
store i32 %10, i32* %2
br label %29
11: ; preds = %1
%12 = load i32, i32* @CLOCK_MONOTONIC
%13 = call i32 @pthread_condattr_setclock(i32* %5, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 @pthread_condattr_destroy(i32* %5)
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %29
19: ; preds = %11
%20 = load i32*, i32** %3
%21 = call i32 @pthread_cond_init(i32* %20, i32* %5)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i32 @pthread_condattr_destroy(i32* %5)
%26 = load i32, i32* %4
store i32 %26, i32* %2
br label %29
27: ; preds = %19
%28 = call i32 @pthread_condattr_destroy(i32* %5)
store i32 0, i32* %2
br label %29
29: ; preds = %27, %24, %16, %9
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@CLOCK_MONOTONIC = global i32 0
define i32 @pthread_cond_init_mt(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @pthread_condattr_init(i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = load i32, i32* @CLOCK_MONOTONIC
%8 = call i32 @pthread_condattr_setclock(i32* %2, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @pthread_cond_init(i32* %0, i32* %2)
br label %12
12: ; preds = %6, %10
%13 = phi i32 [ %11, %10 ], [ %8, %6 ]
%14 = call i32 @pthread_condattr_destroy(i32* %2)
br label %15
15: ; preds = %12, %1
%16 = phi i32 [ %4, %1 ], [ %13, %12 ]
ret i32 %16
}