#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 /*<<< orphan*/ data4;
typedef int /*<<< orphan*/ data3;
typedef int /*<<< orphan*/ data2;
typedef int /*<<< orphan*/ data1;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int nilsimsa_compare(char *, char *);
int /*<<< orphan*/ nilsimsa_compute(char const *, int, char *);
int main(int argc, char **argv) {
  const char data1[] = "abcdefgh";
  const char data2[] =
      "This is a much more ridiculous test because of 21347597.";
  const char data3[] = "The rain in Spain falls mostly in the plains.";
  const char data4[] = "The rain in Spain falls mainly in the plains.";
  int data1_sz = sizeof(data1) / sizeof(data1[0]) - 1;
  int data2_sz = sizeof(data2) / sizeof(data2[0]) - 1;
  int data3_sz = sizeof(data3) / sizeof(data3[0]) - 1;
  int data4_sz = sizeof(data4) / sizeof(data4[0]) - 1;
  char hash1[65] = {0};
  char hash2[65] = {0};
  char hash3[65] = {0};
  char hash4[65] = {0};
  nilsimsa_compute(data1, data1_sz, hash1);
  nilsimsa_compute(data2, data2_sz, hash2);
  nilsimsa_compute(data3, data3_sz, hash3);
  nilsimsa_compute(data4, data4_sz, hash4);
  assert(nilsimsa_compare(hash1, hash2) == 4);
  assert(nilsimsa_compare(hash3, hash4) == 92);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x39,%edx
call   1060 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x2e,%edx
call   1060 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
lea    0xec8(%rip),%rsi
mov    $0x2e,%edx
call   1060 <memcpy@plt>
movl   $0x8,-0xc4(%rbp)
movl   $0x38,-0xc8(%rbp)
movl   $0x2d,-0xcc(%rbp)
movl   $0x2d,-0xd0(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1040 <memset@plt>
lea    -0x170(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1040 <memset@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1040 <memset@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1040 <memset@plt>
lea    -0x19(%rbp),%rdi
mov    -0xc4(%rbp),%esi
lea    -0x120(%rbp),%rdx
call   1030 <nilsimsa_compute@plt>
lea    -0x60(%rbp),%rdi
mov    -0xc8(%rbp),%esi
lea    -0x170(%rbp),%rdx
call   1030 <nilsimsa_compute@plt>
lea    -0x90(%rbp),%rdi
mov    -0xcc(%rbp),%esi
lea    -0x1c0(%rbp),%rdx
call   1030 <nilsimsa_compute@plt>
lea    -0xc0(%rbp),%rdi
mov    -0xd0(%rbp),%esi
lea    -0x210(%rbp),%rdx
call   1030 <nilsimsa_compute@plt>
lea    -0x120(%rbp),%rdi
lea    -0x170(%rbp),%rsi
call   1070 <nilsimsa_compare@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x1c0(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1070 <nilsimsa_compare@plt>
cmp    $0x5c,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1f8,%rsp
movabs $0x6867666564636261,%rax
66 67 68
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
movups 0xee1(%rip),%xmm0
movups %xmm0,0x179(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x170(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movups 0xeda(%rip),%xmm0
movups %xmm0,0x1de(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x1d0(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x1c0(%rsp)
movups 0xedd(%rip),%xmm0
movups %xmm0,0x1ae(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x1a0(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0x190(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movb   $0x0,0x140(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movb   $0x0,0xf0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movb   $0x0,0xa0(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x50(%rsp)
mov    %rsp,%rdi
lea    0x100(%rsp),%r14
mov    $0x8,%esi
mov    %r14,%rdx
call   1030 <nilsimsa_compute@plt>
lea    0x150(%rsp),%rdi
lea    0xb0(%rsp),%r12
mov    $0x38,%esi
mov    %r12,%rdx
call   1030 <nilsimsa_compute@plt>
lea    0x1c0(%rsp),%rdi
lea    0x60(%rsp),%r15
mov    $0x2d,%esi
mov    %r15,%rdx
call   1030 <nilsimsa_compute@plt>
lea    0x190(%rsp),%rdi
lea    0x10(%rsp),%rbx
mov    $0x2d,%esi
mov    %rbx,%rdx
call   1030 <nilsimsa_compute@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <nilsimsa_compare@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1040 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <nilsimsa_compare@plt>
xor    %edi,%edi
cmp    $0x5c,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.data1 = [9 x i8] c"abcdefgh\00"
@__const.main.data2 = [57 x i8] c"This is a much more ridiculous test because of 21347597.\00"
@__const.main.data3 = [46 x i8] c"The rain in Spain falls mostly in the plains.\00"
@__const.main.data4 = [46 x i8] c"The rain in Spain falls mainly in the plains.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [9 x i8]
%7 = alloca [57 x i8]
%8 = alloca [46 x i8]
%9 = alloca [46 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [65 x i8]
%15 = alloca [65 x i8]
%16 = alloca [65 x i8]
%17 = alloca [65 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = bitcast [9 x i8]* %6 to i8*
%19 = bitcast [57 x i8]* %7 to i8*
%20 = bitcast [46 x i8]* %8 to i8*
%21 = bitcast [46 x i8]* %9 to i8*
store i32 8, i32* %10
store i32 56, i32* %11
store i32 45, i32* %12
store i32 45, i32* %13
%22 = bitcast [65 x i8]* %14 to i8*
%23 = bitcast [65 x i8]* %15 to i8*
%24 = bitcast [65 x i8]* %16 to i8*
%25 = bitcast [65 x i8]* %17 to i8*
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%27 = load i32, i32* %10
%28 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%29 = call i32 @nilsimsa_compute(i8* %26, i32 %27, i8* %28)
%30 = getelementptr inbounds [57 x i8], [57 x i8]* %7, i64 0, i64 0
%31 = load i32, i32* %11
%32 = getelementptr inbounds [65 x i8], [65 x i8]* %15, i64 0, i64 0
%33 = call i32 @nilsimsa_compute(i8* %30, i32 %31, i8* %32)
%34 = getelementptr inbounds [46 x i8], [46 x i8]* %8, i64 0, i64 0
%35 = load i32, i32* %12
%36 = getelementptr inbounds [65 x i8], [65 x i8]* %16, i64 0, i64 0
%37 = call i32 @nilsimsa_compute(i8* %34, i32 %35, i8* %36)
%38 = getelementptr inbounds [46 x i8], [46 x i8]* %9, i64 0, i64 0
%39 = load i32, i32* %13
%40 = getelementptr inbounds [65 x i8], [65 x i8]* %17, i64 0, i64 0
%41 = call i32 @nilsimsa_compute(i8* %38, i32 %39, i8* %40)
%42 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%43 = getelementptr inbounds [65 x i8], [65 x i8]* %15, i64 0, i64 0
%44 = call i32 @nilsimsa_compare(i8* %42, i8* %43)
%45 = icmp eq i32 %44, 4
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = getelementptr inbounds [65 x i8], [65 x i8]* %16, i64 0, i64 0
%49 = getelementptr inbounds [65 x i8], [65 x i8]* %17, i64 0, i64 0
%50 = call i32 @nilsimsa_compare(i8* %48, i8* %49)
%51 = icmp eq i32 %50, 92
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
ret i32 0
}

LLVM IR (-O2):
@__const.main.data1 = [9 x i8] c"abcdefgh\00"
@__const.main.data2 = [57 x i8] c"This is a much more ridiculous test because of 21347597.\00"
@__const.main.data3 = [46 x i8] c"The rain in Spain falls mostly in the plains.\00"
@__const.main.data4 = [46 x i8] c"The rain in Spain falls mainly in the plains.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x i8]
%4 = alloca [57 x i8]
%5 = alloca [46 x i8]
%6 = alloca [46 x i8]
%7 = alloca [65 x i8]
%8 = alloca [65 x i8]
%9 = alloca [65 x i8]
%10 = alloca [65 x i8]
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [57 x i8], [57 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [46 x i8], [46 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [46 x i8], [46 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [65 x i8], [65 x i8]* %8, i64 0, i64 0
%17 = getelementptr inbounds [65 x i8], [65 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds [65 x i8], [65 x i8]* %10, i64 0, i64 0
%19 = call i32 @nilsimsa_compute(i8* %11, i32 8, i8* %15)
%20 = call i32 @nilsimsa_compute(i8* %12, i32 56, i8* %16)
%21 = call i32 @nilsimsa_compute(i8* %13, i32 45, i8* %17)
%22 = call i32 @nilsimsa_compute(i8* %14, i32 45, i8* %18)
%23 = call i32 @nilsimsa_compare(i8* %15, i8* %16)
%24 = icmp eq i32 %23, 4
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @nilsimsa_compare(i8* %17, i8* %18)
%28 = icmp eq i32 %27, 92
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret i32 0
}