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

/* Variables and functions */
int tc_get_ac3_header(int /*<<< orphan*/ *, int, int *, int *, int *);
int tc_get_mp3_header(int /*<<< orphan*/ *, int *, int *, int *);
int tc_get_audio_header(uint8_t *buf, int buflen, int format, int *chans,
                        int *srate, int *bitrate) {
  switch (format) {
  case 0x55:
    return tc_get_mp3_header(buf, chans, srate, bitrate);
    break;
  case 0x2000:
    return tc_get_ac3_header(buf, buflen, chans, srate, bitrate);
    break;
  default:
    return -1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<tc_get_audio_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x55,%eax
je     1165 <tc_get_audio_header+0x45>
jmp    1152 <tc_get_audio_header+0x32>
mov    -0x34(%rbp),%eax
sub    $0x2000,%eax
je     1182 <tc_get_audio_header+0x62>
jmp    11a2 <tc_get_audio_header+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <tc_get_mp3_header@plt>
mov    %eax,-0x4(%rbp)
jmp    11a9 <tc_get_audio_header+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1040 <tc_get_ac3_header@plt>
mov    %eax,-0x4(%rbp)
jmp    11a9 <tc_get_audio_header+0x89>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tc_get_audio_header>:
cmp    $0x2000,%edx
je     113b <tc_get_audio_header+0x1b>
cmp    $0x55,%edx
jne    1149 <tc_get_audio_header+0x29>
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %r9,%rcx
jmp    1030 <tc_get_mp3_header@plt>
mov    %rcx,%rdx
mov    %r8,%rcx
mov    %r9,%r8
jmp    1040 <tc_get_ac3_header@plt>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @tc_get_audio_header(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
store i32* %0, i32** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%14 = load i32, i32* %10
switch i32 %14, label %28 [
i32 85, label %15
i32 8192, label %21
]
15: ; preds = %6
%16 = load i32*, i32** %8
%17 = load i32*, i32** %11
%18 = load i32*, i32** %12
%19 = load i32*, i32** %13
%20 = call i32 @tc_get_mp3_header(i32* %16, i32* %17, i32* %18, i32* %19)
store i32 %20, i32* %7
br label %29
21: ; preds = %6
%22 = load i32*, i32** %8
%23 = load i32, i32* %9
%24 = load i32*, i32** %11
%25 = load i32*, i32** %12
%26 = load i32*, i32** %13
%27 = call i32 @tc_get_ac3_header(i32* %22, i32 %23, i32* %24, i32* %25, i32* %26)
store i32 %27, i32* %7
br label %29
28: ; preds = %6
store i32 -1, i32* %7
br label %29
29: ; preds = %28, %21, %15
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
define i32 @tc_get_audio_header(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5) {
switch i32 %2, label %11 [
i32 85, label %7
i32 8192, label %9
]
7: ; preds = %6
%8 = tail call i32 @tc_get_mp3_header(i32* %0, i32* %3, i32* %4, i32* %5)
br label %11
9: ; preds = %6
%10 = tail call i32 @tc_get_ac3_header(i32* %0, i32 %1, i32* %3, i32* %4, i32* %5)
br label %11
11: ; preds = %6, %9, %7
%12 = phi i32 [ %10, %9 ], [ %8, %7 ], [ -1, %6 ]
ret i32 %12
}