#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
char **importdict() {
  FILE *ifp;
  int i, wordcount = 0;
  char **array;
  ifp = fopen("dictionary.txt", "r");
  fscanf(ifp, "%d", &wordcount);
  array = (char **)calloc(wordcount, sizeof(char *));
  for (i = 0; i < wordcount; i++)
    array[i] = (char *)calloc(20, sizeof(char));
  for (i = 0; i < wordcount; i++)
    fscanf(ifp, "%s", array[i]);
  fclose(ifp);
  return array;
}


x86 assembly (clang, -O0):
<importdict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea0(%rip),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cc <importdict+0x8c>
mov    $0x14,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <importdict+0x54>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    120b <importdict+0xcb>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d3 <importdict+0x93>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<importdict>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea9(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xea4(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x4(%rsp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
cmpl   $0x0,0x4(%rsp)
jle    11ef <importdict+0xaf>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x14,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11a0 <importdict+0x60>
test   %eax,%eax
jle    11ef <importdict+0xaf>
lea    0xe48(%rip),%r15
xor    %ebx,%ebx
xchg   %ax,%ax
mov    (%r12,%rbx,8),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <importdict+0x90>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"dictionary.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
define i8** @importdict() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8**
store i32 0, i32* %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i8**
store i8** %10, i8*** %4
store i32 0, i32* %2
br label %11
11: ; preds = %22, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = call i64 @calloc(i32 20, i32 1)
%17 = inttoptr i64 %16 to i8*
%18 = load i8**, i8*** %4
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
store i8* %17, i8** %21
br label %22
22: ; preds = %15
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %11
25: ; preds = %11
store i32 0, i32* %2
br label %26
26: ; preds = %38, %25
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %41
30: ; preds = %26
%31 = load i32*, i32** %1
%32 = load i8**, i8*** %4
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %30
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %26
41: ; preds = %26
%42 = load i32*, i32** %1
%43 = call i32 @fclose(i32* %42)
%44 = load i8**, i8*** %4
ret i8** %44
}

LLVM IR (-O2):
@.str = [15 x i8] c"dictionary.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
define i8** @importdict() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i64 @calloc(i32 %5, i32 8)
%7 = inttoptr i64 %6 to i8**
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %12, label %30
10: ; preds = %12
%11 = icmp sgt i32 %18, 0
br i1 %11, label %21, label %30
12: ; preds = %0, %12
%13 = phi i64 [ %17, %12 ], [ 0, %0 ]
%14 = call i64 @calloc(i32 20, i32 1)
%15 = inttoptr i64 %14 to i8*
%16 = getelementptr inbounds i8*, i8** %7, i64 %13
store i8* %15, i8** %16
%17 = add nuw nsw i64 %13, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %12, label %10
21: ; preds = %10, %21
%22 = phi i64 [ %26, %21 ], [ 0, %10 ]
%23 = getelementptr inbounds i8*, i8** %7, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = add nuw nsw i64 %22, 1
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %21, label %30
30: ; preds = %21, %0, %10
%31 = call i32 @fclose(i32* %3)
ret i8** %7
}