#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 */

/* Variables and functions */
int /*<<< orphan*/ AUDIO_SET_BYPASS_MODE;
int /*<<< orphan*/ O_RDWR;
scalar_t__ close(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int audioSetBypassToRaw() {
  int fd;
  if ((fd = open("/dev/dvb/adapter0/audio0", O_RDWR)) < 0) {
    perror("failed to open audio device:");
    return -1;
  }
  if (ioctl(fd, AUDIO_SET_BYPASS_MODE, 0x30) < 0) {
    perror("AUDIO_SET_BYPASS_MODE to 0x30, error:");
  }
  if (close(fd) < 0) {
    perror("failed to close audio device:");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<audioSetBypassToRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1181 <audioSetBypassToRaw+0x41>
lea    0xea9(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11de <audioSetBypassToRaw+0x9e>
mov    -0x8(%rbp),%edi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
mov    $0x30,%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    11ad <audioSetBypassToRaw+0x6d>
lea    0xe8e(%rip),%rdi
call   1060 <perror@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
jge    11d7 <audioSetBypassToRaw+0x97>
lea    0xe96(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11de <audioSetBypassToRaw+0x9e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<audioSetBypassToRaw>:
push   %rbx
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
js     1189 <audioSetBypassToRaw+0x49>
mov    %eax,%ebx
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x30,%edx
call   1030 <ioctl@plt>
test   %rax,%rax
js     1192 <audioSetBypassToRaw+0x52>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     11a0 <audioSetBypassToRaw+0x60>
pop    %rbx
ret
lea    0xe89(%rip),%rdi
jmp    11a7 <audioSetBypassToRaw+0x67>
lea    0xe9d(%rip),%rdi
call   1060 <perror@plt>
jmp    1176 <audioSetBypassToRaw+0x36>
lea    0xeb5(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/dev/dvb/adapter0/audio0\00"
@O_RDWR = global i32 0
@.str.1 = [29 x i8] c"failed to open audio device:\00"
@AUDIO_SET_BYPASS_MODE = global i32 0
@.str.2 = [38 x i8] c"AUDIO_SET_BYPASS_MODE to 0x30, error:\00"
@.str.3 = [30 x i8] c"failed to close audio device:\00"
define i32 @audioSetBypassToRaw() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @O_RDWR
%4 = call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 %4, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %22
8: ; preds = %0
%9 = load i32, i32* %2
%10 = load i32, i32* @AUDIO_SET_BYPASS_MODE
%11 = call i64 @ioctl(i32 %9, i32 %10, i32 48)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
%16 = load i32, i32* %2
%17 = call i64 @close(i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %22
21: ; preds = %15
store i32 0, i32* %1
br label %22
22: ; preds = %21, %19, %6
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [25 x i8] c"/dev/dvb/adapter0/audio0\00"
@O_RDWR = global i32 0
@.str.1 = [29 x i8] c"failed to open audio device:\00"
@AUDIO_SET_BYPASS_MODE = global i32 0
@.str.2 = [38 x i8] c"AUDIO_SET_BYPASS_MODE to 0x30, error:\00"
@.str.3 = [30 x i8] c"failed to close audio device:\00"
define i32 @audioSetBypassToRaw() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i32 @open(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %0
%5 = load i32, i32* @AUDIO_SET_BYPASS_MODE
%6 = tail call i64 @ioctl(i32 %2, i32 %5, i32 48)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = tail call i64 @close(i32 %2)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10, %0
%14 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), %10 ]
%15 = tail call i32 @perror(i8* %14)
br label %16
16: ; preds = %13, %10
%17 = phi i32 [ 0, %10 ], [ -1, %13 ]
ret i32 %17
}