#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 *);
char **importdict();
int /*<<< orphan*/ permuteString(int /*<<< orphan*/ *, char **, char *, char *,
                                 int /*<<< orphan*/, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int tolower(char);
char toupper(char);
int main() {
  FILE *ofp;
  char **dictionary;
  char choice, entry[20], copyentry[20];
  int i, flag = 0, *flagpointer;
  flagpointer = &flag;
  printf("Welcome to the Jumble Puzzle Solver!\n");
  ofp = fopen("jumbleout.txt", "w");
  dictionary = importdict();
  while (1) {
    printf("Would you like to enter a jumbled word?\n");
    scanf(" %c", &choice);
    switch (tolower(choice)) {
    case 'n':
      fclose(ofp);
      return 0;
    case 'y':
      printf("What word would you like scored?\n");
      scanf("%s", entry);
      for (i = 0; i < strlen(entry); i++)
        entry[i] = toupper(entry[i]);
      strcpy(copyentry, entry);
      permuteString(ofp, dictionary, entry, copyentry, 0, flagpointer);
      if (*flagpointer == 0) {
        printf("Sorry, no permutations of %s form a word.\n", entry);
        fprintf(ofp, "Sorry, no permutations of %s form a word.\n", entry);
      }
      *flagpointer = 0;
      continue;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x58(%rbp)
lea    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe43(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <importdict@plt>
mov    %rax,-0x18(%rbp)
lea    0xe31(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0x19(%rbp),%rsi
call   10c0 <scanf@plt>
movsbl -0x19(%rbp),%edi
call   10a0 <tolower@plt>
mov    %eax,%ecx
mov    %ecx,-0x64(%rbp)
sub    $0x6e,%eax
je     1249 <main+0x99>
jmp    1238 <main+0x88>
mov    -0x64(%rbp),%eax
sub    $0x79,%eax
je     125a <main+0xaa>
jmp    132c <main+0x17c>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe12(%rip),%rdi
call   10c0 <scanf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    12c1 <main+0x111>
movslq -0x54(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1040 <toupper@plt>
mov    %al,%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    127f <main+0xcf>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x50(%rbp),%rcx
mov    -0x60(%rbp),%r9
xor    %r8d,%r8d
call   1090 <permuteString@plt>
mov    -0x60(%rbp),%rax
cmpl   $0x0,(%rax)
jne    131d <main+0x16d>
lea    -0x30(%rbp),%rsi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xd70(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x60(%rbp),%rax
movl   $0x0,(%rax)
jmp    11fe <main+0x4e>
jmp    11fe <main+0x4e>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe65(%rip),%rdi
call   1050 <puts@plt>
lea    0xe17(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   10c0 <importdict@plt>
mov    %rax,0x18(%rsp)
lea    0xe5a(%rip),%r12
lea    0xdfc(%rip),%r13
lea    0xb(%rsp),%r14
lea    0x20(%rsp),%rbp
jmp    1229 <main+0x69>
cmp    $0x6e,%eax
je     1308 <main+0x148>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   10d0 <scanf@plt>
movsbl 0xb(%rsp),%edi
call   10b0 <tolower@plt>
cmp    $0x79,%eax
jne    1220 <main+0x60>
lea    0xe3d(%rip),%rdi
call   1050 <puts@plt>
lea    0xdb6(%rip),%rdi
mov    %rbp,%rsi
call   10d0 <scanf@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    12a3 <main+0xe3>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x20(%rsp,%r15,1),%edi
call   1040 <toupper@plt>
mov    %al,0x20(%rsp,%r15,1)
add    $0x1,%r15
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%r15
jl     1280 <main+0xc0>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
lea    0xc(%rsp),%r9
call   10a0 <permuteString@plt>
cmpl   $0x0,0xc(%rsp)
jne    12fb <main+0x13b>
lea    0xd39(%rip),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1090 <fprintf@plt>
movl   $0x0,0xc(%rsp)
jmp    1229 <main+0x69>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Welcome to the Jumble Puzzle Solver!\0A\00"
@.str.1 = [14 x i8] c"jumbleout.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [41 x i8] c"Would you like to enter a jumbled word?\0A\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [34 x i8] c"What word would you like scored?\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [43 x i8] c"Sorry, no permutations of %s form a word.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8**
%4 = alloca i8
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %8
store i32* %8, i32** %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %11, i32** %2
%12 = call i8** (...) @importdict()
store i8** %12, i8*** %3
br label %13
13: ; preds = %0, %61, %63
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%16 = load i8, i8* %4
%17 = call i32 @tolower(i8 signext %16)
switch i32 %17, label %63 [
i32 110, label %18
i32 121, label %21
]
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = call i32 @fclose(i32* %19)
ret i32 0
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %23)
store i32 0, i32* %7
br label %25
25: ; preds = %39, %21
%26 = load i32, i32* %7
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %42
30: ; preds = %25
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call signext i8 @toupper(i8 signext %34)
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %30
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %25
42: ; preds = %25
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%45 = call i32 @strcpy(i8* %43, i8* %44)
%46 = load i32*, i32** %2
%47 = load i8**, i8*** %3
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%50 = load i32*, i32** %9
%51 = call i32 @permuteString(i32* %46, i8** %47, i8* %48, i8* %49, i32 0, i32* %50)
%52 = load i32*, i32** %9
%53 = load i32, i32* %52
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %42
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = load i32*, i32** %2
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%60 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %55, %42
%62 = load i32*, i32** %9
store i32 0, i32* %62
br label %13
63: ; preds = %13
br label %13
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"jumbleout.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [43 x i8] c"Sorry, no permutations of %s form a word.\0A\00"
@str = [37 x i8] c"Welcome to the Jumble Puzzle Solver!\00"
@str.8 = [40 x i8] c"Would you like to enter a jumbled word?\00"
@str.9 = [33 x i8] c"What word would you like scored?\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i8** (...) @importdict()
br label %11
11: ; preds = %41, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%14 = load i8, i8* %1
%15 = call i32 @tolower(i8 signext %14)
switch i32 %15, label %41 [
i32 110, label %16
i32 121, label %18
]
16: ; preds = %11
%17 = call i32 @fclose(i32* %9)
ret i32 0
18: ; preds = %11
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%21 = call i32 @strlen(i8* %5)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18, %23
%24 = phi i64 [ %28, %23 ], [ 0, %18 ]
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call signext i8 @toupper(i8 signext %26)
store i8 %27, i8* %25
%28 = add nuw nsw i64 %24, 1
%29 = call i32 @strlen(i8* %5)
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %18
%33 = call i32 @strcpy(i8* %6, i8* %5)
%34 = call i32 @permuteString(i32* %9, i8** %10, i8* %5, i8* %6, i32 0, i32* %4)
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%39 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i8* %5)
br label %40
40: ; preds = %37, %32
store i32 0, i32* %4
br label %41
41: ; preds = %40, %11
br label %11
}