#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ get_audio_bits(int /*<<< orphan*/ *);
int get_audio_channels(int /*<<< orphan*/ *);
int get_audio_frq(int /*<<< orphan*/ *);
int /*<<< orphan*/ ioctl(int, int, int *);
int /*<<< orphan*/ printf(char *, int, int, int);
int set_audio_config(int fd_audio, FILE *file) {
  int tmp, format, frequency, channels;
  tmp = format = (int)get_audio_bits(file);
  ioctl(fd_audio,
        ((int)((0x40000000 | 0x20000000) | ((sizeof(int) & 0x1fff) << 16) |
               ('P' << 8) | 5)),
        &format);
  if (tmp != format)
    return -1;
  tmp = frequency = get_audio_frq(file);
  ioctl(fd_audio,
        ((int)((0x40000000 | 0x20000000) | ((sizeof(int) & 0x1fff) << 16) |
               ('P' << 8) | 2)),
        &frequency);
  if (tmp != frequency)
    return -1;
  tmp = channels = get_audio_channels(file);
  ioctl(fd_audio,
        ((int)((0x40000000 | 0x20000000) | ((sizeof(int) & 0x1fff) << 16) |
               ('P' << 8) | 6)),
        &channels);
  if (tmp != channels)
    return -1;
  printf("Configuration : %d %d %d\n", format, frequency, channels);
  return 0;
}


x86 assembly (clang, -O0):
<set_audio_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <get_audio_bits@plt>
mov    %eax,-0x18(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x60045005,%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1197 <set_audio_config+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <set_audio_config+0xd3>
mov    -0x10(%rbp),%rdi
call   1050 <get_audio_frq@plt>
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x60045002,%esi
lea    -0x1c(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11cf <set_audio_config+0x7f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <set_audio_config+0xd3>
mov    -0x10(%rbp),%rdi
call   1070 <get_audio_channels@plt>
mov    %eax,-0x20(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x60045006,%esi
lea    -0x20(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1207 <set_audio_config+0xb7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <set_audio_config+0xd3>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_audio_config>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsi,%rdi
call   1060 <get_audio_bits@plt>
mov    %rax,%rbp
mov    %ebp,0x10(%rsp)
lea    0x10(%rsp),%rdx
mov    %r15d,%edi
mov    $0x60045005,%esi
call   1040 <ioctl@plt>
mov    $0xffffffff,%r14d
cmp    %ebp,0x10(%rsp)
jne    11f2 <set_audio_config+0xa2>
mov    %rbx,%rdi
call   1050 <get_audio_frq@plt>
mov    %eax,%ebp
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    %r15d,%edi
mov    $0x60045002,%esi
call   1040 <ioctl@plt>
cmp    0xc(%rsp),%ebp
jne    11f2 <set_audio_config+0xa2>
mov    %rbx,%rdi
call   1070 <get_audio_channels@plt>
mov    %eax,%ebx
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdx
mov    %r15d,%edi
mov    $0x60045006,%esi
call   1040 <ioctl@plt>
cmp    0x14(%rsp),%ebx
jne    11f2 <set_audio_config+0xa2>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xe18(%rip),%rdi
mov    %ebx,%ecx
call   1030 <printf@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Configuration : %d %d %d\0A\00"
define i32 @set_audio_config(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%10 = load i32*, i32** %5
%11 = call i64 @get_audio_bits(i32* %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %7
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = call i32 @ioctl(i32 %13, i32 1610895365, i32* %7)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 -1, i32* %3
br label %42
19: ; preds = %2
%20 = load i32*, i32** %5
%21 = call i32 @get_audio_frq(i32* %20)
store i32 %21, i32* %8
store i32 %21, i32* %6
%22 = load i32, i32* %4
%23 = call i32 @ioctl(i32 %22, i32 1610895362, i32* %8)
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %19
store i32 -1, i32* %3
br label %42
28: ; preds = %19
%29 = load i32*, i32** %5
%30 = call i32 @get_audio_channels(i32* %29)
store i32 %30, i32* %9
store i32 %30, i32* %6
%31 = load i32, i32* %4
%32 = call i32 @ioctl(i32 %31, i32 1610895366, i32* %9)
%33 = load i32, i32* %6
%34 = load i32, i32* %9
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %28
store i32 -1, i32* %3
br label %42
37: ; preds = %28
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
store i32 0, i32* %3
br label %42
42: ; preds = %37, %36, %27, %18
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [26 x i8] c"Configuration : %d %d %d\0A\00"
define i32 @set_audio_config(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i64 @get_audio_bits(i32* %1)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %3
%11 = call i32 @ioctl(i32 %0, i32 1610895365, i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, %10
br i1 %13, label %14, label %28
14: ; preds = %2
%15 = call i32 @get_audio_frq(i32* %1)
store i32 %15, i32* %4
%16 = call i32 @ioctl(i32 %0, i32 1610895362, i32* %4)
%17 = load i32, i32* %4
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = call i32 @get_audio_channels(i32* %1)
store i32 %20, i32* %5
%21 = call i32 @ioctl(i32 %0, i32 1610895366, i32* %5)
%22 = load i32, i32* %5
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %20)
br label %28
28: ; preds = %19, %14, %2, %24
%29 = phi i32 [ 0, %24 ], [ -1, %2 ], [ -1, %14 ], [ -1, %19 ]
ret i32 %29
}