#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 */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void audio_stream_info(FILE *f, int len) {
  int orig_pos = ftell(f);
  unsigned char data[len - 8];
  int i;
  len -= 8;
  for (i = 0; i < len; i++)
    fread(&data[i], 1, 1, f);
  printf("  [%d bit", data[19]);
  if (data[17] == 1)
    printf(" mono");
  else
    printf(" %d channels", data[17]);
  printf("]\n");
  fseek(f, orig_pos, SEEK_SET);
}


x86 assembly (clang, -O0):
<audio_stream_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffff8,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <audio_stream_info+0x89>
mov    -0x30(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <audio_stream_info+0x54>
mov    -0x30(%rbp),%rax
movzbl 0x13(%rax),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movzbl 0x11(%rax),%eax
cmp    $0x1,%eax
jne    1203 <audio_stream_info+0xc3>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1219 <audio_stream_info+0xd9>
mov    -0x30(%rbp),%rax
movzbl 0x11(%rax),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<audio_stream_info>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r15
call   1060 <ftell@plt>
mov    %eax,%r14d
lea    -0x8(%rbx),%r13d
mov    %rsp,%r12
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
xor    %esi,%esi
cmp    $0x9,%ebx
jl     11b5 <audio_stream_info+0x65>
mov    %r12,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r13
jne    1190 <audio_stream_info+0x40>
movzbl 0x13(%r12),%esi
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x11(%r12),%esi
cmp    $0x1,%esi
jne    11de <audio_stream_info+0x8e>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ec <audio_stream_info+0x9c>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14d,%esi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fseek@plt>

LLVM IR (-O0):
@.str = [10 x i8] c" [%d bit\00"
@.str.1 = [6 x i8] c" mono\00"
@.str.2 = [13 x i8] c" %d channels\00"
@.str.3 = [3 x i8] c"]\0A\00"
@SEEK_SET = global i32 0
define void @audio_stream_info(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32*, i32** %3
%10 = call i32 @ftell(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 8
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %6
%15 = alloca i8, i64 %13
store i64 %13, i64* %7
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 8
store i32 %17, i32* %4
store i32 0, i32* %8
br label %18
18: ; preds = %28, %2
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %15, i64 %24
%26 = load i32*, i32** %3
%27 = call i32 @fread(i8* %25, i32 1, i32 1, i32* %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %18
31: ; preds = %18
%32 = getelementptr inbounds i8, i8* %15, i64 19
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds i8, i8* %15, i64 17
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %31
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %47
42: ; preds = %31
%43 = getelementptr inbounds i8, i8* %15, i64 17
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %42, %40
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%49 = load i32*, i32** %3
%50 = load i32, i32* %5
%51 = load i32, i32* @SEEK_SET
%52 = call i32 @fseek(i32* %49, i32 %50, i32 %51)
%53 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" [%d bit\00"
@.str.1 = [6 x i8] c" mono\00"
@.str.2 = [13 x i8] c" %d channels\00"
@SEEK_SET = global i32 0
@str = [2 x i8] c"]\00"
define void @audio_stream_info(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @ftell(i32* %0)
%4 = add i32 %1, -8
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = icmp sgt i32 %1, 8
br i1 %7, label %8, label %18
8: ; preds = %2, %8
%9 = phi i64 [ %12, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = call i32 @fread(i8* %10, i32 1, i32 1, i32* %0)
%12 = add nuw nsw i64 %9, 1
%13 = icmp eq i64 %12, %5
br i1 %13, label %14, label %8
14: ; preds = %8
%15 = getelementptr inbounds i8, i8* %6, i64 19
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
br label %18
18: ; preds = %14, %2
%19 = phi i32 [ %17, %14 ], [ 0, %2 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i8, i8* %6, i64 17
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %29
26: ; preds = %18
%27 = zext i8 %22 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %24
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%31 = load i32, i32* @SEEK_SET
%32 = tail call i32 @fseek(i32* %0, i32 %3, i32 %31)
ret void
}