#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 t_hdata {
  int dummy;
};

/* Variables and functions */
void *hdata_move(struct t_hdata *, void *, int);
int hdata_check_pointer_in_list(struct t_hdata *hdata, void *list,
                                void *pointer) {
  void *ptr_current;
  if (!hdata || !pointer)
    return 0;
  if (pointer == list)
    return 1;
  ptr_current = list;
  while (ptr_current) {
    ptr_current = hdata_move(hdata, ptr_current, 1);
    if (ptr_current && (ptr_current == pointer))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hdata_check_pointer_in_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113a <hdata_check_pointer_in_list+0x2a>
cmpq   $0x0,-0x20(%rbp)
jne    1146 <hdata_check_pointer_in_list+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11ba <hdata_check_pointer_in_list+0xaa>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1160 <hdata_check_pointer_in_list+0x50>
movl   $0x1,-0x4(%rbp)
jmp    11ba <hdata_check_pointer_in_list+0xaa>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11b3 <hdata_check_pointer_in_list+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x1,%edx
call   1030 <hdata_move@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ae <hdata_check_pointer_in_list+0x9e>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    11ae <hdata_check_pointer_in_list+0x9e>
movl   $0x1,-0x4(%rbp)
jmp    11ba <hdata_check_pointer_in_list+0xaa>
jmp    1168 <hdata_check_pointer_in_list+0x58>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdata_check_pointer_in_list>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1151 <hdata_check_pointer_in_list+0x41>
mov    %rdx,%r14
test   %rdx,%rdx
je     1151 <hdata_check_pointer_in_list+0x41>
cmp    %rsi,%r14
je     1155 <hdata_check_pointer_in_list+0x45>
mov    %rdi,%rbx
mov    $0x1,%ebp
xchg   %ax,%ax
test   %rsi,%rsi
je     1151 <hdata_check_pointer_in_list+0x41>
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <hdata_move@plt>
mov    %rax,%rsi
test   %rax,%rax
je     1130 <hdata_check_pointer_in_list+0x20>
cmp    %r14,%rsi
jne    1130 <hdata_check_pointer_in_list+0x20>
jmp    115a <hdata_check_pointer_in_list+0x4a>
xor    %ebp,%ebp
jmp    115a <hdata_check_pointer_in_list+0x4a>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.t_hdata = type { i32 }
define i32 @hdata_check_pointer_in_list(%struct.t_hdata* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.t_hdata*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.t_hdata* %0, %struct.t_hdata** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load %struct.t_hdata*, %struct.t_hdata** %5
%10 = icmp ne %struct.t_hdata* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11, %3
store i32 0, i32* %4
br label %38
15: ; preds = %11
%16 = load i8*, i8** %7
%17 = load i8*, i8** %6
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %4
br label %38
20: ; preds = %15
%21 = load i8*, i8** %6
store i8* %21, i8** %8
br label %22
22: ; preds = %36, %20
%23 = load i8*, i8** %8
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load %struct.t_hdata*, %struct.t_hdata** %5
%27 = load i8*, i8** %8
%28 = call i8* @hdata_move(%struct.t_hdata* %26, i8* %27, i32 1)
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %36
31: ; preds = %25
%32 = load i8*, i8** %8
%33 = load i8*, i8** %7
%34 = icmp eq i8* %32, %33
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %4
br label %38
36: ; preds = %31, %25
br label %22
37: ; preds = %22
store i32 0, i32* %4
br label %38
38: ; preds = %37, %35, %19, %14
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
%struct.t_hdata = type { i32 }
define i32 @hdata_check_pointer_in_list(%struct.t_hdata* %0, i8* %1, i8* readnone %2) {
%4 = icmp ne %struct.t_hdata* %0, null
%5 = icmp ne i8* %2, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = icmp eq i8* %2, %1
br i1 %8, label %17, label %9
9: ; preds = %7, %12
%10 = phi i8* [ %13, %12 ], [ %1, %7 ]
%11 = icmp eq i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = tail call i8* @hdata_move(%struct.t_hdata* %0, i8* %10, i32 1)
%14 = icmp ne i8* %13, null
%15 = icmp eq i8* %13, %2
%16 = and i1 %14, %15
br i1 %16, label %17, label %9
17: ; preds = %9, %12, %7, %3
%18 = phi i32 [ 0, %3 ], [ 1, %7 ], [ 0, %9 ], [ 1, %12 ]
ret i32 %18
}