#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ canon(char *, char *, int);
scalar_t__ canon_match(char const *, char *);
scalar_t__ crypto_match(char const *, char *);
scalar_t__ direct_match(char const *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ init_accent();
int /*<<< orphan*/ perror(char const *);
scalar_t__ strchr(char const *, char);
int strlen(char *);
int fw_main(const char *pattern, const char *dictfile, int cryptogram,
            void (*callback)(const char *word)) {
  FILE *fp;
  char buf[100];
  char buf2[100];
  int spaces;
  int c;
  init_accent();
  spaces = strchr(pattern, '/') != 0;
  fp = fopen(dictfile, "r");
  if (fp == 0) {
    perror(dictfile);
    return 1;
  }
  while (fgets(buf, sizeof(buf), fp) != NULL) {
    buf[strlen(buf) - 1] = 0;
    if (cryptogram) {
      canon(buf2, buf, 1);
      if (crypto_match(pattern, buf2)) {
        callback(buf);
      }
    } else if (spaces) {
      canon(buf2, buf, 1);
      if (direct_match(pattern, buf2)) {
        callback(buf);
      }
    } else {
      canon(buf2, buf, 0);
      if (canon_match(pattern, buf2)) {
        callback(buf);
      }
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<fw_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    $0x0,%al
call   1080 <init_accent@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x114(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1225 <fw_main+0x75>
mov    -0x18(%rbp),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    135c <fw_main+0x1ac>
jmp    122a <fw_main+0x7a>
lea    -0xa0(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     134c <fw_main+0x19c>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xa0(%rbp,%rax,1)
cmpl   $0x0,-0x1c(%rbp)
je     12b0 <fw_main+0x100>
lea    -0x110(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1090 <canon@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10a0 <crypto_match@plt>
cmp    $0x0,%rax
je     12ab <fw_main+0xfb>
mov    -0x28(%rbp),%rax
lea    -0xa0(%rbp),%rdi
call   *%rax
jmp    1347 <fw_main+0x197>
cmpl   $0x0,-0x114(%rbp)
je     1301 <fw_main+0x151>
lea    -0x110(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1090 <canon@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1060 <direct_match@plt>
cmp    $0x0,%rax
je     12fc <fw_main+0x14c>
mov    -0x28(%rbp),%rax
lea    -0xa0(%rbp),%rdi
call   *%rax
jmp    1342 <fw_main+0x192>
lea    -0x110(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
xor    %edx,%edx
call   1090 <canon@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10d0 <canon_match@plt>
cmp    $0x0,%rax
je     133d <fw_main+0x18d>
mov    -0x28(%rbp),%rax
lea    -0xa0(%rbp),%rdi
call   *%rax
jmp    1342 <fw_main+0x192>
jmp    1347 <fw_main+0x197>
jmp    122a <fw_main+0x7a>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fw_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%r13
xor    %eax,%eax
call   1080 <init_accent@plt>
mov    %r13,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,0x8(%rsp)
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12f7 <fw_main+0x147>
mov    %rax,%rbp
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12db <fw_main+0x12b>
lea    0x10(%rsp),%r15
jmp    1249 <fw_main+0x99>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12db <fw_main+0x12b>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
test   %r12d,%r12d
je     1280 <fw_main+0xd0>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <canon@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   10a0 <crypto_match@plt>
test   %rax,%rax
jne    12d0 <fw_main+0x120>
jmp    1230 <fw_main+0x80>
nop
cmpq   $0x0,0x8(%rsp)
je     12aa <fw_main+0xfa>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <canon@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <direct_match@plt>
test   %rax,%rax
jne    12d0 <fw_main+0x120>
jmp    1230 <fw_main+0x80>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1090 <canon@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   10d0 <canon_match@plt>
test   %rax,%rax
je     1230 <fw_main+0x80>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   *%r14
jmp    1230 <fw_main+0x80>
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   10c0 <perror@plt>
mov    $0x1,%eax
jmp    12e5 <fw_main+0x135>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @fw_main(i8* %0, i8* %1, i32 %2, void (i8*)* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca void (i8*)*
%10 = alloca i32*
%11 = alloca [100 x i8]
%12 = alloca [100 x i8]
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store void (i8*)* %3, void (i8*)** %9
%15 = call i32 (...) @init_accent()
%16 = load i8*, i8** %6
%17 = call i64 @strchr(i8* %16, i8 signext 47)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
store i32 %19, i32* %13
%20 = load i8*, i8** %7
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %10
%22 = load i32*, i32** %10
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %4
%25 = load i8*, i8** %7
%26 = call i32 @perror(i8* %25)
store i32 1, i32* %5
br label %85
27: ; preds = %4
br label %28
28: ; preds = %81, %27
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%30 = load i32*, i32** %10
%31 = call i32* @fgets(i8* %29, i32 100, i32* %30)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %82
33: ; preds = %28
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 %37
store i8 0, i8* %38
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %53
41: ; preds = %33
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%44 = call i32 @canon(i8* %42, i8* %43, i32 1)
%45 = load i8*, i8** %6
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%47 = call i64 @crypto_match(i8* %45, i8* %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %41
%50 = load void (i8*)*, void (i8*)** %9
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
br label %52
52: ; preds = %49, %41
br label %81
53: ; preds = %33
%54 = load i32, i32* %13
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %68
56: ; preds = %53
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%59 = call i32 @canon(i8* %57, i8* %58, i32 1)
%60 = load i8*, i8** %6
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%62 = call i64 @direct_match(i8* %60, i8* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %56
%65 = load void (i8*)*, void (i8*)** %9
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
br label %67
67: ; preds = %64, %56
br label %80
68: ; preds = %53
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%71 = call i32 @canon(i8* %69, i8* %70, i32 0)
%72 = load i8*, i8** %6
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%74 = call i64 @canon_match(i8* %72, i8* %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %68
%77 = load void (i8*)*, void (i8*)** %9
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
br label %79
79: ; preds = %76, %68
br label %80
80: ; preds = %79, %67
br label %81
81: ; preds = %80, %52
br label %28
82: ; preds = %28
%83 = load i32*, i32** %10
%84 = call i32 @fclose(i32* %83)
store i32 0, i32* %5
br label %85
85: ; preds = %82, %24
%86 = load i32, i32* %5
ret i32 %86
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @fw_main(i8* %0, i8* nocapture %1, i32 %2, void (i8*)* nocapture %3) {
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%9 = tail call i32 (...) @init_accent()
%10 = tail call i64 @strchr(i8* %0, i8 signext 47)
%11 = icmp eq i64 %10, 0
%12 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %19, label %14
14: ; preds = %4
%15 = call i32* @fgets(i8* %7, i32 100, i32* %12)
%16 = icmp eq i32* %15, null
br i1 %16, label %43, label %17
17: ; preds = %14
%18 = icmp eq i32 %2, 0
br label %21
19: ; preds = %4
%20 = tail call i32 @perror(i8* %1)
br label %45
21: ; preds = %17, %40
%22 = call i32 @strlen(i8* %7)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %24
store i8 0, i8* %25
br i1 %18, label %30, label %26
26: ; preds = %21
%27 = call i32 @canon(i8* %8, i8* %7, i32 1)
%28 = call i64 @crypto_match(i8* %0, i8* %8)
%29 = icmp eq i64 %28, 0
br i1 %29, label %40, label %39
30: ; preds = %21
br i1 %11, label %35, label %31
31: ; preds = %30
%32 = call i32 @canon(i8* %8, i8* %7, i32 1)
%33 = call i64 @direct_match(i8* %0, i8* %8)
%34 = icmp eq i64 %33, 0
br i1 %34, label %40, label %39
35: ; preds = %30
%36 = call i32 @canon(i8* %8, i8* %7, i32 0)
%37 = call i64 @canon_match(i8* %0, i8* %8)
%38 = icmp eq i64 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %35, %31, %26
br label %40
40: ; preds = %39, %31, %35, %26
%41 = call i32* @fgets(i8* %7, i32 100, i32* %12)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %21
43: ; preds = %40, %14
%44 = call i32 @fclose(i32* %12)
br label %45
45: ; preds = %43, %19
%46 = phi i32 [ 1, %19 ], [ 0, %43 ]
ret i32 %46
}