#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 */
scalar_t__ tc_get_ac3_header(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ tc_get_mp3_header(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int tc_probe_audio_header(uint8_t *buf, int buflen) {
  if (tc_get_mp3_header(buf, NULL, NULL, NULL) > 0) {
    return 0x55;
  }
  if (tc_get_ac3_header(buf, buflen, NULL, NULL, NULL) > 0) {
    return 0x2000;
  }
  return -1;
}


x86 assembly (clang, -O0):
<tc_probe_audio_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1030 <tc_get_mp3_header@plt>
cmp    $0x0,%rax
jle    1158 <tc_probe_audio_header+0x38>
movl   $0x55,-0x4(%rbp)
jmp    118c <tc_probe_audio_header+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   1040 <tc_get_ac3_header@plt>
cmp    $0x0,%rax
jle    1185 <tc_probe_audio_header+0x65>
movl   $0x2000,-0x4(%rbp)
jmp    118c <tc_probe_audio_header+0x6c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tc_probe_audio_header>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <tc_get_mp3_header@plt>
mov    %rax,%rcx
mov    $0x55,%eax
test   %rcx,%rcx
jg     1161 <tc_probe_audio_header+0x41>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <tc_get_ac3_header@plt>
test   %rax,%rax
mov    $0x2000,%ecx
mov    $0xffffffff,%eax
cmovg  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tc_probe_audio_header(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32*, i32** %4
%7 = call i64 @tc_get_mp3_header(i32* %6, i32* null, i32* null, i32* null)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 85, i32* %3
br label %17
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i64 @tc_get_ac3_header(i32* %11, i32 %12, i32* null, i32* null, i32* null)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 8192, i32* %3
br label %17
16: ; preds = %10
store i32 -1, i32* %3
br label %17
17: ; preds = %16, %15, %9
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @tc_probe_audio_header(i32* %0, i32 %1) {
%3 = tail call i64 @tc_get_mp3_header(i32* %0, i32* null, i32* null, i32* null)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i64 @tc_get_ac3_header(i32* %0, i32 %1, i32* null, i32* null, i32* null)
%7 = icmp sgt i64 %6, 0
%8 = select i1 %7, i32 8192, i32 -1
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ 85, %2 ], [ %8, %5 ]
ret i32 %10
}