#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*/ lksmith_error(int, char *, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/, int);
int r_pthread_cond_init(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ terror(int);
int pthread_cond_init(pthread_cond_t *__restrict cond,
                      const pthread_condattr_t *__restrict attr) {
  int ret = r_pthread_cond_init(cond, attr);
  if (ret) {
    lksmith_error(ret,
                  "pthread_cond_init(mutex=%p): "
                  "failed with error %s (%d)",
                  cond, terror(ret), ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<pthread_cond_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <r_pthread_cond_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1189 <pthread_cond_init+0x59>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <terror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
lea    0xe7c(%rip),%rsi
call   1030 <lksmith_error@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthread_cond_init>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <r_pthread_cond_init@plt>
mov    %eax,%ebx
test   %eax,%eax
je     115f <pthread_cond_init+0x2f>
mov    %ebx,%edi
call   1050 <terror@plt>
lea    0xeb0(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
mov    %ebx,%r8d
call   1030 <lksmith_error@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [55 x i8] c"pthread_cond_init(mutex=%p): failed with error %s (%d)\00"
define i32 @pthread_cond_init(i32* noalias %0, i32* noalias %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = load i32*, i32** %4
%8 = call i32 @r_pthread_cond_init(i32* %6, i32* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* %5
%13 = load i32*, i32** %3
%14 = load i32, i32* %5
%15 = call i32 @terror(i32 %14)
%16 = load i32, i32* %5
%17 = call i32 @lksmith_error(i32 %12, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32* %13, i32 %15, i32 %16)
br label %18
18: ; preds = %11, %2
%19 = load i32, i32* %5
ret i32 %19
}

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