#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 int32_t;

/* Variables and functions */
char *malloc(int);
int optima_comparison_full(char *, char *, int, int);
int /*<<< orphan*/ optima_fopen(char *, int, char *);
int /*<<< orphan*/ optima_fwrite(char *, int, char *);
int /*<<< orphan*/ optima_normal(char *);
int /*<<< orphan*/ optima_strip(char *, char *, char *, char *, int, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
main_x() {
  char *optima_in = malloc(0x100000);
  char *optima_tmpA = malloc(0x100000);
  char *optima_tmpB = malloc(0x100000);
  optima_tmpA[0] = '\0';
  optima_tmpB[0] = '\0';
  optima_fopen(optima_in, 0x100000, "wire2.ask");
  optima_normal(optima_in);
  char *seekA = optima_in;
  char *seekB = optima_in;
  int j;
  for (j = 0; j < 1; j++) {
    int32_t window;
    for (window = 16; window >= 8; window--) {
      int32_t index = 0;
      while (1) {
        int32_t match = optima_comparison_full(seekA, seekB, index, window);
        if (match == -1)
          break;
        if (match >= 2) {
          optima_tmpA[0] = '\0';
          optima_strip(optima_tmpA, optima_tmpB, seekA, seekB, index, window);
          strcpy(optima_in, optima_tmpA);
        }
        index++;
      }
      optima_normal(optima_in);
    }
    strcpy(optima_in, optima_tmpA);
    strcat(optima_in, optima_tmpB);
    optima_fwrite(optima_in, 0x100000, "wire2x.ask");
  }
}


x86 assembly (clang, -O0):
<main_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x100000,%esi
lea    0xe30(%rip),%rdx
call   1070 <optima_fopen@plt>
mov    -0x10(%rbp),%rdi
call   1080 <optima_normal@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jge    12d9 <main_x+0x159>
movl   $0x10,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jl     129c <main_x+0x11c>
movl   $0x0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
call   1040 <optima_comparison_full@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
jne    123c <main_x+0xbc>
jmp    1285 <main_x+0x105>
cmpl   $0x2,-0x40(%rbp)
jl     1277 <main_x+0xf7>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x3c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
call   1050 <optima_strip@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1217 <main_x+0x97>
mov    -0x10(%rbp),%rdi
call   1080 <optima_normal@plt>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    1206 <main_x+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    $0x100000,%esi
lea    0xd44(%rip),%rdx
call   10a0 <optima_fwrite@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f5 <main_x+0x75>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_x>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
movb   $0x0,(%r14)
movb   $0x0,(%rax)
lea    0xe43(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100000,%esi
call   1070 <optima_fopen@plt>
mov    %rbx,%rdi
call   1080 <optima_normal@plt>
mov    $0x10,%r12d
jmp    11f6 <main_x+0x76>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <optima_normal@plt>
lea    -0x1(%r12),%eax
cmp    $0x8,%r12d
mov    %eax,%r12d
jbe    1255 <main_x+0xd5>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %r12d,%ecx
call   1040 <optima_comparison_full@plt>
cmp    $0xffffffff,%eax
je     11e0 <main_x+0x60>
xor    %ebp,%ebp
jmp    1228 <main_x+0xa8>
nop
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1040 <optima_comparison_full@plt>
cmp    $0xffffffff,%eax
je     11e0 <main_x+0x60>
cmp    $0x2,%eax
jl     1210 <main_x+0x90>
movb   $0x0,(%r14)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    %r12d,%r9d
call   1050 <optima_strip@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    1210 <main_x+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
lea    0xd98(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100000,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <optima_fwrite@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"wire2.ask\00"
@.str.1 = [11 x i8] c"wire2x.ask\00"
define i32 @main_x() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i8* @malloc(i32 1048576)
store i8* %11, i8** %2
%12 = call i8* @malloc(i32 1048576)
store i8* %12, i8** %3
%13 = call i8* @malloc(i32 1048576)
store i8* %13, i8** %4
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 0, i8* %17
%18 = load i8*, i8** %2
%19 = call i32 @optima_fopen(i8* %18, i32 1048576, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %2
%21 = call i32 @optima_normal(i8* %20)
%22 = load i8*, i8** %2
store i8* %22, i8** %5
%23 = load i8*, i8** %2
store i8* %23, i8** %6
store i32 0, i32* %7
br label %24
24: ; preds = %75, %0
%25 = load i32, i32* %7
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %78
27: ; preds = %24
store i32 16, i32* %8
br label %28
28: ; preds = %63, %27
%29 = load i32, i32* %8
%30 = icmp sge i32 %29, 8
br i1 %30, label %31, label %66
31: ; preds = %28
store i32 0, i32* %9
br label %32
32: ; preds = %31, %57
%33 = load i8*, i8** %5
%34 = load i8*, i8** %6
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = call i32 @optima_comparison_full(i8* %33, i8* %34, i32 %35, i32 %36)
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %41
40: ; preds = %32
br label %60
41: ; preds = %32
%42 = load i32, i32* %10
%43 = icmp sge i32 %42, 2
br i1 %43, label %44, label %57
44: ; preds = %41
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 0
store i8 0, i8* %46
%47 = load i8*, i8** %3
%48 = load i8*, i8** %4
%49 = load i8*, i8** %5
%50 = load i8*, i8** %6
%51 = load i32, i32* %9
%52 = load i32, i32* %8
%53 = call i32 @optima_strip(i8* %47, i8* %48, i8* %49, i8* %50, i32 %51, i32 %52)
%54 = load i8*, i8** %2
%55 = load i8*, i8** %3
%56 = call i32 @strcpy(i8* %54, i8* %55)
br label %57
57: ; preds = %44, %41
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %32
60: ; preds = %40
%61 = load i8*, i8** %2
%62 = call i32 @optima_normal(i8* %61)
br label %63
63: ; preds = %60
%64 = load i32, i32* %8
%65 = add nsw i32 %64, -1
store i32 %65, i32* %8
br label %28
66: ; preds = %28
%67 = load i8*, i8** %2
%68 = load i8*, i8** %3
%69 = call i32 @strcpy(i8* %67, i8* %68)
%70 = load i8*, i8** %2
%71 = load i8*, i8** %4
%72 = call i32 @strcat(i8* %70, i8* %71)
%73 = load i8*, i8** %2
%74 = call i32 @optima_fwrite(i8* %73, i32 1048576, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %75
75: ; preds = %66
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %24
78: ; preds = %24
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@.str = [10 x i8] c"wire2.ask\00"
@.str.1 = [11 x i8] c"wire2x.ask\00"
define i32 @main_x() {
%1 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%2 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%3 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
store i8 0, i8* %2
store i8 0, i8* %3
%4 = tail call i32 @optima_fopen(i8* %1, i32 1048576, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @optima_normal(i8* %1)
br label %6
6: ; preds = %0, %21
%7 = phi i32 [ 16, %0 ], [ %23, %21 ]
%8 = tail call i32 @optima_comparison_full(i8* %1, i8* %1, i32 0, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %21, label %10
10: ; preds = %6, %17
%11 = phi i32 [ %19, %17 ], [ %8, %6 ]
%12 = phi i32 [ %18, %17 ], [ 0, %6 ]
%13 = icmp sgt i32 %11, 1
br i1 %13, label %14, label %17
14: ; preds = %10
store i8 0, i8* %2
%15 = tail call i32 @optima_strip(i8* %2, i8* %3, i8* %1, i8* %1, i32 %12, i32 %7)
%16 = tail call i32 @strcpy(i8* %1, i8* %2)
br label %17
17: ; preds = %10, %14
%18 = add nuw nsw i32 %12, 1
%19 = tail call i32 @optima_comparison_full(i8* %1, i8* %1, i32 %18, i32 %7)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %10
21: ; preds = %17, %6
%22 = tail call i32 @optima_normal(i8* %1)
%23 = add nsw i32 %7, -1
%24 = icmp ugt i32 %7, 8
br i1 %24, label %6, label %25
25: ; preds = %21
%26 = tail call i32 @strcpy(i8* %1, i8* %2)
%27 = tail call i32 @strcat(i8* %1, i8* %3)
%28 = tail call i32 @optima_fwrite(i8* %1, i32 1048576, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
ret i32 undef
}