#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 boggle(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ makemap(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char line[256];
  char letters[256];
  char name[40];
  FILE *file;
  int i;
  printf("Boggle square size is %d lines of %d characters\n", 4, 4);
  strcpy(letters, "");
  for (i = 0; i < 4; i++) {
    printf("Enter line %d :", i + 1);
    gets(line);
    if (strlen(line) != 4) {
      fprintf(stderr, "Wrong length of line\n");
      exit(1);
    }
    strcat(letters, line);
  }
  makemap(letters);
  for (i = 2; i <= 18; i++) {
    sprintf(name, "<Data>.Words%d", i);
    file = fopen(name, "r");
    if (file == NULL) {
      fprintf(stderr, "Could not open %s\n", name);
      exit(1);
    }
    for (; fgets(line, 256, file);) {
      if (boggle(line, (-1), 0) == 2) {
        printf("-- %s", line);
      }
    }
    fclose(file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe17(%rip),%rdi
mov    $0x4,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x24c(%rbp)
cmpl   $0x4,-0x24c(%rbp)
jge    12a1 <main+0xd1>
mov    -0x24c(%rbp),%esi
add    $0x1,%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
call   10a0 <gets@plt>
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
je     127a <main+0xaa>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x24c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24c(%rbp)
jmp    1214 <main+0x44>
lea    -0x210(%rbp),%rdi
call   10f0 <makemap@plt>
movl   $0x2,-0x24c(%rbp)
cmpl   $0x12,-0x24c(%rbp)
jg     13aa <main+0x1da>
lea    -0x240(%rbp),%rdi
mov    -0x24c(%rbp),%edx
lea    0xd7f(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x240(%rbp),%rdi
lea    0xd7b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    132d <main+0x15d>
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
lea    -0x240(%rbp),%rdx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    1332 <main+0x162>
lea    -0x110(%rbp),%rdi
mov    -0x248(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     138a <main+0x1ba>
lea    -0x110(%rbp),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <boggle@plt>
cmp    $0x2,%eax
jne    1385 <main+0x1b5>
lea    -0x110(%rbp),%rsi
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1332 <main+0x162>
mov    -0x248(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24c(%rbp)
jmp    12b7 <main+0xe7>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
lea    0xe18(%rip),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe56(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe20(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x130(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    13f0 <main+0x220>
lea    0x30(%rsp),%rdi
lea    0x130(%rsp),%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xdd7(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    13f0 <main+0x220>
lea    0x30(%rsp),%rdi
lea    0x130(%rsp),%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xd96(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    13f0 <main+0x220>
lea    0x30(%rsp),%rdi
lea    0x130(%rsp),%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xd55(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    13f0 <main+0x220>
lea    0x30(%rsp),%rbp
lea    0x130(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
mov    %rbp,%rdi
call   10f0 <makemap@plt>
mov    $0x2,%ebp
mov    %rsp,%r15
lea    0xd36(%rip),%r12
lea    0xd44(%rip),%r13
jmp    1350 <main+0x180>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x1,%ebp
cmp    $0x13,%ebp
je     13b8 <main+0x1e8>
mov    %r15,%rdi
lea    0xcfd(%rip),%rsi
mov    %ebp,%edx
call   10d0 <sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13cc <main+0x1fc>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1340 <main+0x170>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <boggle@plt>
cmp    $0x2,%eax
jne    1380 <main+0x1b0>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1380 <main+0x1b0>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
lea    0xc8c(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
lea    0xc41(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"Boggle square size is %d lines of %d characters\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [16 x i8] c"Enter line %d :\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Wrong length of line\0A\00"
@.str.4 = [15 x i8] c"<Data>.Words%d\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [19 x i8] c"Could not open %s\0A\00"
@.str.7 = [6 x i8] c"-- %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca [40 x i8]
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 4, i32 4)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %10
10: ; preds = %30, %0
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%18 = call i32 @gets(i8* %17)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp ne i32 %20, 4
br i1 %21, label %22, label %26
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %13
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
br label %30
30: ; preds = %26
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %10
33: ; preds = %10
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%35 = call i32 @makemap(i8* %34)
store i32 2, i32* %6
br label %36
36: ; preds = %69, %33
%37 = load i32, i32* %6
%38 = icmp sle i32 %37, 18
br i1 %38, label %39, label %72
39: ; preds = %36
%40 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%41 = load i32, i32* %6
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %44, i32** %5
%45 = load i32*, i32** %5
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %52
47: ; preds = %39
%48 = load i32, i32* @stderr
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %39
br label %53
53: ; preds = %65, %52
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%55 = load i32*, i32** %5
%56 = call i64 @fgets(i8* %54, i32 256, i32* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %66
58: ; preds = %53
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%60 = call i32 @boggle(i8* %59, i32 -1, i32 0)
%61 = icmp eq i32 %60, 2
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %62, %58
br label %53
66: ; preds = %53
%67 = load i32*, i32** %5
%68 = call i32 @fclose(i32* %67)
br label %69
69: ; preds = %66
%70 = load i32, i32* %6
%71 = add nsw i32 %70, 1
store i32 %71, i32* %6
br label %36
72: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"Boggle square size is %d lines of %d characters\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [16 x i8] c"Enter line %d :\00"
@stderr = global i32 0
@.str.3 = [22 x i8] c"Wrong length of line\0A\00"
@.str.4 = [15 x i8] c"<Data>.Words%d\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [19 x i8] c"Could not open %s\0A\00"
@.str.7 = [6 x i8] c"-- %s\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 4, i32 4)
%8 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 1)
%10 = call i32 @gets(i8* %4)
%11 = call i32 @strlen(i8* %4)
%12 = icmp eq i32 %11, 4
br i1 %12, label %17, label %13
13: ; preds = %29, %23, %17, %0
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %0
%18 = call i32 @strcat(i8* %5, i8* %4)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 2)
%20 = call i32 @gets(i8* %4)
%21 = call i32 @strlen(i8* %4)
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %13
23: ; preds = %17
%24 = call i32 @strcat(i8* %5, i8* %4)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 3)
%26 = call i32 @gets(i8* %4)
%27 = call i32 @strlen(i8* %4)
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %13
29: ; preds = %23
%30 = call i32 @strcat(i8* %5, i8* %4)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 4)
%32 = call i32 @gets(i8* %4)
%33 = call i32 @strlen(i8* %4)
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %13
35: ; preds = %29
%36 = call i32 @strcat(i8* %5, i8* %4)
%37 = call i32 @makemap(i8* %5)
br label %38
38: ; preds = %35, %58
%39 = phi i32 [ 2, %35 ], [ %60, %58 ]
%40 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = call i64 @fgets(i8* %4, i32 256, i32* %41)
%45 = icmp eq i64 %44, 0
br i1 %45, label %58, label %50
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %43, %55
%51 = call i32 @boggle(i8* %4, i32 -1, i32 0)
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %55
55: ; preds = %53, %50
%56 = call i64 @fgets(i8* %4, i32 256, i32* %41)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %50
58: ; preds = %55, %43
%59 = call i32 @fclose(i32* %41)
%60 = add nuw nsw i32 %39, 1
%61 = icmp eq i32 %60, 19
br i1 %61, label %62, label %38
62: ; preds = %58
ret i32 0
}