#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_CUR;
int /*<<< orphan*/ SEEK_SET;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int _IsWAV(FILE *f) {
  int ok = 1;
  if (f == NULL)
    return (0);
  if (fgetc(f) != 'R')
    ok = 0;
  if (fgetc(f) != 'I')
    ok = 0;
  if (fgetc(f) != 'F')
    ok = 0;
  if (fgetc(f) != 'F')
    ok = 0;
  fseek(f, 4, SEEK_CUR);
  if (fgetc(f) != 'W')
    ok = 0;
  if (fgetc(f) != 'A')
    ok = 0;
  if (fgetc(f) != 'V')
    ok = 0;
  if (fgetc(f) != 'E')
    ok = 0;
  fseek(f, 0, SEEK_SET);
  return (ok);
}


x86 assembly (clang, -O0):
<_IsWAV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <_IsWAV+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    125b <_IsWAV+0x13b>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x52,%eax
je     1166 <_IsWAV+0x46>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x49,%eax
je     1182 <_IsWAV+0x62>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x46,%eax
je     119e <_IsWAV+0x7e>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x46,%eax
je     11ba <_IsWAV+0x9a>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x57,%eax
je     11ed <_IsWAV+0xcd>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x41,%eax
je     1209 <_IsWAV+0xe9>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x56,%eax
je     1225 <_IsWAV+0x105>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x45,%eax
je     1241 <_IsWAV+0x121>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_IsWAV>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     11e3 <_IsWAV+0xc3>
mov    %rdi,%r14
call   1030 <fgetc@plt>
mov    %eax,%ebp
xor    $0x52,%bpl
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
xor    $0x49,%bl
or     %bpl,%bl
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r15d
xor    $0x46,%r15b
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
xor    $0x46,%bpl
or     %r15b,%bpl
or     %bl,%bpl
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x4,%esi
call   1040 <fseek@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r15d
xor    $0x57,%r15b
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r12d
xor    $0x41,%r12b
or     %r15b,%r12b
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
xor    $0x56,%bl
or     %r12b,%bl
or     %bpl,%bl
mov    %r14,%rdi
call   1030 <fgetc@plt>
xor    $0x45,%al
xor    %ebp,%ebp
or     %bl,%al
sete   %bpl
mov    0x2e03(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
jmp    11e5 <_IsWAV+0xc5>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define i32 @_IsWAV(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 1, i32* %4
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %64
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = call signext i8 @fgetc(i32* %9)
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 82
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 0, i32* %4
br label %14
14: ; preds = %13, %8
%15 = load i32*, i32** %3
%16 = call signext i8 @fgetc(i32* %15)
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 73
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %4
br label %20
20: ; preds = %19, %14
%21 = load i32*, i32** %3
%22 = call signext i8 @fgetc(i32* %21)
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 70
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 0, i32* %4
br label %26
26: ; preds = %25, %20
%27 = load i32*, i32** %3
%28 = call signext i8 @fgetc(i32* %27)
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 70
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 0, i32* %4
br label %32
32: ; preds = %31, %26
%33 = load i32*, i32** %3
%34 = load i32, i32* @SEEK_CUR
%35 = call i32 @fseek(i32* %33, i32 4, i32 %34)
%36 = load i32*, i32** %3
%37 = call signext i8 @fgetc(i32* %36)
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 87
br i1 %39, label %40, label %41
40: ; preds = %32
store i32 0, i32* %4
br label %41
41: ; preds = %40, %32
%42 = load i32*, i32** %3
%43 = call signext i8 @fgetc(i32* %42)
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 65
br i1 %45, label %46, label %47
46: ; preds = %41
store i32 0, i32* %4
br label %47
47: ; preds = %46, %41
%48 = load i32*, i32** %3
%49 = call signext i8 @fgetc(i32* %48)
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 86
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 0, i32* %4
br label %53
53: ; preds = %52, %47
%54 = load i32*, i32** %3
%55 = call signext i8 @fgetc(i32* %54)
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 69
br i1 %57, label %58, label %59
58: ; preds = %53
store i32 0, i32* %4
br label %59
59: ; preds = %58, %53
%60 = load i32*, i32** %3
%61 = load i32, i32* @SEEK_SET
%62 = call i32 @fseek(i32* %60, i32 0, i32 %61)
%63 = load i32, i32* %4
store i32 %63, i32* %2
br label %64
64: ; preds = %59, %7
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define i32 @_IsWAV(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %32, label %3
3: ; preds = %1
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = icmp eq i8 %4, 82
%6 = tail call signext i8 @fgetc(i32* %0)
%7 = icmp eq i8 %6, 73
%8 = and i1 %5, %7
%9 = tail call signext i8 @fgetc(i32* %0)
%10 = icmp eq i8 %9, 70
%11 = and i1 %10, %8
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = icmp eq i8 %12, 70
%14 = and i1 %13, %11
%15 = load i32, i32* @SEEK_CUR
%16 = tail call i32 @fseek(i32* %0, i32 4, i32 %15)
%17 = tail call signext i8 @fgetc(i32* %0)
%18 = icmp eq i8 %17, 87
%19 = and i1 %14, %18
%20 = tail call signext i8 @fgetc(i32* %0)
%21 = icmp eq i8 %20, 65
%22 = and i1 %21, %19
%23 = tail call signext i8 @fgetc(i32* %0)
%24 = icmp eq i8 %23, 86
%25 = and i1 %24, %22
%26 = tail call signext i8 @fgetc(i32* %0)
%27 = icmp eq i8 %26, 69
%28 = and i1 %27, %25
%29 = zext i1 %28 to i32
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @fseek(i32* %0, i32 0, i32 %30)
br label %32
32: ; preds = %1, %3
%33 = phi i32 [ %29, %3 ], [ 0, %1 ]
ret i32 %33
}