#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*/ printf(char *, int);
void search(char *text, char *shablon, int digit, int index) {
  while ((*(text + digit) == *(shablon + digit)) && (digit > 0)) {
    printf("%d ", index + digit);
    digit--;
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rdx
movsbl (%rax,%rdx,1),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
jne    1155 <search+0x45>
cmpl   $0x0,-0x14(%rbp)
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1165 <search+0x55>
jmp    1185 <search+0x75>
mov    -0x18(%rbp),%esi
add    -0x14(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <search+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movslq %edx,%rbx
mov    (%rdi,%rbx,1),%al
cmp    (%rsi,%rbx,1),%al
jne    1167 <search+0x57>
test   %edx,%edx
jle    1167 <search+0x57>
mov    %ecx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
add    %edx,%ebp
lea    0xec8(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movzbl -0x1(%r15,%rbx,1),%eax
cmp    -0x1(%r14,%rbx,1),%al
jne    1167 <search+0x57>
lea    -0x1(%rbx),%rax
add    $0xffffffff,%ebp
cmp    $0x1,%rbx
mov    %rax,%rbx
jg     1140 <search+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define void @search(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
br label %9
9: ; preds = %28, %4
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %15, %21
br i1 %22, label %23, label %26
23: ; preds = %9
%24 = load i32, i32* %7
%25 = icmp sgt i32 %24, 0
br label %26
26: ; preds = %23, %9
%27 = phi i1 [ false, %9 ], [ %25, %23 ]
br i1 %27, label %28, label %35
28: ; preds = %26
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = add nsw i32 %29, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %7
%34 = add nsw i32 %33, -1
store i32 %34, i32* %7
br label %9
35: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @search(i8* nocapture %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %1, i64 %5
%9 = load i8, i8* %8
%10 = icmp eq i8 %7, %9
%11 = icmp sgt i32 %2, 0
%12 = and i1 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %4, %13
%14 = phi i64 [ %18, %13 ], [ %5, %4 ]
%15 = trunc i64 %14 to i32
%16 = add i32 %15, %3
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = add nsw i64 %14, -1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %1, i64 %18
%22 = load i8, i8* %21
%23 = icmp eq i8 %20, %22
%24 = icmp sgt i64 %14, 1
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %13, label %26
26: ; preds = %13, %4
ret void
}