#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*/ free(int *);
unsigned long hash_str(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
void str_array_diff(char **first, char **second, int size) {
  int *xs = (int *)malloc(sizeof(int) * 31);
  for (int i = 0; i < size; i++) {
    unsigned long h = hash_str(first[i]);
    xs[h % 31]++;
  }
  printf("[");
  for (int i = 0; i < size + 1; i++) {
    unsigned long h = hash_str(second[i]);
    if (!xs[h % 31])
      printf("%s, ", second[i]);
  }
  printf("]\n");
  free(xs);
}


x86 assembly (clang, -O0):
<str_array_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x7c,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ba <str_array_diff+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <hash_str@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x1f,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x48(%rbp),%rax
mov    (%rax,%rdx,4),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax,%rdx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1168 <str_array_diff+0x28>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1246 <str_array_diff+0x106>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <hash_str@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    $0x1f,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x50(%rbp),%rax
cmpl   $0x0,(%rax,%rdx,4)
jne    1233 <str_array_diff+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1238 <str_array_diff+0xf8>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cf <str_array_diff+0x8f>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_array_diff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x7c,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %r14d,%r14d
jle    11d3 <str_array_diff+0x73>
mov    %r14d,%ebp
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%r12,%r13,8),%rdi
call   1060 <hash_str@plt>
mov    %rax,%rcx
movabs $0x842108421084211,%rdx
10 42 08
mul    %rdx
mov    %rcx,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x4,%rax
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rdx,%rax
add    %rcx,%rax
addl   $0x1,(%rbx,%rax,4)
add    $0x1,%r13
cmp    %r13,%rbp
jne    1190 <str_array_diff+0x30>
mov    $0x5b,%edi
call   1040 <putchar@plt>
test   %r14d,%r14d
movabs $0x842108421084211,%r13
10 42 08
js     124b <str_array_diff+0xeb>
add    $0x1,%r14d
lea    0xe09(%rip),%r12
xor    %ebp,%ebp
jmp    1209 <str_array_diff+0xa9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r14
je     124b <str_array_diff+0xeb>
mov    (%r15,%rbp,8),%rdi
call   1060 <hash_str@plt>
mov    %rax,%rcx
mul    %r13
mov    %rcx,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x4,%rax
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rdx,%rax
add    %rcx,%rax
cmpl   $0x0,(%rbx,%rax,4)
jne    1200 <str_array_diff+0xa0>
mov    (%r15,%rbp,8),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1200 <str_array_diff+0xa0>
lea    0xdb3(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [5 x i8] c"%s, \00"
@.str.2 = [3 x i8] c"]\0A\00"
define void @str_array_diff(i8** %0, i8** %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%12 = call i64 @malloc(i32 124)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %7
store i32 0, i32* %8
br label %14
14: ; preds = %31, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %14
%19 = load i8**, i8*** %4
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @hash_str(i8* %23)
store i64 %24, i64* %9
%25 = load i32*, i32** %7
%26 = load i64, i64* %9
%27 = urem i64 %26, 31
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %18
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %14
34: ; preds = %14
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %36
36: ; preds = %62, %34
%37 = load i32, i32* %10
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %65
41: ; preds = %36
%42 = load i8**, i8*** %5
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i64 @hash_str(i8* %46)
store i64 %47, i64* %11
%48 = load i32*, i32** %7
%49 = load i64, i64* %11
%50 = urem i64 %49, 31
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %61, label %54
54: ; preds = %41
%55 = load i8**, i8*** %5
%56 = load i32, i32* %10
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %54, %41
br label %62
62: ; preds = %61
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %36
65: ; preds = %36
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%67 = load i32*, i32** %7
%68 = call i32 @free(i32* %67)
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%s, \00"
@str = [2 x i8] c"]\00"
define void @str_array_diff(i8** nocapture %0, i8** nocapture %1, i32 %2) {
%4 = tail call i64 @malloc(i32 124)
%5 = inttoptr i64 %4 to i32*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %15
9: ; preds = %15, %3
%10 = tail call i32 @putchar(i32 91)
%11 = icmp slt i32 %2, 0
br i1 %11, label %26, label %12
12: ; preds = %9
%13 = add nuw i32 %2, 1
%14 = zext i32 %13 to i64
br label %29
15: ; preds = %7, %15
%16 = phi i64 [ 0, %7 ], [ %24, %15 ]
%17 = getelementptr inbounds i8*, i8** %0, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i64 @hash_str(i8* %18)
%20 = urem i64 %19, 31
%21 = getelementptr inbounds i32, i32* %5, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
%24 = add nuw nsw i64 %16, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %9, label %15
26: ; preds = %41, %9
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 @free(i32* %5)
ret void
29: ; preds = %12, %41
%30 = phi i64 [ 0, %12 ], [ %42, %41 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i64 @hash_str(i8* %32)
%34 = urem i64 %33, 31
%35 = getelementptr inbounds i32, i32* %5, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %29
%39 = load i8*, i8** %31
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %38, %29
%42 = add nuw nsw i64 %30, 1
%43 = icmp eq i64 %42, %14
br i1 %43, label %26, label %29
}