#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*/ printf(char *, char *);
int pthread_cond_signal(int /*<<< orphan*/ *);
int pthread_mutex_lock(int /*<<< orphan*/ *);
int pthread_mutex_unlock(int /*<<< orphan*/ *);
char *strerror(int);
void pthr_cond_signal_mutex(pthread_cond_t *cond, pthread_mutex_t *mut) {
  int err;
  err = pthread_mutex_lock(mut);
  if (err)
    printf("mutex_lock  : %s\n", strerror(err));
  err = pthread_cond_signal(cond);
  if (err)
    printf("cond_signal : %s\n", strerror(err));
  err = pthread_mutex_unlock(mut);
  if (err)
    printf("mutex_unlock: %s\n", strerror(err));
}


x86 assembly (clang, -O0):
<pthr_cond_signal_mutex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <pthread_mutex_lock@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     118d <pthr_cond_signal_mutex+0x3d>
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <pthread_cond_signal@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ba <pthr_cond_signal_mutex+0x6a>
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <pthread_mutex_unlock@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11e7 <pthr_cond_signal_mutex+0x97>
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthr_cond_signal_mutex>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1070 <pthread_mutex_lock@plt>
test   %eax,%eax
je     117c <pthr_cond_signal_mutex+0x2c>
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe8c(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <pthread_cond_signal@plt>
test   %eax,%eax
je     119e <pthr_cond_signal_mutex+0x4e>
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <pthread_mutex_unlock@plt>
test   %eax,%eax
je     11c7 <pthr_cond_signal_mutex+0x77>
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe6c(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"mutex_lock : %s\0A\00"
@.str.1 = [18 x i8] c"cond_signal : %s\0A\00"
@.str.2 = [18 x i8] c"mutex_unlock: %s\0A\00"
define void @pthr_cond_signal_mutex(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @pthread_mutex_lock(i32* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %5
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %10, %2
%15 = load i32*, i32** %3
%16 = call i32 @pthread_cond_signal(i32* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* %5
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %14
%24 = load i32*, i32** %4
%25 = call i32 @pthread_mutex_unlock(i32* %24)
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* %5
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %23
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"mutex_lock : %s\0A\00"
@.str.1 = [18 x i8] c"cond_signal : %s\0A\00"
@.str.2 = [18 x i8] c"mutex_unlock: %s\0A\00"
define void @pthr_cond_signal_mutex(i32* %0, i32* %1) {
%3 = tail call i32 @pthread_mutex_lock(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i8* @strerror(i32 %3)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %5, %2
%9 = tail call i32 @pthread_cond_signal(i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i8* @strerror(i32 %9)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %8
%15 = tail call i32 @pthread_mutex_unlock(i32* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i8* @strerror(i32 %15)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %14
ret void
}