#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 */
struct libiso_msgs_item {
  int dummy;
};
struct libiso_msgs {
  int dummy;
};

/* Variables and functions */
int libiso_msgs_item_destroy(struct libiso_msgs_item **, int /*<<< orphan*/);
int libiso_msgs_lock(struct libiso_msgs *, int /*<<< orphan*/);
int /*<<< orphan*/ libiso_msgs_unlock(struct libiso_msgs *, int /*<<< orphan*/);
int libiso_msgs_destroy_item(struct libiso_msgs *m,
                             struct libiso_msgs_item **item, int flag) {
  int ret;
  ret = libiso_msgs_lock(m, 0);
  if (ret <= 0)
    return (-1);
  ret = libiso_msgs_item_destroy(item, 0);
  libiso_msgs_unlock(m, 0);
  return (ret);
}


x86 assembly (clang, -O0):
<libiso_msgs_destroy_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <libiso_msgs_lock@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     1167 <libiso_msgs_destroy_item+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    1186 <libiso_msgs_destroy_item+0x56>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1050 <libiso_msgs_item_destroy@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <libiso_msgs_unlock@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libiso_msgs_destroy_item>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <libiso_msgs_lock@plt>
test   %eax,%eax
jle    115f <libiso_msgs_destroy_item+0x2f>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <libiso_msgs_item_destroy@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <libiso_msgs_unlock@plt>
mov    %ebp,%eax
jmp    1164 <libiso_msgs_destroy_item+0x34>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.libiso_msgs = type { i32 }
%struct.libiso_msgs_item = type { i32 }
define i32 @libiso_msgs_destroy_item(%struct.libiso_msgs* %0, %struct.libiso_msgs_item** %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.libiso_msgs*
%6 = alloca %struct.libiso_msgs_item**
%7 = alloca i32
%8 = alloca i32
store %struct.libiso_msgs* %0, %struct.libiso_msgs** %5
store %struct.libiso_msgs_item** %1, %struct.libiso_msgs_item*** %6
store i32 %2, i32* %7
%9 = load %struct.libiso_msgs*, %struct.libiso_msgs** %5
%10 = call i32 @libiso_msgs_lock(%struct.libiso_msgs* %9, i32 0)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %20
14: ; preds = %3
%15 = load %struct.libiso_msgs_item**, %struct.libiso_msgs_item*** %6
%16 = call i32 @libiso_msgs_item_destroy(%struct.libiso_msgs_item** %15, i32 0)
store i32 %16, i32* %8
%17 = load %struct.libiso_msgs*, %struct.libiso_msgs** %5
%18 = call i32 @libiso_msgs_unlock(%struct.libiso_msgs* %17, i32 0)
%19 = load i32, i32* %8
store i32 %19, i32* %4
br label %20
20: ; preds = %14, %13
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
%struct.libiso_msgs = type { i32 }
%struct.libiso_msgs_item = type { i32 }
define i32 @libiso_msgs_destroy_item(%struct.libiso_msgs* %0, %struct.libiso_msgs_item** %1, i32 %2) {
%4 = tail call i32 @libiso_msgs_lock(%struct.libiso_msgs* %0, i32 0)
%5 = icmp slt i32 %4, 1
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @libiso_msgs_item_destroy(%struct.libiso_msgs_item** %1, i32 0)
%8 = tail call i32 @libiso_msgs_unlock(%struct.libiso_msgs* %0, i32 0)
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ %7, %6 ], [ -1, %3 ]
ret i32 %10
}