int set_selector(int fd_audio, int val) {
  int err = 0;
  int ret, mem;
  mem = val;
  ret = ioctl(fd_audio,
              ((int)((0x40000000 | 0x20000000) |
                     ((sizeof(int) & 0x1fff) << 16) | ('M' << 8) | 0xfa)),
              &mem);
  if (!(mem & val)) {
    printf("%s: "
           "Error with IOCTL SNDCTL_MC13783_WRITE_OUTSRC\n",
           __FUNCTION__);
    err++;
  }
  return err;
}


x86 assembly (clang, -O0):
<set_selector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x60044dfa,%esi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <ioctl@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
and    -0x8(%rbp),%eax
cmp    $0x0,%eax
jne    117e <set_selector+0x5e>
lea    0xe99(%rip),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_selector>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %esi,0x4(%rsp)
xor    %ebx,%ebx
lea    0x4(%rsp),%rdx
mov    $0x60044dfa,%esi
xor    %eax,%eax
call   1040 <ioctl@plt>
test   %ebp,0x4(%rsp)
jne    115c <set_selector+0x3c>
lea    0xeb7(%rip),%rdi
lea    0xee2(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"%s: Error with IOCTL SNDCTL_MC13783_WRITE_OUTSRC\0A\00"
@__FUNCTION__.set_selector = [13 x i8] c"set_selector\00"
define i32 @set_selector(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i32, i32* %4
store i32 %8, i32* %7
%9 = load i32, i32* %3
%10 = call i32 (i32, i32, i32*, ...) bitcast (i32 (...)* @ioctl to i32 (i32, i32, i32*, ...)*)(i32 %9, i32 1610894842, i32* %7)
store i32 %10, i32* %6
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = and i32 %11, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.set_selector, i64 0, i64 0))
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %19
19: ; preds = %15, %2
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@.str = [50 x i8] c"%s: Error with IOCTL SNDCTL_MC13783_WRITE_OUTSRC\0A\00"
@__FUNCTION__.set_selector = [13 x i8] c"set_selector\00"
define i32 @set_selector(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 %1, i32* %3
%5 = call i32 (i32, i32, i32*, ...) bitcast (i32 (...)* @ioctl to i32 (i32, i32, i32*, ...)*)(i32 %0, i32 1610894842, i32* %3)
%6 = load i32, i32* %3
%7 = and i32 %6, %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.set_selector, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = phi i32 [ 0, %2 ], [ 1, %9 ]
ret i32 %12
}