#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 aiff_id(unsigned char *buf, int len) {
  if (len < 12)
    return 0;
  if (memcmp(buf, "FORM", 4))
    return 0;
  if (memcmp(buf + 8, "AIF", 3))
    return 0;
  if (buf[11] != 'C' && buf[11] != 'F')
    return 0;
  return 1;
}


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

x86 assembly (clang, -O2):
<aiff_id>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
cmp    $0xc,%esi
jl     1161 <aiff_id+0x51>
mov    %rdi,%r14
lea    0xedb(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    1161 <aiff_id+0x51>
lea    0x8(%r14),%rdi
lea    0xec6(%rip),%rsi
mov    $0x3,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    1161 <aiff_id+0x51>
mov    0xb(%r14),%al
cmp    $0x43,%al
sete   %cl
cmp    $0x46,%al
sete   %al
or     %cl,%al
movzbl %al,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"FORM\00"
@.str.1 = [4 x i8] c"AIF\00"
define i32 @aiff_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 %34
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 %34
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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %3
br label %34
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 11
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp ne i32 %24, 67
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 11
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp ne i32 %30, 70
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 0, i32* %3
br label %34
33: ; preds = %26, %20
store i32 1, i32* %3
br label %34
34: ; preds = %33, %32, %19, %13, %8
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"FORM\00"
@.str.1 = [4 x i8] c"AIF\00"
define i32 @aiff_id(i8* %0, i32 %1) {
%3 = icmp slt i32 %1, 12
br i1 %3, label %18, 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 %18
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 8
%9 = tail call i64 @memcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 67
%15 = icmp eq i8 %13, 70
%16 = or i1 %14, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %11, %7, %4, %2
%19 = phi i32 [ 0, %2 ], [ 0, %4 ], [ 0, %7 ], [ %17, %11 ]
ret i32 %19
}