#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strrindex(char *, char *);
int x_getline(char **, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc != 2)
    return 1;
  char *line = NULL;
  while (x_getline(&line, stdin) != -1) {
    printf("%ld\n", strrindex(line, argv[1]));
    free(line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <main+0x83>
movq   $0x0,-0x18(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdi
call   1040 <x_getline@plt>
cmp    $0xffffffff,%eax
je     11bc <main+0x7c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1060 <strrindex@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1174 <main+0x34>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x2,%edi
jne    11be <main+0x7e>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
movq   $0x0,(%rsp)
mov    0x2e84(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdi
call   1040 <x_getline@plt>
cmp    $0xffffffff,%eax
je     11b1 <main+0x71>
lea    0xe84(%rip),%r14
mov    %rsp,%r15
nop
mov    (%rsp),%rdi
mov    0x8(%rbx),%rsi
call   1060 <strrindex@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    (%r12),%esi
mov    %r15,%rdi
call   1040 <x_getline@plt>
cmp    $0xffffffff,%eax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %25
10: ; preds = %2
store i8* null, i8** %6
br label %11
11: ; preds = %15, %10
%12 = load i32, i32* @stdin
%13 = call i32 @x_getline(i8** %6, i32 %12)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strrindex(i8* %16, i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
br label %11
24: ; preds = %11
store i32 0, i32* %3
br label %25
25: ; preds = %24, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %23
5: ; preds = %2
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = load i32, i32* @stdin
%8 = call i32 @x_getline(i8** %3, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %22, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8*, i8** %1, i64 1
br label %12
12: ; preds = %10, %12
%13 = load i8*, i8** %3
%14 = load i8*, i8** %11
%15 = call i32 @strrindex(i8* %13, i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* @stdin
%20 = call i32 @x_getline(i8** %3, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %12
22: ; preds = %12, %5
br label %23
23: ; preds = %2, %22
%24 = phi i32 [ 0, %22 ], [ 1, %2 ]
ret i32 %24
}