#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*/ create_dic(int /*<<< orphan*/ *, int /*<<< orphan*/, char *,
                              char *, int, long);
int /*<<< orphan*/ end(int);
int /*<<< orphan*/ errPointer(int);
int /*<<< orphan*/ explication();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, char *);
char *malloc(int);
int /*<<< orphan*/ *manage_file();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
long totDic(char *);
void wl_dictionary() {
  FILE *fp = NULL;
  char str[50], *sol = NULL;
  long int tot = 0;
  explication();
  fflush(stdin);
  fprintf(stdout, "Insert string to modify for dictionary attack: ");
  fscanf(stdin, "%49s", str);
  fp = manage_file();
  tot = totDic(str);
  sol = malloc((strlen(str) + 1) * sizeof(char));
  strcpy(sol, str);
  if (sol == NULL)
    errPointer(-24);
  create_dic(fp, 0, str, sol, strlen(str), tot);
  end(strlen(str));
  fclose(fp);
  free(sol);
}


x86 assembly (clang, -O0):
<wl_dictionary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    $0x0,%al
call   1060 <explication@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xdf2(%rip),%rsi
call   10a0 <fscanf@plt>
mov    $0x0,%al
call   1040 <manage_file@plt>
mov    %rax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
call   10d0 <totDic@plt>
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1090 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcpy@plt>
cmpq   $0x0,-0x48(%rbp)
jne    129a <wl_dictionary+0xba>
mov    $0xffffffe8,%edi
call   1100 <errPointer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    %eax,%r8d
mov    -0x50(%rbp),%r9
xor    %esi,%esi
call   1070 <create_dic@plt>
lea    -0x40(%rbp),%rdi
call   1090 <strlen@plt>
mov    %eax,%edi
call   10b0 <end@plt>
mov    -0x8(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wl_dictionary>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1060 <explication@plt>
mov    0x2def(%rip),%rbx
mov    (%rbx),%edi
call   10f0 <fflush@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%rip),%rsi
call   10c0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe12(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdx
call   10a0 <fscanf@plt>
xor    %eax,%eax
call   1040 <manage_file@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   10d0 <totDic@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1090 <strlen@plt>
lea    0x1(%rax),%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
test   %rbx,%rbx
jne    126b <wl_dictionary+0x8b>
mov    $0xffffffe8,%edi
call   1100 <errPointer@plt>
mov    %rsp,%r12
mov    %r12,%rdi
call   1090 <strlen@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
mov    %r15,%r9
call   1070 <create_dic@plt>
mov    %r12,%rdi
call   1090 <strlen@plt>
mov    %eax,%edi
call   10b0 <end@plt>
mov    %r14,%rdi
call   1080 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [48 x i8] c"Insert string to modify for dictionary attack: \00"
@.str.1 = [5 x i8] c"%49s\00"
define void @wl_dictionary() {
%1 = alloca i32*
%2 = alloca [50 x i8]
%3 = alloca i8*
%4 = alloca i64
store i32* null, i32** %1
store i8* null, i8** %3
store i64 0, i64* %4
%5 = call i32 (...) @explication()
%6 = load i32, i32* @stdin
%7 = call i32 @fflush(i32 %6)
%8 = load i32, i32* @stdout
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @fscanf(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32* (...) @manage_file()
store i32* %13, i32** %1
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%15 = call i64 @totDic(i8* %14)
store i64 %15, i64* %4
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %3
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 @errPointer(i32 -24)
br label %30
30: ; preds = %28, %0
%31 = load i32*, i32** %1
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%33 = load i8*, i8** %3
%34 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = load i64, i64* %4
%37 = call i32 @create_dic(i32* %31, i32 0, i8* %32, i8* %33, i32 %35, i64 %36)
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = call i32 @end(i32 %39)
%41 = load i32*, i32** %1
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [48 x i8] c"Insert string to modify for dictionary attack: \00"
@.str.1 = [5 x i8] c"%49s\00"
define void @wl_dictionary() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @explication()
%4 = load i32, i32* @stdin
%5 = tail call i32 @fflush(i32 %4)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fscanf(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = call i32* (...) @manage_file()
%11 = call i64 @totDic(i8* %2)
%12 = call i32 @strlen(i8* %2)
%13 = add nsw i32 %12, 1
%14 = call i8* @malloc(i32 %13)
%15 = call i32 @strcpy(i8* %14, i8* %2)
%16 = icmp eq i8* %14, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @errPointer(i32 -24)
br label %19
19: ; preds = %17, %0
%20 = call i32 @strlen(i8* %2)
%21 = call i32 @create_dic(i32* %10, i32 0, i8* %2, i8* %14, i32 %20, i64 %11)
%22 = call i32 @strlen(i8* %2)
%23 = call i32 @end(i32 %22)
%24 = call i32 @fclose(i32* %10)
%25 = call i32 @free(i8* %14)
ret void
}