#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int);
void saveDictionary(char **dictionary, int *countingArray, char *saveFile,
                    int wordCount) {
  FILE *savefp = fopen(saveFile, "w+");
  for (int i = 0; i < wordCount; i++) {
    fprintf(savefp, "%s: %d\n", dictionary[i], countingArray[i]);
  }
}


x86 assembly (clang, -O0):
<saveDictionary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1193 <saveDictionary+0x73>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1152 <saveDictionary+0x32>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveDictionary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec6(%rip),%rsi
mov    %rdx,%rdi
call   1040 <fopen@plt>
test   %ebp,%ebp
jle    117c <saveDictionary+0x5c>
mov    %rax,%r13
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xeaf(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rdx
mov    (%r14,%rbx,4),%ecx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <saveDictionary+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"w+\00"
@.str.1 = [8 x i8] c"%s: %d\0A\00"
define void @saveDictionary(i8** %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i8** %0, i8*** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %7
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
store i32 0, i32* %10
br label %13
13: ; preds = %30, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i32*, i32** %9
%19 = load i8**, i8*** %5
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i32*, i32** %6
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %28)
br label %30
30: ; preds = %17
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
br label %13
33: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"w+\00"
@.str.1 = [8 x i8] c"%s: %d\0A\00"
define void @saveDictionary(i8** nocapture %0, i32* nocapture %1, i8* nocapture %2, i32 %3) {
%5 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = zext i32 %3 to i64
br label %10
9: ; preds = %10, %4
ret void
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %17, %10 ]
%12 = getelementptr inbounds i8*, i8** %0, i64 %11
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i32, i32* %1, i64 %11
%15 = load i32, i32* %14
%16 = tail call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %15)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %9, label %10
}