#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 */
unsigned int count_similars(unsigned int *, unsigned int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sign(char *, int /*<<< orphan*/, unsigned int *, int);
int /*<<< orphan*/ strlen(char *);
int test_sign_similarity() {
  unsigned int result[16];
  unsigned int s1[16];
  unsigned int s2[16];
  char digits1[] = "948259038450923823094850923845092384598234532452908345";
  char digits2[] = "948259038450923823094850924845092384598234532452908345";
  char letters1[] = "kldfgjlksdmklvcamsdkcjaslkfjalskdjfklasdmklsajflkas";
  char letters2[] = "kldfgjlksdmklvcatsdkcjaslkfjalskdjfklasdmklsajflkas";
  unsigned int sims;
  printf("\n* Testing similarity properties of catalog1:\n");
  sign(letters1, strlen(letters1), s1, 16);
  sign(letters2, strlen(letters2), s2, 16);
  sims = count_similars(s1, s2, 16);
  if (sims < 16 / 2) {
    printf("letters1 is not so similar to letters2.\n");
    return -1;
  }
  sign(digits1, strlen(digits1), s1, 16);
  sign(digits2, strlen(digits2), s2, 16);
  sims = count_similars(s1, s2, 16);
  if (sims < 16 / 2) {
    printf("digits1 is not so similar to digits2.\n");
    return -1;
  }
  sign(letters1, strlen(letters1), s1, 16);
  sign(digits2, strlen(digits2), s2, 16);
  sims = count_similars(s1, s2, 16);
  if (sims > 0) {
    printf("A similarity was found between letters1 and digits2\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_sign_similarity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    -0x110(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x37,%edx
call   1050 <memcpy@plt>
lea    -0x150(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x37,%edx
call   1050 <memcpy@plt>
lea    -0x190(%rbp),%rdi
lea    0xee7(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
lea    -0x1d0(%rbp),%rdi
lea    0xf0f(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
lea    0xf32(%rip),%rdi
call   1040 <printf@plt>
lea    -0x190(%rbp),%rax
mov    %rax,-0x1e8(%rbp)
lea    -0x190(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1e8(%rbp),%rdi
mov    %eax,%esi
lea    -0x90(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x1d0(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
lea    -0x1d0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1e0(%rbp),%rdi
mov    %eax,%esi
lea    -0xd0(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    $0x10,%edx
call   1070 <count_similars@plt>
mov    %eax,-0x1d4(%rbp)
cmpl   $0x8,-0x1d4(%rbp)
jae    1272 <test_sign_similarity+0x122>
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13cf <test_sign_similarity+0x27f>
lea    -0x110(%rbp),%rax
mov    %rax,-0x1f8(%rbp)
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1f8(%rbp),%rdi
mov    %eax,%esi
lea    -0x90(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x150(%rbp),%rax
mov    %rax,-0x1f0(%rbp)
lea    -0x150(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1f0(%rbp),%rdi
mov    %eax,%esi
lea    -0xd0(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    $0x10,%edx
call   1070 <count_similars@plt>
mov    %eax,-0x1d4(%rbp)
cmpl   $0x8,-0x1d4(%rbp)
jae    131d <test_sign_similarity+0x1cd>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13cf <test_sign_similarity+0x27f>
lea    -0x190(%rbp),%rax
mov    %rax,-0x208(%rbp)
lea    -0x190(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x208(%rbp),%rdi
mov    %eax,%esi
lea    -0x90(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x150(%rbp),%rax
mov    %rax,-0x200(%rbp)
lea    -0x150(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x200(%rbp),%rdi
mov    %eax,%esi
lea    -0xd0(%rbp),%rdx
mov    $0x10,%ecx
call   1060 <sign@plt>
lea    -0x90(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
mov    $0x10,%edx
call   1070 <count_similars@plt>
mov    %eax,-0x1d4(%rbp)
cmpl   $0x0,-0x1d4(%rbp)
jbe    13c8 <test_sign_similarity+0x278>
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13cf <test_sign_similarity+0x27f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sign_similarity>:
push   %r15
push   %r14
push   %rbx
sub    $0x180,%rsp
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movabs $0x35343338303932,%rax
mov    %rax,0xef(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %rax,0x6f(%rsp)
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x73616b,0x30(%rsp)
movaps 0xefa(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movl   $0x73616b,0xb0(%rsp)
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x140(%rsp),%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x100(%rsp),%r15
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1060 <count_similars@plt>
cmp    $0x8,%eax
jae    1293 <test_sign_similarity+0x153>
lea    0xeee(%rip),%rdi
jmp    1369 <test_sign_similarity+0x229>
lea    0xc0(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x140(%rsp),%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x100(%rsp),%r15
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1060 <count_similars@plt>
cmp    $0x8,%eax
jae    1302 <test_sign_similarity+0x1c2>
lea    0xe56(%rip),%rdi
jmp    1369 <test_sign_similarity+0x229>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x140(%rsp),%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x100(%rsp),%r15
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x10,%ecx
call   1050 <sign@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1060 <count_similars@plt>
test   %eax,%eax
je     1380 <test_sign_similarity+0x240>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x180,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
jmp    1373 <test_sign_similarity+0x233>

LLVM IR (-O0):
@__const.test_sign_similarity.digits1 = [55 x i8] c"948259038450923823094850923845092384598234532452908345\00"
@__const.test_sign_similarity.digits2 = [55 x i8] c"948259038450923823094850924845092384598234532452908345\00"
@__const.test_sign_similarity.letters1 = [52 x i8] c"kldfgjlksdmklvcamsdkcjaslkfjalskdjfklasdmklsajflkas\00"
@__const.test_sign_similarity.letters2 = [52 x i8] c"kldfgjlksdmklvcatsdkcjaslkfjalskdjfklasdmklsajflkas\00"
@.str = [47 x i8] c"\0A* Testing similarity properties of catalog1:\0A\00"
@.str.1 = [41 x i8] c"letters1 is not so similar to letters2.\0A\00"
@.str.2 = [39 x i8] c"digits1 is not so similar to digits2.\0A\00"
@.str.3 = [53 x i8] c"A similarity was found between letters1 and digits2\0A\00"
define i32 @test_sign_similarity() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca [16 x i32]
%4 = alloca [16 x i32]
%5 = alloca [55 x i8]
%6 = alloca [55 x i8]
%7 = alloca [52 x i8]
%8 = alloca [52 x i8]
%9 = alloca i32
%10 = bitcast [55 x i8]* %5 to i8*
%11 = bitcast [55 x i8]* %6 to i8*
%12 = bitcast [52 x i8]* %7 to i8*
%13 = bitcast [52 x i8]* %8 to i8*
%14 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [52 x i8], [52 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [52 x i8], [52 x i8]* %7, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%19 = call i32 @sign(i8* %15, i32 %17, i32* %18, i32 16)
%20 = getelementptr inbounds [52 x i8], [52 x i8]* %8, i64 0, i64 0
%21 = getelementptr inbounds [52 x i8], [52 x i8]* %8, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%24 = call i32 @sign(i8* %20, i32 %22, i32* %23, i32 16)
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%26 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%27 = call i32 @count_similars(i32* %25, i32* %26, i32 16)
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = icmp ult i32 %28, 8
br i1 %29, label %30, label %32
30: ; preds = %0
%31 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %69
32: ; preds = %0
%33 = getelementptr inbounds [55 x i8], [55 x i8]* %5, i64 0, i64 0
%34 = getelementptr inbounds [55 x i8], [55 x i8]* %5, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%37 = call i32 @sign(i8* %33, i32 %35, i32* %36, i32 16)
%38 = getelementptr inbounds [55 x i8], [55 x i8]* %6, i64 0, i64 0
%39 = getelementptr inbounds [55 x i8], [55 x i8]* %6, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%42 = call i32 @sign(i8* %38, i32 %40, i32* %41, i32 16)
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%44 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%45 = call i32 @count_similars(i32* %43, i32* %44, i32 16)
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = icmp ult i32 %46, 8
br i1 %47, label %48, label %50
48: ; preds = %32
%49 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %69
50: ; preds = %32
%51 = getelementptr inbounds [52 x i8], [52 x i8]* %7, i64 0, i64 0
%52 = getelementptr inbounds [52 x i8], [52 x i8]* %7, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%55 = call i32 @sign(i8* %51, i32 %53, i32* %54, i32 16)
%56 = getelementptr inbounds [55 x i8], [55 x i8]* %6, i64 0, i64 0
%57 = getelementptr inbounds [55 x i8], [55 x i8]* %6, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%60 = call i32 @sign(i8* %56, i32 %58, i32* %59, i32 16)
%61 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%62 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%63 = call i32 @count_similars(i32* %61, i32* %62, i32 16)
store i32 %63, i32* %9
%64 = load i32, i32* %9
%65 = icmp ugt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %50
%67 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %69
68: ; preds = %50
store i32 0, i32* %1
br label %69
69: ; preds = %68, %66, %48, %30
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@__const.test_sign_similarity.digits1 = [55 x i8] c"948259038450923823094850923845092384598234532452908345\00"
@__const.test_sign_similarity.digits2 = [55 x i8] c"948259038450923823094850924845092384598234532452908345\00"
@__const.test_sign_similarity.letters1 = [52 x i8] c"kldfgjlksdmklvcamsdkcjaslkfjalskdjfklasdmklsajflkas\00"
@__const.test_sign_similarity.letters2 = [52 x i8] c"kldfgjlksdmklvcatsdkcjaslkfjalskdjfklasdmklsajflkas\00"
@str = [46 x i8] c"\0A* Testing similarity properties of catalog1:\00"
@str.4 = [52 x i8] c"A similarity was found between letters1 and digits2\00"
@str.5 = [38 x i8] c"digits1 is not so similar to digits2.\00"
@str.6 = [40 x i8] c"letters1 is not so similar to letters2.\00"
define i32 @test_sign_similarity() {
%1 = alloca [16 x i32]
%2 = alloca [16 x i32]
%3 = alloca [55 x i8]
%4 = alloca [55 x i8]
%5 = alloca [52 x i8]
%6 = alloca [52 x i8]
%7 = bitcast [16 x i32]* %1 to i8*
%8 = bitcast [16 x i32]* %2 to i8*
%9 = getelementptr inbounds [55 x i8], [55 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [55 x i8], [55 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [52 x i8], [52 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [52 x i8], [52 x i8]* %6, i64 0, i64 0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%14 = call i32 @strlen(i8* %11)
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%16 = call i32 @sign(i8* %11, i32 %14, i32* %15, i32 16)
%17 = call i32 @strlen(i8* %12)
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%19 = call i32 @sign(i8* %12, i32 %17, i32* %18, i32 16)
%20 = call i32 @count_similars(i32* %15, i32* %18, i32 16)
%21 = icmp ult i32 %20, 8
br i1 %21, label %36, label %22
22: ; preds = %0
%23 = call i32 @strlen(i8* %9)
%24 = call i32 @sign(i8* %9, i32 %23, i32* %15, i32 16)
%25 = call i32 @strlen(i8* %10)
%26 = call i32 @sign(i8* %10, i32 %25, i32* %18, i32 16)
%27 = call i32 @count_similars(i32* %15, i32* %18, i32 16)
%28 = icmp ult i32 %27, 8
br i1 %28, label %36, label %29
29: ; preds = %22
%30 = call i32 @strlen(i8* %11)
%31 = call i32 @sign(i8* %11, i32 %30, i32* %15, i32 16)
%32 = call i32 @strlen(i8* %10)
%33 = call i32 @sign(i8* %10, i32 %32, i32* %18, i32 16)
%34 = call i32 @count_similars(i32* %15, i32* %18, i32 16)
%35 = icmp eq i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %29, %22, %0
%37 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @str.5, i64 0, i64 0), %22 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.4, i64 0, i64 0), %29 ]
%38 = call i32 @puts(i8* dereferenceable(1) %37)
br label %39
39: ; preds = %36, %29
%40 = phi i32 [ 0, %29 ], [ -1, %36 ]
ret i32 %40
}