#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 fnMatchAny(char *, char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char acStr[100], acSubStr[100];
  int iFound;
  printf("\n****************************************************");
  printf("\n*\tPROGRAM TO IMPLEMENT STRING MATCHING\t   *\n");
  printf("****************************************************");
  printf("\nEnter first string\n");
  gets(acStr);
  printf("\nEnter second string\n");
  gets(acSubStr);
  iFound = fnMatchAny(acStr, acSubStr);
  printf("\nFirst string is\n");
  printf("%s\n", acStr);
  printf("\nSecond string is\n");
  printf("%s\n", acSubStr);
  if (iFound != -1)
    printf("\nCharacter \'%c\' from Second string is found at position %d in "
           "the First string\n",
           acStr[iFound], iFound + 1);
  else
    printf("\nMatch not 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    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <fnMatchAny@plt>
mov    %eax,-0xe4(%rbp)
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0xe4(%rbp)
je     122b <main+0xfb>
movslq -0xe4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
mov    -0xe4(%rbp),%edx
add    $0x1,%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1239 <main+0x109>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf25(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf38(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <gets@plt>
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fnMatchAny@plt>
mov    %eax,%ebx
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xf21(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
cmp    $0xffffffff,%ebx
je     11fa <main+0xba>
movslq %ebx,%rax
movsbl (%rsp,%rax,1),%esi
add    $0x1,%ebx
lea    0xe47(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1206 <main+0xc6>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [54 x i8] c"\0A****************************************************\00"
@.str.1 = [46 x i8] c"\0A*\09PROGRAM TO IMPLEMENT STRING MATCHING\09 *\0A\00"
@.str.2 = [53 x i8] c"****************************************************\00"
@.str.3 = [21 x i8] c"\0AEnter first string\0A\00"
@.str.4 = [22 x i8] c"\0AEnter second string\0A\00"
@.str.5 = [18 x i8] c"\0AFirst string is\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [19 x i8] c"\0ASecond string is\0A\00"
@.str.8 = [80 x i8] c"\0ACharacter '%c' from Second string is found at position %d in the First string\0A\00"
@.str.9 = [18 x i8] c"\0AMatch not 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 ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i32 @fnMatchAny(i8* %14, i8* %15)
store i32 %16, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %34
25: ; preds = %0
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.8, i64 0, i64 0), i32 %30, i32 %32)
br label %36
34: ; preds = %0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %36
36: ; preds = %34, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [54 x i8] c"\0A****************************************************\00"
@.str.2 = [53 x i8] c"****************************************************\00"
@.str.8 = [80 x i8] c"\0ACharacter '%c' from Second string is found at position %d in the First string\0A\00"
@str = [45 x i8] c"\0A*\09PROGRAM TO IMPLEMENT STRING MATCHING\09 *\00"
@str.10 = [20 x i8] c"\0AEnter first string\00"
@str.11 = [21 x i8] c"\0AEnter second string\00"
@str.12 = [17 x i8] c"\0AFirst string is\00"
@str.13 = [18 x i8] c"\0ASecond string is\00"
@str.14 = [17 x i8] c"\0AMatch not found\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%9 = call i32 @gets(i8* %3)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @gets(i8* %4)
%12 = call i32 @fnMatchAny(i8* %3, i8* %4)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%14 = call i32 @puts(i8* %3)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%16 = call i32 @puts(i8* %4)
%17 = icmp eq i32 %12, -1
br i1 %17, label %25, label %18
18: ; preds = %0
%19 = sext i32 %12 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nuw nsw i32 %12, 1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.8, i64 0, i64 0), i32 %22, i32 %23)
br label %27
25: ; preds = %0
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
br label %27
27: ; preds = %25, %18
ret i32 0
}