#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int main() {
  char str[80], search[10];
  int count1 = 0, count2 = 0, i, j, flag;
  printf("Enter a string:");
  gets(str);
  printf("Enter search substring:");
  gets(search);
  count1 = strlen(str);
  count2 = strlen(search);
  for (i = 0; i <= count1 - count2; i++) {
    for (j = i; j < i + count2; j++) {
      flag = 1;
      if (str[j] != search[j - i]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1)
      break;
  }
  if (flag == 1)
    printf("SEARCH SUCCESSFUL!");
  else
    printf("SEARCH UNSUCCESSFUL!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1050 <gets@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x6a(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x70(%rbp)
lea    -0x6a(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    -0x70(%rbp),%ecx
sub    -0x74(%rbp),%ecx
cmp    %ecx,%eax
jg     1228 <main+0xf8>
mov    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%ecx
add    -0x74(%rbp),%ecx
cmp    %ecx,%eax
jge    1206 <main+0xd6>
movl   $0x1,-0x80(%rbp)
movslq -0x7c(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
mov    -0x7c(%rbp),%ecx
sub    -0x78(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x6a(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11f3 <main+0xc3>
movl   $0x0,-0x80(%rbp)
jmp    1206 <main+0xd6>
jmp    11f8 <main+0xc8>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11b0 <main+0x80>
cmpl   $0x1,-0x80(%rbp)
jne    1215 <main+0xe5>
jmp    1228 <main+0xf8>
jmp    121a <main+0xea>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1199 <main+0x69>
cmpl   $0x1,-0x80(%rbp)
jne    1243 <main+0x113>
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
jmp    124f <main+0x11f>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1050 <gets@plt>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0x6(%rsp),%r15
mov    %r15,%rdi
call   1050 <gets@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0xeb4(%rip),%rdi
sub    %eax,%r14d
jl     11df <main+0xaf>
movslq %eax,%r9
add    $0x1,%r14d
xor    %edx,%edx
lea    0xe8c(%rip),%r8
jmp    11ad <main+0x7d>
xchg   %ax,%ax
add    $0x1,%rdx
add    $0x1,%r12
cmp    %r14,%rdx
je     11df <main+0xaf>
test   %eax,%eax
jle    11a0 <main+0x70>
lea    (%rdx,%r9,1),%rsi
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rcx,1),%ebx
cmp    0x6(%rsp,%rcx,1),%bl
jne    11a0 <main+0x70>
lea    (%rdx,%rcx,1),%rbx
add    $0x1,%rbx
add    $0x1,%rcx
cmp    %rsi,%rbx
jl     11c0 <main+0x90>
mov    %r8,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a string:\00"
@.str.1 = [24 x i8] c"Enter search substring:\00"
@.str.2 = [19 x i8] c"SEARCH SUCCESSFUL!\00"
@.str.3 = [21 x i8] c"SEARCH UNSUCCESSFUL!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%14 = call i32 @gets(i8* %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %4
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %5
store i32 0, i32* %6
br label %19
19: ; preds = %57, %0
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = sub nsw i32 %21, %22
%24 = icmp sle i32 %20, %23
br i1 %24, label %25, label %60
25: ; preds = %19
%26 = load i32, i32* %6
store i32 %26, i32* %7
br label %27
27: ; preds = %49, %25
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = load i32, i32* %5
%31 = add nsw i32 %29, %30
%32 = icmp slt i32 %28, %31
br i1 %32, label %33, label %52
33: ; preds = %27
store i32 1, i32* %8
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = sub nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %38, %45
br i1 %46, label %47, label %48
47: ; preds = %33
store i32 0, i32* %8
br label %52
48: ; preds = %33
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %27
52: ; preds = %47, %27
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %56
55: ; preds = %52
br label %60
56: ; preds = %52
br label %57
57: ; preds = %56
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %19
60: ; preds = %55, %19
%61 = load i32, i32* %8
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %67
65: ; preds = %60
%66 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %63
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter a string:\00"
@.str.1 = [24 x i8] c"Enter search substring:\00"
@.str.2 = [19 x i8] c"SEARCH SUCCESSFUL!\00"
@.str.3 = [21 x i8] c"SEARCH UNSUCCESSFUL!\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strlen(i8* %3)
%10 = call i32 @strlen(i8* %4)
%11 = icmp slt i32 %9, %10
br i1 %11, label %35, label %12
12: ; preds = %0
%13 = sext i32 %10 to i64
%14 = add i32 %9, 1
%15 = sub i32 %14, %10
%16 = zext i32 %15 to i64
%17 = icmp sgt i32 %10, 0
br label %18
18: ; preds = %12, %32
%19 = phi i64 [ 0, %12 ], [ %33, %32 ]
%20 = add nsw i64 %19, %13
br i1 %17, label %23, label %32
21: ; preds = %23
%22 = icmp slt i64 %31, %20
br i1 %22, label %23, label %35
23: ; preds = %18, %21
%24 = phi i64 [ %31, %21 ], [ %19, %18 ]
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sub nuw nsw i64 %24, %19
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %26, %29
%31 = add nuw nsw i64 %24, 1
br i1 %30, label %21, label %32
32: ; preds = %23, %18
%33 = add nuw nsw i64 %19, 1
%34 = icmp eq i64 %33, %16
br i1 %34, label %35, label %18
35: ; preds = %32, %21, %0
%36 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %21 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %32 ]
%37 = call i32 @printf(i8* dereferenceable(1) %36)
ret i32 0
}