#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*/ fgets(char *, int, int /*<<< orphan*/);
int match(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char arr1[100], arr2[100];
  int position;
  printf("Enter some text : ");
  fgets(arr1, 100, stdin);
  printf("Enter a string to find : ");
  fgets(arr2, 100, stdin);
  position = match(arr1, arr2);
  if (position != -1)
    printf("\nFound at [%d] with adress|%p|\n", position + 1, &position);
  else
    printf("\nNOT FOUND\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <match@plt>
mov    %eax,-0xe4(%rbp)
cmpl   $0xffffffff,-0xe4(%rbp)
je     11d5 <main+0xa5>
mov    -0xe4(%rbp),%esi
add    $0x1,%esi
lea    0xe6b(%rip),%rdi
lea    -0xe4(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xb3>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e89(%rip),%rbx
mov    (%rbx),%edx
lea    0x80(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <match@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     11c6 <main+0x86>
add    $0x1,%eax
lea    0xe77(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d2 <main+0x92>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter some text : \00"
@stdin = global i32 0
@.str.1 = [26 x i8] c"Enter a string to find : \00"
@.str.2 = [32 x i8] c"\0AFound at [%d] with adress|%p|\0A\00"
@.str.3 = [12 x i8] c"\0ANOT FOUND\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 100, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 100, i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @match(i8* %13, i8* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %0
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32* %4)
br label %24
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter some text : \00"
@stdin = global i32 0
@.str.1 = [26 x i8] c"Enter a string to find : \00"
@.str.2 = [32 x i8] c"\0AFound at [%d] with adress|%p|\0A\00"
@str = [11 x i8] c"\0ANOT FOUND\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %4, i32 100, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %5, i32 100, i32 %11)
%13 = call i32 @match(i8* %4, i8* %5)
store i32 %13, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = add nuw nsw i32 %13, 1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32* %3)
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret i32 0
}