#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__ checkdict(int /*<<< orphan*/ *, char **, char *, char const *);
int strlen(char *);
int /*<<< orphan*/ swap(char *, int, int);
int permuteString(FILE *ofp, char **dictionary, char permute[],
                  const char *submission, int permuteStart, int *flag) {
  int i;
  if (permuteStart == strlen(permute)) {
    if (checkdict(ofp, dictionary, permute, submission))
      *flag = 1;
  } else {
    for (i = permuteStart; i < strlen(permute); i++) {
      swap(permute, permuteStart, i);
      permuteString(ofp, dictionary, permute, submission, permuteStart + 1,
                    flag);
      swap(permute, i, permuteStart);
    }
  }
  if (*flag == 1) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<permuteString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jne    11aa <permuteString+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <checkdict@plt>
cmp    $0x0,%rax
je     11a5 <permuteString+0x65>
mov    -0x38(%rbp),%rax
movl   $0x1,(%rax)
jmp    121e <permuteString+0xde>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    1219 <permuteString+0xd9>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   1060 <swap@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x38(%rbp),%r9
call   1050 <permuteString@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1060 <swap@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b0 <permuteString+0x70>
jmp    121e <permuteString+0xde>
mov    -0x38(%rbp),%rax
cmpl   $0x1,(%rax)
jne    1237 <permuteString+0xf7>
movl   $0x1,-0x4(%rbp)
jmp    123e <permuteString+0xfe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permuteString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %r8d,%r13d
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rdx,%rdi
call   1040 <strlen@plt>
cmp    %r13d,%eax
jne    118d <permuteString+0x4d>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <checkdict@plt>
test   %rax,%rax
je     11f8 <permuteString+0xb8>
movl   $0x1,(%r12)
jmp    11f8 <permuteString+0xb8>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %r13d,%eax
mov    %r14,0x10(%rsp)
mov    %r15,0x8(%rsp)
jle    11f8 <permuteString+0xb8>
lea    0x1(%r13),%r14d
mov    %r13d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1060 <swap@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
mov    %rbx,%rdx
mov    0x10(%rsp),%rcx
mov    %r14d,%r8d
mov    %r12,%r9
call   1050 <permuteString@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
call   1060 <swap@plt>
add    $0x1,%r15d
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r15d
jl     11b0 <permuteString+0x70>
xor    %eax,%eax
cmpl   $0x1,(%r12)
sete   %al
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @permuteString(i32* %0, i8** %1, i8* %2, i8* %3, i32 %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
store i32* %0, i32** %8
store i8** %1, i8*** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32* %5, i32** %13
%15 = load i32, i32* %12
%16 = load i8*, i8** %10
%17 = call i32 @strlen(i8* %16)
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %6
%20 = load i32*, i32** %8
%21 = load i8**, i8*** %9
%22 = load i8*, i8** %10
%23 = load i8*, i8** %11
%24 = call i64 @checkdict(i32* %20, i8** %21, i8* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i32*, i32** %13
store i32 1, i32* %27
br label %28
28: ; preds = %26, %19
br label %57
29: ; preds = %6
%30 = load i32, i32* %12
store i32 %30, i32* %14
br label %31
31: ; preds = %53, %29
%32 = load i32, i32* %14
%33 = load i8*, i8** %10
%34 = call i32 @strlen(i8* %33)
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %56
36: ; preds = %31
%37 = load i8*, i8** %10
%38 = load i32, i32* %12
%39 = load i32, i32* %14
%40 = call i32 @swap(i8* %37, i32 %38, i32 %39)
%41 = load i32*, i32** %8
%42 = load i8**, i8*** %9
%43 = load i8*, i8** %10
%44 = load i8*, i8** %11
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
%47 = load i32*, i32** %13
%48 = call i32 @permuteString(i32* %41, i8** %42, i8* %43, i8* %44, i32 %46, i32* %47)
%49 = load i8*, i8** %10
%50 = load i32, i32* %14
%51 = load i32, i32* %12
%52 = call i32 @swap(i8* %49, i32 %50, i32 %51)
br label %53
53: ; preds = %36
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 1
store i32 %55, i32* %14
br label %31
56: ; preds = %31
br label %57
57: ; preds = %56, %28
%58 = load i32*, i32** %13
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %62
61: ; preds = %57
store i32 1, i32* %7
br label %63
62: ; preds = %57
store i32 0, i32* %7
br label %63
63: ; preds = %62, %61
%64 = load i32, i32* %7
ret i32 %64
}

LLVM IR (-O2):
define i32 @permuteString(i32* %0, i8** %1, i8* %2, i8* %3, i32 %4, i32* nocapture %5) {
%7 = tail call i32 @strlen(i8* %2)
%8 = icmp eq i32 %7, %4
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %2)
%11 = icmp sgt i32 %10, %4
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = add nsw i32 %4, 1
br label %18
14: ; preds = %6
%15 = tail call i64 @checkdict(i32* %0, i8** %1, i8* %2, i8* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %14
store i32 1, i32* %5
br label %26
18: ; preds = %12, %18
%19 = phi i32 [ %4, %12 ], [ %23, %18 ]
%20 = tail call i32 @swap(i8* %2, i32 %4, i32 %19)
%21 = tail call i32 @permuteString(i32* %0, i8** %1, i8* %2, i8* %3, i32 %13, i32* %5)
%22 = tail call i32 @swap(i8* %2, i32 %19, i32 %4)
%23 = add nsw i32 %19, 1
%24 = tail call i32 @strlen(i8* %2)
%25 = icmp slt i32 %23, %24
br i1 %25, label %18, label %26
26: ; preds = %18, %9, %14, %17
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 1
%29 = zext i1 %28 to i32
ret i32 %29
}