#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_pcm_hw_params {
  int dummy;
};
struct snd_mask {
  int *bits;
};

/* Variables and functions */
unsigned int SNDRV_MASK_MAX;
scalar_t__ param_is_mask(int);
struct snd_mask *param_to_mask(struct snd_pcm_hw_params *, int);
void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit) {
  if (bit >= SNDRV_MASK_MAX)
    return;
  if (param_is_mask(n)) {
    struct snd_mask *m = param_to_mask(p, n);
    m->bits[0] = 0;
    m->bits[1] = 0;
    m->bits[bit >> 5] |= (1 << (bit & 31));
  }
}


x86 assembly (clang, -O0):
<param_set_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%eax
jb     1149 <param_set_mask+0x29>
jmp    11a8 <param_set_mask+0x88>
mov    -0xc(%rbp),%edi
call   1040 <param_is_mask@plt>
cmp    $0x0,%rax
je     11a8 <param_set_mask+0x88>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <param_to_mask@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%ecx
and    $0x1f,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
shr    $0x5,%ecx
mov    %ecx,%ecx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<param_set_mask>:
push   %rbp
push   %r14
push   %rbx
mov    0x2eb5(%rip),%rax
cmp    %edx,(%rax)
jbe    1165 <param_set_mask+0x45>
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   1040 <param_is_mask@plt>
test   %rax,%rax
je     1165 <param_set_mask+0x45>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <param_to_mask@plt>
mov    (%rax),%rax
movq   $0x0,(%rax)
mov    $0x1,%edx
mov    %ebx,%ecx
shl    %cl,%edx
shr    $0x5,%ebx
or     %edx,(%rax,%rbx,4)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.snd_pcm_hw_params = type { i32 }
%struct.snd_mask = type { i32* }
@SNDRV_MASK_MAX = global i32 0
define void @param_set_mask(%struct.snd_pcm_hw_params* %0, i32 %1, i32 %2) {
%4 = alloca %struct.snd_pcm_hw_params*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.snd_mask*
store %struct.snd_pcm_hw_params* %0, %struct.snd_pcm_hw_params** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* @SNDRV_MASK_MAX
%10 = icmp uge i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %3
br label %40
12: ; preds = %3
%13 = load i32, i32* %5
%14 = call i64 @param_is_mask(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %12
%17 = load %struct.snd_pcm_hw_params*, %struct.snd_pcm_hw_params** %4
%18 = load i32, i32* %5
%19 = call %struct.snd_mask* @param_to_mask(%struct.snd_pcm_hw_params* %17, i32 %18)
store %struct.snd_mask* %19, %struct.snd_mask** %7
%20 = load %struct.snd_mask*, %struct.snd_mask** %7
%21 = getelementptr inbounds %struct.snd_mask, %struct.snd_mask* %20, i32 0, i32 0
%22 = load i32*, i32** %21
%23 = getelementptr inbounds i32, i32* %22, i64 0
store i32 0, i32* %23
%24 = load %struct.snd_mask*, %struct.snd_mask** %7
%25 = getelementptr inbounds %struct.snd_mask, %struct.snd_mask* %24, i32 0, i32 0
%26 = load i32*, i32** %25
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32 0, i32* %27
%28 = load i32, i32* %6
%29 = and i32 %28, 31
%30 = shl i32 1, %29
%31 = load %struct.snd_mask*, %struct.snd_mask** %7
%32 = getelementptr inbounds %struct.snd_mask, %struct.snd_mask* %31, i32 0, i32 0
%33 = load i32*, i32** %32
%34 = load i32, i32* %6
%35 = lshr i32 %34, 5
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %33, i64 %36
%38 = load i32, i32* %37
%39 = or i32 %38, %30
store i32 %39, i32* %37
br label %40
40: ; preds = %11, %16, %12
ret void
}

LLVM IR (-O2):
%struct.snd_pcm_hw_params = type { i32 }
%struct.snd_mask = type { i32* }
@SNDRV_MASK_MAX = global i32 0
define void @param_set_mask(%struct.snd_pcm_hw_params* %0, i32 %1, i32 %2) {
%4 = load i32, i32* @SNDRV_MASK_MAX
%5 = icmp ugt i32 %4, %2
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = tail call i64 @param_is_mask(i32 %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6
%10 = tail call %struct.snd_mask* @param_to_mask(%struct.snd_pcm_hw_params* %0, i32 %1)
%11 = getelementptr inbounds %struct.snd_mask, %struct.snd_mask* %10, i64 0, i32 0
%12 = load i32*, i32** %11
store i32 0, i32* %12
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 0, i32* %13
%14 = and i32 %2, 31
%15 = shl nuw i32 1, %14
%16 = lshr i32 %2, 5
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %12, i64 %17
%19 = load i32, i32* %18
%20 = or i32 %19, %15
store i32 %20, i32* %18
br label %21
21: ; preds = %3, %9, %6
ret void
}