#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int volume_left;
  int volume_right;
};
typedef TYPE_1__ audio_mixer_t;

/* Variables and functions */
int /*<<< orphan*/ AUDIO_SET_MIXER;
int ioctl(int, int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ perror(char *);
int audioSetVolume(int fd, int level) {
  int ans;
  audio_mixer_t mix;
  mix.volume_left = mix.volume_right = level;
  if ((ans = ioctl(fd, AUDIO_SET_MIXER, &mix)) < 0) {
    perror("AUDIO SET VOLUME: ");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<audioSetVolume>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1170 <audioSetVolume+0x50>
lea    0xea1(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1177 <audioSetVolume+0x57>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<audioSetVolume>:
push   %rax
mov    %esi,0x4(%rsp)
mov    %esi,(%rsp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1030 <ioctl@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
js     1143 <audioSetVolume+0x23>
pop    %rcx
ret
lea    0xeb6(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@AUDIO_SET_MIXER = global i32 0
@.str = [19 x i8] c"AUDIO SET VOLUME: \00"
define i32 @audioSetVolume(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 1
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
store i32 %8, i32* %10
%11 = load i32, i32* %4
%12 = load i32, i32* @AUDIO_SET_MIXER
%13 = call i32 @ioctl(i32 %11, i32 %12, %struct.TYPE_3__* %7)
store i32 %13, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %18
17: ; preds = %2
store i32 0, i32* %3
br label %18
18: ; preds = %17, %15
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@AUDIO_SET_MIXER = global i32 0
@.str = [19 x i8] c"AUDIO SET VOLUME: \00"
define i32 @audioSetVolume(i32 %0, i32 %1) {
%3 = alloca %struct.TYPE_3__
%4 = bitcast %struct.TYPE_3__* %3 to i8*
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
store i32 %1, i32* %5
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
store i32 %1, i32* %6
%7 = load i32, i32* @AUDIO_SET_MIXER
%8 = call i32 @ioctl(i32 %0, i32 %7, %struct.TYPE_3__* %3)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %2, %10
%13 = phi i32 [ -1, %10 ], [ 0, %2 ]
ret i32 %13
}