#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__ hash_data_has_checksum(char const *, int);
unsigned int hash_data_used_functions(const char *data) {
  int i;
  unsigned int res = 0;
  if (!data)
    return 0;
  for (i = 0; i < 3; i++)
    if (hash_data_has_checksum(data, 1 << i))
      res |= 1 << i;
  return res;
}


x86 assembly (clang, -O0):
<hash_data_used_functions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <hash_data_used_functions+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    1191 <hash_data_used_functions+0x81>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    118b <hash_data_used_functions+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
call   1030 <hash_data_has_checksum@plt>
cmp    $0x0,%rax
je     1178 <hash_data_used_functions+0x68>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    117d <hash_data_used_functions+0x6d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <hash_data_used_functions+0x31>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_data_used_functions>:
test   %rdi,%rdi
je     116a <hash_data_used_functions+0x5a>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1,%esi
call   1030 <hash_data_has_checksum@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <hash_data_has_checksum@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%r14,%rcx,2),%r14d
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <hash_data_has_checksum@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%r14,%rcx,4),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @hash_data_used_functions(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %30
9: ; preds = %1
store i32 0, i32* %4
br label %10
10: ; preds = %25, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = shl i32 1, %15
%17 = call i64 @hash_data_has_checksum(i8* %14, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32, i32* %4
%21 = shl i32 1, %20
%22 = load i32, i32* %5
%23 = or i32 %22, %21
store i32 %23, i32* %5
br label %24
24: ; preds = %19, %13
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i32, i32* %5
store i32 %29, i32* %2
br label %30
30: ; preds = %28, %8
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @hash_data_used_functions(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i64 @hash_data_has_checksum(i8* %0, i32 1)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i64 @hash_data_has_checksum(i8* %0, i32 2)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 0, i32 2
%10 = or i32 %9, %6
%11 = tail call i64 @hash_data_has_checksum(i8* %0, i32 4)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 0, i32 4
%14 = or i32 %13, %10
br label %15
15: ; preds = %3, %1
%16 = phi i32 [ 0, %1 ], [ %14, %3 ]
ret i32 %16
}