#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 */
int /*<<< orphan*/ hash_data_extract_printable_checksum(char const *,
                                                        unsigned int, char *);
scalar_t__ hash_data_has_checksum(char const *, unsigned int);
int /*<<< orphan*/ hash_function_name(unsigned int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
char toupper(char);
void hash_data_print(const char *data, unsigned int functions, char *buffer) {
  int i, j;
  char first = 1;
  if (functions == 0)
    functions = ~functions;
  buffer[0] = '\0';
  for (i = 0; i < 3; i++) {
    unsigned func = 1 << i;
    if ((functions & func) && hash_data_has_checksum(data, func)) {
      char temp[256];
      if (!first)
        strcat(buffer, " ");
      first = 0;
      strcpy(temp, hash_function_name(func));
      for (j = 0; temp[j]; j++)
        temp[j] = toupper(temp[j]);
      strcat(buffer, temp);
      strcat(buffer, "(");
      hash_data_extract_printable_checksum(data, func, temp);
      strcat(buffer, temp);
      strcat(buffer, ")");
    }
  }
}


x86 assembly (clang, -O0):
<hash_data_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x1,-0x21(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118d <hash_data_print+0x2d>
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    12c4 <hash_data_print+0x164>
mov    -0x1c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
and    -0x28(%rbp),%eax
cmp    $0x0,%eax
je     12b1 <hash_data_print+0x151>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1070 <hash_data_has_checksum@plt>
cmp    $0x0,%rax
je     12b1 <hash_data_print+0x151>
cmpb   $0x0,-0x21(%rbp)
jne    11f1 <hash_data_print+0x91>
mov    -0x18(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1080 <strcat@plt>
movb   $0x0,-0x21(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x28(%rbp),%edi
call   1060 <hash_function_name@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmpb   $0x0,-0x130(%rbp,%rax,1)
je     125e <hash_data_print+0xfe>
movslq -0x20(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x130(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1220 <hash_data_print+0xc0>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x130(%rbp),%rdx
call   1050 <hash_data_extract_printable_checksum@plt>
mov    -0x18(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1080 <strcat@plt>
jmp    12b6 <hash_data_print+0x156>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119b <hash_data_print+0x3b>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_data_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdx,%r14
mov    %rdi,%r15
cmp    $0x1,%esi
sbb    %ebx,%ebx
or     %esi,%ebx
movb   $0x0,(%rdx)
xor    %ebp,%ebp
mov    $0x1,%r12b
mov    %ebx,0xc(%rsp)
jmp    11e6 <hash_data_print+0x86>
nopl   0x0(%rax)
mov    %r14,%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
lea    0xe58(%rip),%rsi
call   1080 <strcat@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %rbx,%rdx
call   1050 <hash_data_extract_printable_checksum@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
lea    0xe32(%rip),%rsi
call   1080 <strcat@plt>
xor    %r12d,%r12d
mov    0xc(%rsp),%ebx
add    $0x1,%ebp
cmp    $0x3,%ebp
je     125b <hash_data_print+0xfb>
mov    $0x1,%r13d
mov    %ebp,%ecx
shl    %cl,%r13d
bt     %ebp,%ebx
jae    11de <hash_data_print+0x7e>
mov    %r15,%rdi
mov    %r13d,%esi
call   1070 <hash_data_has_checksum@plt>
test   %rax,%rax
je     11de <hash_data_print+0x7e>
test   %r12b,%r12b
jne    121a <hash_data_print+0xba>
mov    %r14,%rdi
lea    0xdeb(%rip),%rsi
call   1080 <strcat@plt>
mov    %r13d,%edi
call   1060 <hash_function_name@plt>
lea    0x10(%rsp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     1190 <hash_data_print+0x30>
lea    0x11(%rsp),%rbx
nop
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1240 <hash_data_print+0xe0>
jmp    1190 <hash_data_print+0x30>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c")\00"
define void @hash_data_print(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca [256 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i8 1, i8* %9
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* %5
%16 = xor i32 %15, -1
store i32 %16, i32* %5
br label %17
17: ; preds = %14, %3
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 0, i8* %19
store i32 0, i32* %7
br label %20
20: ; preds = %80, %17
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %83
23: ; preds = %20
%24 = load i32, i32* %7
%25 = shl i32 1, %24
store i32 %25, i32* %10
%26 = load i32, i32* %5
%27 = load i32, i32* %10
%28 = and i32 %26, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %79
30: ; preds = %23
%31 = load i8*, i8** %4
%32 = load i32, i32* %10
%33 = call i64 @hash_data_has_checksum(i8* %31, i32 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %79
35: ; preds = %30
%36 = load i8, i8* %9
%37 = icmp ne i8 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = load i8*, i8** %6
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %38, %35
store i8 0, i8* %9
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%43 = load i32, i32* %10
%44 = call i32 @hash_function_name(i32 %43)
%45 = call i32 @strcpy(i8* %42, i32 %44)
store i32 0, i32* %8
br label %46
46: ; preds = %61, %41
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 0
br i1 %51, label %52, label %64
52: ; preds = %46
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = call signext i8 @toupper(i8 signext %56)
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %59
store i8 %57, i8* %60
br label %61
61: ; preds = %52
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %46
64: ; preds = %46
%65 = load i8*, i8** %6
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%67 = call i32 @strcat(i8* %65, i8* %66)
%68 = load i8*, i8** %6
%69 = call i32 @strcat(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%70 = load i8*, i8** %4
%71 = load i32, i32* %10
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%73 = call i32 @hash_data_extract_printable_checksum(i8* %70, i32 %71, i8* %72)
%74 = load i8*, i8** %6
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%76 = call i32 @strcat(i8* %74, i8* %75)
%77 = load i8*, i8** %6
%78 = call i32 @strcat(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %79
79: ; preds = %64, %30, %23
br label %80
80: ; preds = %79
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
store i32 %82, i32* %7
br label %20
83: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"(\00"
@.str.2 = [2 x i8] c")\00"
define void @hash_data_print(i8* %0, i32 %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i32 -1, i32 %1
store i8 0, i8* %2
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
br label %8
8: ; preds = %3, %41
%9 = phi i8 [ 1, %3 ], [ %42, %41 ]
%10 = phi i32 [ 0, %3 ], [ %43, %41 ]
%11 = shl nuw nsw i32 1, %10
%12 = and i32 %11, %6
%13 = icmp eq i32 %12, 0
br i1 %13, label %41, label %14
14: ; preds = %8
%15 = call i64 @hash_data_has_checksum(i8* %0, i32 %11)
%16 = icmp eq i64 %15, 0
br i1 %16, label %41, label %17
17: ; preds = %14
%18 = icmp eq i8 %9, 0
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = call i32 @hash_function_name(i32 %11)
%23 = call i32 @strcpy(i8* %7, i32 %22)
%24 = load i8, i8* %7
%25 = icmp eq i8 %24, 0
br i1 %25, label %35, label %26
26: ; preds = %21, %26
%27 = phi i64 [ %31, %26 ], [ 0, %21 ]
%28 = phi i8 [ %33, %26 ], [ %24, %21 ]
%29 = phi i8* [ %32, %26 ], [ %7, %21 ]
%30 = call signext i8 @toupper(i8 signext %28)
store i8 %30, i8* %29
%31 = add nuw i64 %27, 1
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %26
35: ; preds = %26, %21
%36 = call i32 @strcat(i8* %2, i8* %7)
%37 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @hash_data_extract_printable_checksum(i8* %0, i32 %11, i8* %7)
%39 = call i32 @strcat(i8* %2, i8* %7)
%40 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %35, %14, %8
%42 = phi i8 [ 0, %35 ], [ %9, %14 ], [ %9, %8 ]
%43 = add nuw nsw i32 %10, 1
%44 = icmp eq i32 %43, 3
br i1 %44, label %45, label %8
45: ; preds = %41
ret void
}