int alsa_check_sample_rate(unsigned long sample_rate) {
  const unsigned long sampling_rates[] = {8000,  11025, 16000,  22050,
                                          32000, 44100, 48000,  64000,
                                          88200, 96000, 176000, 192000};
  int i, size;
  size = sizeof(sampling_rates) / sizeof(sampling_rates[0]);
  for (i = 0; i < size; i++)
    if (sample_rate == sampling_rates[i])
      return 0;
  return -1;
}


x86 assembly (clang, -O0):
<alsa_check_sample_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xed6(%rip),%rsi
mov    $0x60,%edx
call   1030 <memcpy@plt>
movl   $0xc,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    1180 <alsa_check_sample_rate+0x70>
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
cmp    -0x70(%rbp,%rcx,8),%rax
jne    116d <alsa_check_sample_rate+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    1187 <alsa_check_sample_rate+0x77>
jmp    1172 <alsa_check_sample_rate+0x62>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1142 <alsa_check_sample_rate+0x32>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alsa_check_sample_rate>:
xor    %eax,%eax
cmp    $0xbb7f,%rdi
jg     1130 <alsa_check_sample_rate+0x30>
cmp    $0x5621,%rdi
jg     1156 <alsa_check_sample_rate+0x56>
cmp    $0x1f40,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x2b11,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x3e80,%rdi
jne    118e <alsa_check_sample_rate+0x8e>
ret
cmp    $0x176ff,%rdi
jg     1173 <alsa_check_sample_rate+0x73>
cmp    $0xbb80,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0xfa00,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x15888,%rdi
je     112f <alsa_check_sample_rate+0x2f>
jmp    118e <alsa_check_sample_rate+0x8e>
cmp    $0x5622,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x7d00,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0xac44,%rdi
je     112f <alsa_check_sample_rate+0x2f>
jmp    118e <alsa_check_sample_rate+0x8e>
cmp    $0x17700,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x2af80,%rdi
je     112f <alsa_check_sample_rate+0x2f>
cmp    $0x2ee00,%rdi
je     112f <alsa_check_sample_rate+0x2f>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@__const.alsa_check_sample_rate.sampling_rates = [12 x i64] [i64 8000, i64 11025, i64 16000, i64 22050, i64 32000, i64 44100, i64 48000, i64 64000, i64 88200, i64 96000, i64 176000, i64 192000]
define i32 @alsa_check_sample_rate(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca [12 x i64]
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %3
%7 = bitcast [12 x i64]* %4 to i8*
store i32 12, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %21, %1
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i64, i64* %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [12 x i64], [12 x i64]* %4, i64 0, i64 %15
%17 = load i64, i64* %16
%18 = icmp eq i64 %13, %17
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 0, i32* %2
br label %25
20: ; preds = %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %8
24: ; preds = %8
store i32 -1, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @alsa_check_sample_rate(i64 %0) {
switch i64 %0, label %2 [
i64 8000, label %3
i64 11025, label %3
i64 16000, label %3
i64 22050, label %3
i64 32000, label %3
i64 44100, label %3
i64 48000, label %3
i64 64000, label %3
i64 88200, label %3
i64 96000, label %3
i64 176000, label %3
i64 192000, label %3
]
2: ; preds = %1
br label %3
3: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %2
%4 = phi i32 [ 0, %1 ], [ -1, %2 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ]
ret i32 %4
}