#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;

/* Variables and functions */
int /*<<< orphan*/ hash1(int *, int *);
scalar_t__ memcmp(int *, int *, int);
int /*<<< orphan*/ printarr(char *, int *, int);
int /*<<< orphan*/ prnlog(char *);
int _testHash1() {
  uint8_t csn[8] = {0x01, 0x02, 0x03, 0x04, 0xF7, 0xFF, 0x12, 0xE0};
  uint8_t k[8] = {0};
  hash1(csn, k);
  uint8_t expected[8] = {0x7E, 0x72, 0x2F, 0x40, 0x2D, 0x02, 0x51, 0x42};
  if (memcmp(k, expected, 8) != 0) {
    prnlog("Error with hash1!");
    printarr("calculated", k, 8);
    printarr("expected", expected, 8);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_testHash1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <hash1@plt>
mov    0xe78(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe75(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     122b <_testHash1+0xdb>
lea    0xe50(%rip),%rdi
call   1030 <prnlog@plt>
lea    -0x50(%rbp),%rsi
lea    0xe52(%rip),%rdi
mov    $0x8,%edx
call   1060 <printarr@plt>
lea    -0x70(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x8,%edx
call   1060 <printarr@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <_testHash1+0xe2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_testHash1>:
push   %rbx
sub    $0x60,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x40(%rsp),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <hash1@plt>
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe91(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     11e5 <_testHash1+0xa5>
lea    0xe91(%rip),%rdi
call   1030 <prnlog@plt>
lea    0xe97(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
call   1050 <printarr@plt>
lea    0xe8c(%rip),%rdi
mov    %rsp,%rsi
mov    $0x8,%edx
call   1050 <printarr@plt>
mov    $0x1,%eax
jmp    11e7 <_testHash1+0xa7>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const._testHash1.csn = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 247, i32 255, i32 18, i32 224]
@__const._testHash1.expected = [8 x i32] [i32 126, i32 114, i32 47, i32 64, i32 45, i32 2, i32 81, i32 66]
@.str = [18 x i8] c"Error with hash1!\00"
@.str.1 = [11 x i8] c"calculated\00"
@.str.2 = [9 x i8] c"expected\00"
define i32 @_testHash1() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca [8 x i32]
%4 = alloca [8 x i32]
%5 = bitcast [8 x i32]* %2 to i8*
%6 = bitcast [8 x i32]* %3 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%9 = call i32 @hash1(i32* %7, i32* %8)
%10 = bitcast [8 x i32]* %4 to i8*
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%13 = call i64 @memcmp(i32* %11, i32* %12, i32 8)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %0
%16 = call i32 @prnlog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%18 = call i32 @printarr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %17, i32 8)
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%20 = call i32 @printarr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %19, i32 8)
store i32 1, i32* %1
br label %22
21: ; preds = %0
store i32 0, i32* %1
br label %22
22: ; preds = %21, %15
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@__const._testHash1.csn = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 247, i32 255, i32 18, i32 224]
@__const._testHash1.expected = [8 x i32] [i32 126, i32 114, i32 47, i32 64, i32 45, i32 2, i32 81, i32 66]
@.str = [18 x i8] c"Error with hash1!\00"
@.str.1 = [11 x i8] c"calculated\00"
@.str.2 = [9 x i8] c"expected\00"
define i32 @_testHash1() {
%1 = alloca [8 x i32]
%2 = alloca [8 x i32]
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %1 to i8*
%5 = bitcast [8 x i32]* %2 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%8 = call i32 @hash1(i32* %6, i32* %7)
%9 = bitcast [8 x i32]* %3 to i8*
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%11 = call i64 @memcmp(i32* %7, i32* %10, i32 8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = call i32 @prnlog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @printarr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32 8)
%16 = call i32 @printarr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %10, i32 8)
br label %17
17: ; preds = %0, %13
%18 = phi i32 [ 1, %13 ], [ 0, %0 ]
ret i32 %18
}