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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int pthread_mutex_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
void destroy_mutex(pthread_mutex_t *mutex, const char *mutex_desc) {
  int rc = pthread_mutex_destroy(mutex);
  if (rc != 0) {
    fprintf(stderr, "pthread_mutex_destroy failed for %s: %s\n", mutex_desc,
            strerror(rc));
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<destroy_mutex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pthread_mutex_destroy@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a2 <destroy_mutex+0x62>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe6d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destroy_mutex>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1030 <pthread_mutex_destroy@plt>
test   %eax,%eax
jne    1156 <destroy_mutex+0x16>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e83(%rip),%rcx
mov    (%rcx),%ebp
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe93(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"pthread_mutex_destroy failed for %s: %s\0A\00"
define void @destroy_mutex(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i32*, i32** %3
%7 = call i32 @pthread_mutex_destroy(i32* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"pthread_mutex_destroy failed for %s: %s\0A\00"
define void @destroy_mutex(i32* %0, i8* %1) {
%3 = tail call i32 @pthread_mutex_destroy(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i8* @strerror(i32 %3)
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %7)
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
ret void
}