#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 snd_mask {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ snd_mask_empty(struct snd_mask *);
int /*<<< orphan*/ snd_mask_leave(struct snd_mask *, int /*<<< orphan*/);
int /*<<< orphan*/ snd_mask_min(struct snd_mask *);
scalar_t__ snd_mask_single(struct snd_mask *);
int snd_mask_refine_first(struct snd_mask *mask) {
  (void)(!snd_mask_empty(mask));
  if (snd_mask_single(mask))
    return 0;
  snd_mask_leave(mask, snd_mask_min(mask));
  return 1;
}


x86 assembly (clang, -O0):
<snd_mask_refine_first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <snd_mask_empty@plt>
mov    -0x10(%rbp),%rdi
call   1060 <snd_mask_single@plt>
cmp    $0x0,%rax
je     1174 <snd_mask_refine_first+0x34>
movl   $0x0,-0x4(%rbp)
jmp    1197 <snd_mask_refine_first+0x57>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <snd_mask_min@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <snd_mask_leave@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snd_mask_refine_first>:
push   %rbx
mov    %rdi,%rbx
call   1030 <snd_mask_empty@plt>
mov    %rbx,%rdi
call   1060 <snd_mask_single@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     115d <snd_mask_refine_first+0x1d>
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <snd_mask_min@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <snd_mask_leave@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.snd_mask = type { i32 }
define i32 @snd_mask_refine_first(%struct.snd_mask* %0) {
%2 = alloca i32
%3 = alloca %struct.snd_mask*
store %struct.snd_mask* %0, %struct.snd_mask** %3
%4 = load %struct.snd_mask*, %struct.snd_mask** %3
%5 = call i32 @snd_mask_empty(%struct.snd_mask* %4)
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
%8 = zext i1 %7 to i32
%9 = load %struct.snd_mask*, %struct.snd_mask** %3
%10 = call i64 @snd_mask_single(%struct.snd_mask* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %18
13: ; preds = %1
%14 = load %struct.snd_mask*, %struct.snd_mask** %3
%15 = load %struct.snd_mask*, %struct.snd_mask** %3
%16 = call i32 @snd_mask_min(%struct.snd_mask* %15)
%17 = call i32 @snd_mask_leave(%struct.snd_mask* %14, i32 %16)
store i32 1, i32* %2
br label %18
18: ; preds = %13, %12
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
%struct.snd_mask = type { i32 }
define i32 @snd_mask_refine_first(%struct.snd_mask* %0) {
%2 = tail call i32 @snd_mask_empty(%struct.snd_mask* %0)
%3 = tail call i64 @snd_mask_single(%struct.snd_mask* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @snd_mask_min(%struct.snd_mask* %0)
%7 = tail call i32 @snd_mask_leave(%struct.snd_mask* %0, i32 %6)
br label %8
8: ; preds = %1, %5
%9 = phi i32 [ 1, %5 ], [ 0, %1 ]
ret i32 %9
}