#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*/ 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);
  file = fopen("apet", "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    0xe27(%rip),%rdi
mov    $0x4,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x24c(%rbp)
cmpl   $0x4,-0x24c(%rbp)
jge    1291 <main+0xd1>
mov    -0x24c(%rbp),%esi
add    $0x1,%esi
lea    0xe10(%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     126a <main+0xaa>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <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    1204 <main+0x44>
lea    -0x210(%rbp),%rdi
call   10e0 <makemap@plt>
lea    0xdb3(%rip),%rdi
lea    0xdb1(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
jne    12ed <main+0x12d>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    -0x240(%rbp),%rdx
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    12f2 <main+0x132>
lea    -0x110(%rbp),%rdi
mov    -0x248(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     134a <main+0x18a>
lea    -0x110(%rbp),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <boggle@plt>
cmp    $0x2,%eax
je     1345 <main+0x185>
lea    -0x110(%rbp),%rsi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12f2 <main+0x132>
mov    -0x248(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x230,%rsp
lea    0xe2d(%rip),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe6b(%rip),%rsi
lea    0x130(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe32(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    138f <main+0x1cf>
lea    0x130(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xdf0(%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    138f <main+0x1cf>
lea    0x130(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xdb1(%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    138f <main+0x1cf>
lea    0x130(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xd72(%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    138f <main+0x1cf>
lea    0x130(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   10c0 <strcat@plt>
mov    %rbx,%rdi
call   10e0 <makemap@plt>
lea    0xd51(%rip),%rdi
lea    0xd4f(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13b0 <main+0x1f0>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1378 <main+0x1b8>
mov    %rsp,%rbx
lea    0xd34(%rip),%r15
jmp    1355 <main+0x195>
nop
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1378 <main+0x1b8>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
call   1070 <boggle@plt>
cmp    $0x2,%eax
je     1340 <main+0x180>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1340 <main+0x180>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
lea    0xc9e(%rip),%rsi
lea    0x100(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <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 = [5 x i8] c"apet\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)
%36 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %36, i32** %5
%37 = load i32*, i32** %5
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %33
br label %45
45: ; preds = %57, %44
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%47 = load i32*, i32** %5
%48 = call i64 @fgets(i8* %46, i32 256, i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %45
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%52 = call i32 @boggle(i8* %51, i32 -1, i32 0)
%53 = icmp ne i32 %52, 2
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %55)
br label %57
57: ; preds = %54, %50
br label %45
58: ; preds = %45
%59 = load i32*, i32** %5
%60 = call i32 @fclose(i32* %59)
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 = [5 x i8] c"apet\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)
%38 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %35
%41 = call i64 @fgets(i8* %4, i32 256, i32* %38)
%42 = icmp eq i64 %41, 0
br i1 %42, label %55, label %47
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %40, %52
%48 = call i32 @boggle(i8* %4, i32 -1, i32 0)
%49 = icmp eq i32 %48, 2
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = 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 %52
52: ; preds = %50, %47
%53 = call i64 @fgets(i8* %4, i32 256, i32* %38)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %47
55: ; preds = %52, %40
%56 = call i32 @fclose(i32* %38)
ret i32 0
}