#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_AV_SYNC;
int atoi(char *);
int ioctl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int audioSetAVSync(int fd, char *arg) {
  int _sync;
  if (!arg)
    return -1;
  _sync = atoi(arg);
  if (ioctl(fd, AUDIO_SET_AV_SYNC, _sync) == -1)
    perror("AUDIO_SET_AV_SYNC");
  return 0;
}


x86 assembly (clang, -O0):
<audioSetAVSync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <audioSetAVSync+0x26>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <audioSetAVSync+0x62>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    118b <audioSetAVSync+0x5b>
lea    0xe7a(%rip),%rdi
call   1040 <perror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<audioSetAVSync>:
push   %rbx
test   %rsi,%rsi
je     1167 <audioSetAVSync+0x37>
mov    %edi,%ebx
mov    %rsi,%rdi
call   1050 <atoi@plt>
mov    0x2ea1(%rip),%rcx
mov    (%rcx),%esi
mov    %ebx,%edi
mov    %eax,%edx
call   1030 <ioctl@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
jne    116c <audioSetAVSync+0x3c>
lea    0xea0(%rip),%rdi
call   1040 <perror@plt>
jmp    116c <audioSetAVSync+0x3c>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@AUDIO_SET_AV_SYNC = global i32 0
@.str = [18 x i8] c"AUDIO_SET_AV_SYNC\00"
define i32 @audioSetAVSync(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 -1, i32* %3
br label %21
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = load i32, i32* @AUDIO_SET_AV_SYNC
%15 = load i32, i32* %6
%16 = call i32 @ioctl(i32 %13, i32 %14, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %10
store i32 0, i32* %3
br label %21
21: ; preds = %20, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@AUDIO_SET_AV_SYNC = global i32 0
@.str = [18 x i8] c"AUDIO_SET_AV_SYNC\00"
define i32 @audioSetAVSync(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i32 @atoi(i8* %1)
%6 = load i32, i32* @AUDIO_SET_AV_SYNC
%7 = tail call i32 @ioctl(i32 %0, i32 %6, i32 %5)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %4, %9, %2
%12 = phi i32 [ -1, %2 ], [ 0, %9 ], [ 0, %4 ]
ret i32 %12
}