#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_cond_t;

/* Variables and functions */
int lksmith_cond_predestroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ lksmith_error(int, char *, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/, int);
int r_pthread_cond_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ terror(int);
int pthread_cond_destroy(pthread_cond_t *cond) {
  int ret = lksmith_cond_predestroy(cond);
  if (ret)
    return ret;
  ret = r_pthread_cond_destroy(cond);
  if (ret) {
    lksmith_error(ret,
                  "pthread_cond_destroy(cond=%p): "
                  "failed with error %s (%d)",
                  cond, terror(ret), ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<pthread_cond_destroy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <lksmith_cond_predestroy@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116d <pthread_cond_destroy+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <pthread_cond_destroy+0x78>
mov    -0x10(%rbp),%rdi
call   1050 <r_pthread_cond_destroy@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b2 <pthread_cond_destroy+0x72>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <terror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
lea    0xe53(%rip),%rsi
call   1040 <lksmith_error@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthread_cond_destroy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <lksmith_cond_predestroy@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    1181 <pthread_cond_destroy+0x41>
mov    %r14,%rdi
call   1050 <r_pthread_cond_destroy@plt>
test   %eax,%eax
je     117f <pthread_cond_destroy+0x3f>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <terror@plt>
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
mov    %ebx,%r8d
call   1040 <lksmith_error@plt>
jmp    1181 <pthread_cond_destroy+0x41>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [57 x i8] c"pthread_cond_destroy(cond=%p): failed with error %s (%d)\00"
define i32 @pthread_cond_destroy(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 @lksmith_cond_predestroy(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 %25
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = call i32 @r_pthread_cond_destroy(i32* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* %4
%18 = load i32*, i32** %3
%19 = load i32, i32* %4
%20 = call i32 @terror(i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @lksmith_error(i32 %17, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32* %18, i32 %20, i32 %21)
br label %23
23: ; preds = %16, %11
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %25
25: ; preds = %23, %9
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [57 x i8] c"pthread_cond_destroy(cond=%p): failed with error %s (%d)\00"
define i32 @pthread_cond_destroy(i32* %0) {
%2 = tail call i32 @lksmith_cond_predestroy(i32* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call i32 @r_pthread_cond_destroy(i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @terror(i32 %5)
%9 = tail call i32 @lksmith_error(i32 %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32* %0, i32 %8, i32 %5)
br label %10
10: ; preds = %4, %7, %1
%11 = phi i32 [ %2, %1 ], [ %5, %7 ], [ 0, %4 ]
ret i32 %11
}