#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
char *savingComparison(int *, char ***, int *, int *);
int saveDictionary(char *outFileName, char ****array, int *count,
                   int *capacity) {
  FILE *outFile;
  int i;
  char *current;
  outFile = fopen(outFileName, "w");
  if (outFile == NULL) {
    printf("I couldn't open results.dat for writing.\n");
    return -1;
  }
  int track[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  int size = 0;
  for (i = 0; i < 8; i++) {
    if (count[i] != 0) {
      size++;
    }
  }
  while (size > 0) {
    current = savingComparison(track, *array, &size, count);
    fprintf(outFile, "%s\n", current);
  }
  fclose(outFile);
  return 0;
}


x86 assembly (clang, -O0):
<saveDictionary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11af <saveDictionary+0x4f>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1259 <saveDictionary+0xf9>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    1205 <saveDictionary+0xa5>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11f2 <saveDictionary+0x92>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11f7 <saveDictionary+0x97>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cd <saveDictionary+0x6d>
jmp    120a <saveDictionary+0xaa>
cmpl   $0x0,-0x64(%rbp)
jle    1249 <saveDictionary+0xe9>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x64(%rbp),%rdx
call   1060 <savingComparison@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xded(%rip),%rsi
call   1070 <fprintf@plt>
jmp    120a <saveDictionary+0xaa>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveDictionary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1232 <saveDictionary+0xe2>
mov    %rax,%r12
pxor   %xmm1,%xmm1
movdqa %xmm1,0x20(%rsp)
movdqa %xmm1,0x10(%rsp)
movdqu (%r15),%xmm0
movdqu 0x10(%r15),%xmm2
pcmpeqd %xmm1,%xmm2
pcmpeqd %xmm3,%xmm3
pxor   %xmm3,%xmm2
pcmpeqd %xmm1,%xmm0
pxor   %xmm3,%xmm0
packssdw %xmm2,%xmm0
pmovmskb %xmm0,%eax
packsswb %xmm0,%xmm0
pmovmskb %xmm0,%ecx
mov    %ecx,%edx
shr    %dl
and    $0x55,%dl
sub    %dl,%cl
mov    %ecx,%edx
and    $0x33,%dl
shr    $0x2,%cl
and    $0x33,%cl
add    %dl,%cl
mov    %ecx,%edx
shr    $0x4,%dl
add    %cl,%dl
and    $0xf,%dl
movzbl %dl,%ecx
mov    %ecx,0xc(%rsp)
test   %eax,%eax
je     1226 <saveDictionary+0xd6>
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0xe0b(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    (%r14),%rsi
mov    %r13,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1050 <savingComparison@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
cmpl   $0x0,0xc(%rsp)
jg     1200 <saveDictionary+0xb0>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1243 <saveDictionary+0xf3>
lea    0xdcd(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [42 x i8] c"I couldn't open results.dat for writing.\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @saveDictionary(i8* %0, i8**** %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8****
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [8 x i32]
%14 = alloca i32
store i8* %0, i8** %6
store i8**** %1, i8***** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%15 = load i8*, i8** %6
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %10
%17 = load i32*, i32** %10
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %56
21: ; preds = %4
%22 = bitcast [8 x i32]* %13 to i8*
store i32 0, i32* %14
store i32 0, i32* %11
br label %23
23: ; preds = %37, %21
%24 = load i32, i32* %11
%25 = icmp slt i32 %24, 8
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i32*, i32** %8
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32, i32* %14
%35 = add nsw i32 %34, 1
store i32 %35, i32* %14
br label %36
36: ; preds = %33, %26
br label %37
37: ; preds = %36
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %23
40: ; preds = %23
br label %41
41: ; preds = %44, %40
%42 = load i32, i32* %14
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 0
%46 = load i8****, i8***** %7
%47 = load i8***, i8**** %46
%48 = load i32*, i32** %8
%49 = call i8* @savingComparison(i32* %45, i8*** %47, i32* %14, i32* %48)
store i8* %49, i8** %12
%50 = load i32*, i32** %10
%51 = load i8*, i8** %12
%52 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %51)
br label %41
53: ; preds = %41
%54 = load i32*, i32** %10
%55 = call i32 @fclose(i32* %54)
store i32 0, i32* %5
br label %56
56: ; preds = %53, %19
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@str = [41 x i8] c"I couldn't open results.dat for writing.\00"
define i32 @saveDictionary(i8* nocapture %0, i8**** nocapture %1, i32* %2, i32* nocapture readnone %3) {
%5 = alloca [8 x i32]
%6 = alloca i32
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %31
11: ; preds = %4
%12 = bitcast [8 x i32]* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %2 to <8 x i32>*
%15 = load <8 x i32>, <8 x i32>* %14
%16 = icmp ne <8 x i32> %15, zeroinitializer
%17 = bitcast <8 x i1> %16 to i8
%18 = call i8 @llvm.ctpop.i8(i8 %17)
%19 = zext i8 %18 to i32
store i32 %19, i32* %6
%20 = icmp eq i8 %17, 0
br i1 %20, label %29, label %21
21: ; preds = %11
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
br label %23
23: ; preds = %21, %23
%24 = load i8***, i8**** %1
%25 = call i8* @savingComparison(i32* %22, i8*** %24, i32* %6, i32* %2)
%26 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
br i1 %28, label %23, label %29
29: ; preds = %23, %11
%30 = call i32 @fclose(i32* %7)
br label %31
31: ; preds = %29, %9
%32 = phi i32 [ -1, %9 ], [ 0, %29 ]
ret i32 %32
}