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

/* Variables and functions */
scalar_t__ memcmp(unsigned char *, char *, int);
int wav_id(unsigned char *buf, int len) {
  ;
  if (len < 12)
    return 0;
  if (memcmp(buf, "RIFF", 4))
    return 0;
  if (memcmp(buf + 8, "WAVE", 4))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<wav_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    1135 <wav_id+0x25>
movl   $0x0,-0x4(%rbp)
jmp    1196 <wav_id+0x86>
mov    -0x10(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     1160 <wav_id+0x50>
movl   $0x0,-0x4(%rbp)
jmp    1196 <wav_id+0x86>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
lea    0xe96(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     118f <wav_id+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1196 <wav_id+0x86>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wav_id>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
cmp    $0xc,%esi
jl     1154 <wav_id+0x44>
mov    %rdi,%r14
lea    0xedb(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    1154 <wav_id+0x44>
add    $0x8,%r14
lea    0xec6(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <memcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"RIFF\00"
@.str.1 = [5 x i8] c"WAVE\00"
define i32 @wav_id(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp slt i32 %6, 12
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* %3
br label %21
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i64 @memcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 0, i32* %3
br label %21
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 8
%17 = call i64 @memcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %3
br label %21
20: ; preds = %14
store i32 1, i32* %3
br label %21
21: ; preds = %20, %19, %13, %8
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [5 x i8] c"RIFF\00"
@.str.1 = [5 x i8] c"WAVE\00"
define i32 @wav_id(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 12
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 8
%9 = tail call i64 @memcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %7, %4, %2
%13 = phi i32 [ 0, %2 ], [ 0, %4 ], [ %11, %7 ]
ret i32 %13
}