#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 */
struct v2_header {
  int dummy;
};

/* Variables and functions */
int v2_header_footer_parse(struct v2_header *, char const *);
int v2_header_parse(struct v2_header *header, const char *buf) {
  if (buf[0] != 'I' || buf[1] != 'D' || buf[2] != '3')
    return 0;
  return v2_header_footer_parse(header, buf);
}


x86 assembly (clang, -O0):
<v2_header_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x49,%eax
jne    1152 <v2_header_parse+0x42>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x44,%eax
jne    1152 <v2_header_parse+0x42>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x33,%eax
je     115e <v2_header_parse+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    116e <v2_header_parse+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <v2_header_footer_parse@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v2_header_parse>:
cmpb   $0x49,(%rsi)
jne    1126 <v2_header_parse+0x16>
cmpb   $0x44,0x1(%rsi)
jne    1126 <v2_header_parse+0x16>
cmpb   $0x33,0x2(%rsi)
jne    1126 <v2_header_parse+0x16>
jmp    1030 <v2_header_footer_parse@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.v2_header = type { i32 }
define i32 @v2_header_parse(%struct.v2_header* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.v2_header*
%5 = alloca i8*
store %struct.v2_header* %0, %struct.v2_header** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 73
br i1 %10, label %23, label %11
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 68
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 51
br i1 %22, label %23, label %24
23: ; preds = %17, %11, %2
store i32 0, i32* %3
br label %28
24: ; preds = %17
%25 = load %struct.v2_header*, %struct.v2_header** %4
%26 = load i8*, i8** %5
%27 = call i32 @v2_header_footer_parse(%struct.v2_header* %25, i8* %26)
store i32 %27, i32* %3
br label %28
28: ; preds = %24, %23
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.v2_header = type { i32 }
define i32 @v2_header_parse(%struct.v2_header* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 73
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 68
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %1, i64 2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 51
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @v2_header_footer_parse(%struct.v2_header* %0, i8* %1)
br label %15
15: ; preds = %2, %5, %9, %13
%16 = phi i32 [ %14, %13 ], [ 0, %9 ], [ 0, %5 ], [ 0, %2 ]
ret i32 %16
}