#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(char *, char const *, int);
int read_chunk_header(int, char *, unsigned int *);
int read_named_chunk_header(int fd, const char *name, unsigned int *size) {
  int rc;
  char buf[4];
  rc = read_chunk_header(fd, buf, size);
  if (rc)
    return rc;
  if (memcmp(buf, name, 4))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<read_named_chunk_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <read_chunk_header@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     115b <read_named_chunk_header+0x3b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <read_named_chunk_header+0x6a>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1183 <read_named_chunk_header+0x63>
movl   $0x1,-0x4(%rbp)
jmp    118a <read_named_chunk_header+0x6a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_named_chunk_header>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rsi
call   1030 <read_chunk_header@plt>
test   %eax,%eax
jne    1153 <read_named_chunk_header+0x33>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_named_chunk_header(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [4 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = load i32, i32* %5
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%12 = load i32*, i32** %7
%13 = call i32 @read_chunk_header(i32 %10, i8* %11, i32* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %8
store i32 %17, i32* %4
br label %25
18: ; preds = %3
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = call i64 @memcmp(i8* %19, i8* %20, i32 4)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %4
br label %25
24: ; preds = %18
store i32 0, i32* %4
br label %25
25: ; preds = %24, %23, %16
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
define i32 @read_named_chunk_header(i32 %0, i8* %1, i32* %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = call i32 @read_chunk_header(i32 %0, i8* %5, i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = call i64 @memcmp(i8* %5, i8* %1, i32 4)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %3
%13 = phi i32 [ %6, %3 ], [ %11, %8 ]
ret i32 %13
}