#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ getline(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int strrindex(char *, 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 s[128], t[128];
  int i;
  int n = 0;
  fscanf(in, "%d", &n);
  fgetc(in);
  while (n--) {
    getline(in, s, 128);
    getline(in, t, 128);
    i = strrindex(s, t);
    fprintf(out, "strrindex(\n'%s', \n'%s')\n\t is %d\n\n", s, t, i);
  }
  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    0xe60(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d3 <main+0x53>
lea    0xe3e(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <main+0x157>
lea    0xe32(%rip),%rdi
lea    0xe36(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120d <main+0x8d>
lea    0xe10(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d7 <main+0x157>
movl   $0x0,-0x128(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdf7(%rip),%rsi
lea    -0x128(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    -0x128(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x128(%rbp)
cmp    $0x0,%eax
je     12be <main+0x13e>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   10a0 <getline@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x80,%edx
call   10a0 <getline@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1060 <strrindex@plt>
mov    %eax,-0x124(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    -0x120(%rbp),%rcx
mov    -0x124(%rbp),%r8d
lea    0xd68(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1237 <main+0xb7>
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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x110,%rsp
lea    0xe69(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1279 <main+0xf9>
mov    %rax,%r15
lea    0xe56(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1282 <main+0x102>
mov    %rax,%r14
movl   $0x0,0xc(%rsp)
lea    0xe3c(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
call   1040 <fscanf@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
subl   $0x1,0xc(%rsp)
jb     1256 <main+0xd6>
lea    0x90(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xe0f(%rip),%r13
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x80,%edx
call   10a0 <getline@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x80,%edx
call   10a0 <getline@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strrindex@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1070 <fprintf@plt>
subl   $0x1,0xc(%rsp)
jae    1210 <main+0x90>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd80(%rip),%rdi
jmp    1289 <main+0x109>
lea    0xd83(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
jmp    1268 <main+0xe8>

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 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"strrindex(\0A'%s', \0A'%s')\0A\09 is %d\0A\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
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = 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* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %52
17: ; preds = %2
%18 = 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* %18, i32** %7
%19 = load i32*, i32** %7
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = 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 %52
23: ; preds = %17
store i32 0, i32* %11
%24 = load i32*, i32** %6
%25 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %11)
%26 = load i32*, i32** %6
%27 = call i32 @fgetc(i32* %26)
br label %28
28: ; preds = %32, %23
%29 = load i32, i32* %11
%30 = add nsw i32 %29, -1
store i32 %30, i32* %11
%31 = icmp ne i32 %29, 0
br i1 %31, label %32, label %47
32: ; preds = %28
%33 = load i32*, i32** %6
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%35 = call i32 @getline(i32* %33, i8* %34, i32 128)
%36 = load i32*, i32** %6
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%38 = call i32 @getline(i32* %36, i8* %37, i32 128)
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%41 = call i32 @strrindex(i8* %39, i8* %40)
store i32 %41, i32* %10
%42 = load i32*, i32** %7
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%45 = load i32, i32* %10
%46 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %43, i8* %44, i32 %45)
br label %28
47: ; preds = %28
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
%50 = load i32*, i32** %7
%51 = call i32 @fclose(i32* %50)
store i32 0, i32* %3
br label %52
52: ; preds = %47, %21, %15
%53 = load i32, i32* %3
ret i32 %53
}

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 = [3 x i8] c"%d\00"
@.str.5 = [34 x i8] c"strrindex(\0A'%s', \0A'%s')\0A\09 is %d\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = 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))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %35
10: ; preds = %2
%11 = 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))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %35
15: ; preds = %10
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%18 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%19 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%20 = call i32 @fgetc(i32* %6)
%21 = load i32, i32* %5
%22 = add nsw i32 %21, -1
store i32 %22, i32* %5
%23 = icmp eq i32 %21, 0
br i1 %23, label %32, label %24
24: ; preds = %15, %24
%25 = call i32 @getline(i32* %6, i8* %16, i32 128)
%26 = call i32 @getline(i32* %6, i8* %17, i32 128)
%27 = call i32 @strrindex(i8* %16, i8* %17)
%28 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %16, i8* %17, i32 %27)
%29 = load i32, i32* %5
%30 = add nsw i32 %29, -1
store i32 %30, i32* %5
%31 = icmp eq i32 %29, 0
br i1 %31, label %32, label %24
32: ; preds = %24, %15
%33 = call i32 @fclose(i32* %6)
%34 = call i32 @fclose(i32* %11)
br label %35
35: ; preds = %32, %13, %8
%36 = phi i32 [ 1, %8 ], [ 1, %13 ], [ 0, %32 ]
ret i32 %36
}