#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 uint8_t;
typedef scalar_t__ iof;

/* Variables and functions */
int *get_current_hof(int *);
int *get_current_iof(int *);
uint8_t *get_hof_ver_normal(uint8_t *buf) {
  uint8_t *iof = get_current_iof(buf);
  uint8_t *hof = get_current_hof(buf);
  if ((((*iof) & 0x01) && (hof == iof + (*((uint8_t *)(iof) + 8 - 1)) * 8)) ||
      (!((*iof) & 0x01) && (hof == iof + 8)))
    return NULL;
  int offset = ((*iof) & 0x01) ? 1 : -1;
  return hof + offset * 8;
}


x86 assembly (clang, -O0):
<get_hof_ver_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_current_iof@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <get_current_hof@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117d <get_hof_ver_normal+0x5d>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%rdx
mov    0x1c(%rdx),%edx
shl    $0x3,%edx
movslq %edx,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
je     11a4 <get_hof_ver_normal+0x84>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11b1 <get_hof_ver_normal+0x91>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x20,%rcx
cmp    %rcx,%rax
jne    11b1 <get_hof_ver_normal+0x91>
movq   $0x0,-0x8(%rbp)
jmp    11e5 <get_hof_ver_normal+0xc5>
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
and    $0x1,%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x3,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hof_ver_normal>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <get_current_iof@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <get_current_hof@plt>
testb  $0x1,(%rbx)
jne    1152 <get_hof_ver_normal+0x32>
add    $0x20,%rbx
mov    $0xfffffffffffffff8,%rcx
cmp    %rbx,%rax
je     1167 <get_hof_ver_normal+0x47>
lea    (%rax,%rcx,4),%rax
jmp    1169 <get_hof_ver_normal+0x49>
movslq 0x1c(%rbx),%rdx
shl    $0x5,%rdx
add    %rbx,%rdx
mov    $0x8,%ecx
cmp    %rdx,%rax
jne    114c <get_hof_ver_normal+0x2c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @get_hof_ver_normal(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i32* @get_current_iof(i32* %7)
store i32* %8, i32** %4
%9 = load i32*, i32** %3
%10 = call i32* @get_current_hof(i32* %9)
store i32* %10, i32** %5
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %1
%16 = load i32*, i32** %5
%17 = load i32*, i32** %4
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 8
%20 = getelementptr inbounds i32, i32* %19, i64 -1
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, 8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %17, i64 %23
%25 = icmp eq i32* %16, %24
br i1 %25, label %36, label %26
26: ; preds = %15, %1
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = and i32 %28, 1
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %26
%32 = load i32*, i32** %5
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 8
%35 = icmp eq i32* %32, %34
br i1 %35, label %36, label %37
36: ; preds = %31, %15
store i32* null, i32** %2
br label %49
37: ; preds = %31, %26
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = and i32 %39, 1
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 1, i32 -1
store i32 %43, i32* %6
%44 = load i32*, i32** %5
%45 = load i32, i32* %6
%46 = mul nsw i32 %45, 8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %44, i64 %47
store i32* %48, i32** %2
br label %49
49: ; preds = %37, %36
%50 = load i32*, i32** %2
ret i32* %50
}

LLVM IR (-O2):
define i32* @get_hof_ver_normal(i32* %0) {
%2 = tail call i32* @get_current_iof(i32* %0)
%3 = tail call i32* @get_current_hof(i32* %0)
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %1
%8 = getelementptr inbounds i32, i32* %2, i64 7
%9 = load i32, i32* %8
%10 = shl nsw i32 %9, 3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %2, i64 %11
%13 = icmp eq i32* %3, %12
br i1 %13, label %20, label %17
14: ; preds = %1
%15 = getelementptr inbounds i32, i32* %2, i64 8
%16 = icmp eq i32* %3, %15
br i1 %16, label %20, label %17
17: ; preds = %7, %14
%18 = phi i64 [ 8, %7 ], [ -8, %14 ]
%19 = getelementptr inbounds i32, i32* %3, i64 %18
br label %20
20: ; preds = %7, %14, %17
%21 = phi i32* [ %19, %17 ], [ null, %14 ], [ null, %7 ]
ret i32* %21
}