#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, size_t);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int substringfound(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *filea, *fileb;
  size_t offset, size_fileb;
  bool found = false;
  int i, ret = 31;
  if (argc < 3) {
    puts("-15");
    return 15;
  }
  filea = fopen(argv[1], "rb");
  if (!filea) {
    puts("-7");
    return 7;
  }
  for (i = 2; i < argc; i++) {
    fileb = fopen(argv[i], "rb");
    if (!fileb) {
      puts("-3");
      ret &= 3;
    } else {
      found = false;
      fseek(fileb, 0, SEEK_END);
      size_fileb = ftell(fileb);
      for (offset = 0; offset < size_fileb; offset++) {
        rewind(filea);
        fseek(fileb, offset, SEEK_SET);
        found = substringfound(filea, fileb);
        if (found)
          break;
      }
      if (!found) {
        puts("-1");
        ret &= 1;
      } else {
        printf("%zu\n", offset);
        ret &= 0;
      }
      fclose(fileb);
    }
  }
  fclose(filea);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x1f,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c6 <main+0x46>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
movl   $0xf,-0x4(%rbp)
jmp    1351 <main+0x1d1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1201 <main+0x81>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
movl   $0x7,-0x4(%rbp)
jmp    1351 <main+0x1d1>
movl   $0x2,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1342 <main+0x1c2>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xddd(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1255 <main+0xd5>
lea    0xdc8(%rip),%rdi
call   1030 <puts@plt>
mov    -0x3c(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x3c(%rbp)
jmp    132f <main+0x1af>
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    12e9 <main+0x169>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <substringfound@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     12d3 <main+0x153>
jmp    12e9 <main+0x169>
jmp    12d8 <main+0x158>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1287 <main+0x107>
cmpl   $0x0,-0x34(%rbp)
jne    130d <main+0x18d>
lea    0xd13(%rip),%rdi
call   1030 <puts@plt>
mov    -0x3c(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1326 <main+0x1a6>
mov    -0x28(%rbp),%rsi
lea    0xcf8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x3c(%rbp),%eax
and    $0x0,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1334 <main+0x1b4>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1208 <main+0x88>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jg     11aa <main+0x2a>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    $0xf,%r15d
jmp    12e6 <main+0x166>
mov    %rsi,%rbp
mov    %edi,%r14d
mov    0x8(%rsi),%rdi
lea    0xe49(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12d4 <main+0x154>
mov    %rax,%rbx
mov    %r14d,%eax
mov    %rax,0x10(%rsp)
mov    $0x1f,%r15d
mov    $0x2,%r14d
jmp    120f <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
and    $0x3,%r15d
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     12ca <main+0x14a>
mov    0x0(%rbp,%r14,8),%rdi
lea    0xde9(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11f0 <main+0x70>
mov    %rax,%r12
mov    %r15d,0xc(%rsp)
mov    0x2db4(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r12,%rdi
call   1070 <ftell@plt>
test   %rax,%rax
je     1294 <main+0x114>
mov    %rax,%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1080 <fseek@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <substringfound@plt>
test   %eax,%eax
jne    12ab <main+0x12b>
add    $0x1,%r15
cmp    %r15,%r13
jne    1260 <main+0xe0>
lea    0xd72(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%r15d
and    $0x1,%r15d
jmp    12bd <main+0x13d>
lea    0xd5e(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
xor    %r15d,%r15d
mov    %r12,%rdi
call   1040 <fclose@plt>
jmp    1200 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    12e6 <main+0x166>
lea    0xd2c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"-15\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"-7\00"
@.str.3 = [3 x i8] c"-3\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [3 x i8] c"-1\00"
@.str.5 = [5 x i8] c"%zu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 31, i32* %12
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 15, i32* %3
br label %94
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %26, label %24
24: ; preds = %17
%25 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 7, i32* %3
br label %94
26: ; preds = %17
store i32 2, i32* %11
br label %27
27: ; preds = %87, %26
%28 = load i32, i32* %11
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %90
31: ; preds = %27
%32 = load i8**, i8*** %5
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %7
%38 = load i32*, i32** %7
%39 = icmp ne i32* %38, null
br i1 %39, label %44, label %40
40: ; preds = %31
%41 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = load i32, i32* %12
%43 = and i32 %42, 3
store i32 %43, i32* %12
br label %86
44: ; preds = %31
store i32 0, i32* %10
%45 = load i32*, i32** %7
%46 = load i32, i32* @SEEK_END
%47 = call i32 @fseek(i32* %45, i64 0, i32 %46)
%48 = load i32*, i32** %7
%49 = call i64 @ftell(i32* %48)
store i64 %49, i64* %9
store i64 0, i64* %8
br label %50
50: ; preds = %68, %44
%51 = load i64, i64* %8
%52 = load i64, i64* %9
%53 = icmp ult i64 %51, %52
br i1 %53, label %54, label %71
54: ; preds = %50
%55 = load i32*, i32** %6
%56 = call i32 @rewind(i32* %55)
%57 = load i32*, i32** %7
%58 = load i64, i64* %8
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @fseek(i32* %57, i64 %58, i32 %59)
%61 = load i32*, i32** %6
%62 = load i32*, i32** %7
%63 = call i32 @substringfound(i32* %61, i32* %62)
store i32 %63, i32* %10
%64 = load i32, i32* %10
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %54
br label %71
67: ; preds = %54
br label %68
68: ; preds = %67
%69 = load i64, i64* %8
%70 = add i64 %69, 1
store i64 %70, i64* %8
br label %50
71: ; preds = %66, %50
%72 = load i32, i32* %10
%73 = icmp ne i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %71
%75 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32, i32* %12
%77 = and i32 %76, 1
store i32 %77, i32* %12
br label %83
78: ; preds = %71
%79 = load i64, i64* %8
%80 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %79)
%81 = load i32, i32* %12
%82 = and i32 %81, 0
store i32 %82, i32* %12
br label %83
83: ; preds = %78, %74
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
br label %86
86: ; preds = %83, %40
br label %87
87: ; preds = %86
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 1
store i32 %89, i32* %11
br label %27
90: ; preds = %27
%91 = load i32*, i32** %6
%92 = call i32 @fclose(i32* %91)
%93 = load i32, i32* %12
store i32 %93, i32* %3
br label %94
94: ; preds = %90, %24, %15
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@.str = [4 x i8] c"-15\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"-7\00"
@.str.3 = [3 x i8] c"-3\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [3 x i8] c"-1\00"
@.str.5 = [5 x i8] c"%zu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %54
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = zext i32 %0 to i64
br label %15
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %54
15: ; preds = %11, %48
%16 = phi i64 [ 2, %11 ], [ %50, %48 ]
%17 = phi i32 [ 31, %11 ], [ %49, %48 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %16
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = and i32 %17, 3
br label %48
25: ; preds = %15
%26 = load i32, i32* @SEEK_END
%27 = tail call i32 @fseek(i32* %20, i64 0, i32 %26)
%28 = tail call i64 @ftell(i32* %20)
%29 = icmp eq i64 %28, 0
br i1 %29, label %40, label %30
30: ; preds = %25, %37
%31 = phi i64 [ %38, %37 ], [ 0, %25 ]
%32 = tail call i32 @rewind(i32* %9)
%33 = load i32, i32* @SEEK_SET
%34 = tail call i32 @fseek(i32* %20, i64 %31, i32 %33)
%35 = tail call i32 @substringfound(i32* %9, i32* %20)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %30
%38 = add nuw i64 %31, 1
%39 = icmp eq i64 %38, %28
br i1 %39, label %40, label %30
40: ; preds = %37, %25
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%42 = and i32 %17, 1
br label %45
43: ; preds = %30
%44 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %31)
br label %45
45: ; preds = %43, %40
%46 = phi i32 [ 0, %43 ], [ %42, %40 ]
%47 = tail call i32 @fclose(i32* %20)
br label %48
48: ; preds = %22, %45
%49 = phi i32 [ %46, %45 ], [ %24, %22 ]
%50 = add nuw nsw i64 %16, 1
%51 = icmp eq i64 %50, %12
br i1 %51, label %52, label %15
52: ; preds = %48
%53 = tail call i32 @fclose(i32* %9)
br label %54
54: ; preds = %52, %13, %4
%55 = phi i32 [ 15, %4 ], [ %49, %52 ], [ 7, %13 ]
ret i32 %55
}