#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_SET;
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ fread(char *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int strcmp(char *, char const *);
short compareSection(FILE *file, long offset, size_t length,
                     const char *comparison) {
  fseek(file, offset, SEEK_SET);
  char *buf = (char *)calloc(length, 1);
  fread(buf, length, 1, file);
  int compResult = strcmp(buf, comparison);
  free(buf);
  return (compResult == 0);
}


x86 assembly (clang, -O0):
<compareSection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cwtl
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareSection>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rdi,%r15
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    %r12,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define signext i16 @compareSection(i32* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%11 = load i32*, i32** %5
%12 = load i64, i64* %6
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %11, i64 %12, i32 %13)
%15 = load i64, i64* %7
%16 = call i64 @calloc(i64 %15, i32 1)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = load i64, i64* %7
%20 = load i32*, i32** %5
%21 = call i32 @fread(i8* %18, i64 %19, i32 1, i32* %20)
%22 = load i8*, i8** %9
%23 = load i8*, i8** %8
%24 = call i32 @strcmp(i8* %22, i8* %23)
store i32 %24, i32* %10
%25 = load i8*, i8** %9
%26 = call i32 @free(i8* %25)
%27 = load i32, i32* %10
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = trunc i32 %29 to i16
ret i16 %30
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define signext i16 @compareSection(i32* nocapture %0, i64 %1, i64 %2, i8* nocapture %3) {
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %0, i64 %1, i32 %5)
%7 = tail call i64 @calloc(i64 %2, i32 1)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @fread(i8* %8, i64 %2, i32 1, i32* %0)
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(1) %3)
%11 = tail call i32 @free(i8* %8)
%12 = icmp eq i32 %10, 0
%13 = zext i1 %12 to i16
ret i16 %13
}