#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 gfs2_holder {
  int dummy;
};
struct gfs2_glock {
  int dummy;
};

/* Variables and functions */
int gfs2_glock_nq(struct gfs2_holder *);
int /*<<< orphan*/ gfs2_holder_init(struct gfs2_glock *, unsigned int, int,
                                    struct gfs2_holder *);
int /*<<< orphan*/ gfs2_holder_uninit(struct gfs2_holder *);
int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags,
                       struct gfs2_holder *gh) {
  int error;
  gfs2_holder_init(gl, state, flags, gh);
  error = gfs2_glock_nq(gh);
  if (error)
    gfs2_holder_uninit(gh);
  return error;
}


x86 assembly (clang, -O0):
<gfs2_glock_nq_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1050 <gfs2_holder_init@plt>
mov    -0x18(%rbp),%rdi
call   1030 <gfs2_glock_nq@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1178 <gfs2_glock_nq_init+0x48>
mov    -0x18(%rbp),%rdi
call   1040 <gfs2_holder_uninit@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfs2_glock_nq_init>:
push   %rbp
push   %rbx
push   %rax
mov    %rcx,%rbx
call   1050 <gfs2_holder_init@plt>
mov    %rbx,%rdi
call   1030 <gfs2_glock_nq@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1151 <gfs2_glock_nq_init+0x21>
mov    %rbx,%rdi
call   1040 <gfs2_holder_uninit@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.gfs2_glock = type { i32 }
%struct.gfs2_holder = type { i32 }
define i32 @gfs2_glock_nq_init(%struct.gfs2_glock* %0, i32 %1, i32 %2, %struct.gfs2_holder* %3) {
%5 = alloca %struct.gfs2_glock*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.gfs2_holder*
%9 = alloca i32
store %struct.gfs2_glock* %0, %struct.gfs2_glock** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store %struct.gfs2_holder* %3, %struct.gfs2_holder** %8
%10 = load %struct.gfs2_glock*, %struct.gfs2_glock** %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = load %struct.gfs2_holder*, %struct.gfs2_holder** %8
%14 = call i32 @gfs2_holder_init(%struct.gfs2_glock* %10, i32 %11, i32 %12, %struct.gfs2_holder* %13)
%15 = load %struct.gfs2_holder*, %struct.gfs2_holder** %8
%16 = call i32 @gfs2_glock_nq(%struct.gfs2_holder* %15)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %4
%20 = load %struct.gfs2_holder*, %struct.gfs2_holder** %8
%21 = call i32 @gfs2_holder_uninit(%struct.gfs2_holder* %20)
br label %22
22: ; preds = %19, %4
%23 = load i32, i32* %9
ret i32 %23
}

LLVM IR (-O2):
%struct.gfs2_glock = type { i32 }
%struct.gfs2_holder = type { i32 }
define i32 @gfs2_glock_nq_init(%struct.gfs2_glock* %0, i32 %1, i32 %2, %struct.gfs2_holder* %3) {
%5 = tail call i32 @gfs2_holder_init(%struct.gfs2_glock* %0, i32 %1, i32 %2, %struct.gfs2_holder* %3)
%6 = tail call i32 @gfs2_glock_nq(%struct.gfs2_holder* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @gfs2_holder_uninit(%struct.gfs2_holder* %3)
br label %10
10: ; preds = %8, %4
ret i32 %6
}