#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 */
scalar_t__ EOF;
int any(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  in = fopen("input.dat", "r");
  if (in == NULL) {
    perror("input.dat");
    return 1;
  }
  out = fopen("output.dat", "w");
  if (out == NULL) {
    perror("output.dat");
    return 1;
  }
  char s1[128];
  char s2[128];
  int p;
  while (fscanf(in, "%s %s", s1, s2) != EOF) {
    p = any(s1, s2);
    fprintf(out, "first location is: %d\n", p);
  }
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b3 <main+0x53>
lea    0xe5e(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    126d <main+0x10d>
lea    0xe52(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ed <main+0x8d>
lea    0xe30(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    126d <main+0x10d>
jmp    11f2 <main+0x92>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe0e(%rip),%rsi
call   1040 <fscanf@plt>
mov    0x2dd1(%rip),%rcx
cmp    (%rcx),%rax
je     1254 <main+0xf4>
lea    -0xa0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1060 <any@plt>
mov    %eax,-0x124(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x124(%rbp),%edx
lea    0xdd5(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11f2 <main+0x92>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1247 <main+0xe7>
mov    %rax,%r14
lea    0xe75(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1250 <main+0xf0>
mov    %rax,%r15
lea    0xe63(%rip),%rsi
lea    0x80(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1040 <fscanf@plt>
mov    0x2e18(%rip),%r13
cmp    0x0(%r13),%rax
je     1223 <main+0xc3>
lea    0x80(%rsp),%r12
mov    %rsp,%rbx
lea    0xe31(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <any@plt>
mov    %r15,%rdi
lea    0xe1a(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1040 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    11f0 <main+0x90>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb2(%rip),%rdi
jmp    1257 <main+0xf7>
lea    0xdb5(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    1235 <main+0xd5>

LLVM IR (-O0):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.5 = [23 x i8] c"first location is: %d\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 [128 x i8]
%9 = alloca [128 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %42
16: ; preds = %2
%17 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %42
22: ; preds = %16
br label %23
23: ; preds = %30, %22
%24 = load i32*, i32** %6
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%27 = call i64 @fscanf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* %26)
%28 = load i64, i64* @EOF
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %23
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%33 = call i32 @any(i8* %31, i8* %32)
store i32 %33, i32* %10
%34 = load i32*, i32** %7
%35 = load i32, i32* %10
%36 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %23
37: ; preds = %23
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
%40 = load i32*, i32** %7
%41 = call i32 @fclose(i32* %40)
store i32 0, i32* %3
br label %42
42: ; preds = %37, %20, %14
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.5 = [23 x i8] c"first location is: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %29
9: ; preds = %2
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %29
14: ; preds = %9
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%17 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %26, label %20
20: ; preds = %14, %20
%21 = call i32 @any(i8* %15, i8* %16)
%22 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %16)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %20
26: ; preds = %20, %14
%27 = call i32 @fclose(i32* %5)
%28 = call i32 @fclose(i32* %10)
br label %29
29: ; preds = %26, %12, %7
%30 = phi i32 [ 1, %7 ], [ 1, %12 ], [ 0, %26 ]
ret i32 %30
}