#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 main() {
  char str[80], search[10];
  int count1 = 0, count2 = 0, i, j, flag;
  printf("enter first string-");
  gets(str);
  printf("enter second string-");
  gets(search);
  while (str[count1] != '\0')
    count1++;
  while (search[count2] != '\0')
    count2++;
  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    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1040 <gets@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    -0x6a(%rbp),%rdi
call   1040 <gets@plt>
movslq -0x70(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     118a <main+0x6a>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    116a <main+0x4a>
jmp    118f <main+0x6f>
movslq -0x74(%rbp),%rax
movsbl -0x6a(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11af <main+0x8f>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    118f <main+0x6f>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    -0x70(%rbp),%ecx
sub    -0x74(%rbp),%ecx
cmp    %ecx,%eax
jg     1245 <main+0x125>
mov    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%ecx
add    -0x74(%rbp),%ecx
cmp    %ecx,%eax
jge    1223 <main+0x103>
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     1210 <main+0xf0>
movl   $0x0,-0x80(%rbp)
jmp    1223 <main+0x103>
jmp    1215 <main+0xf5>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11cd <main+0xad>
cmpl   $0x1,-0x80(%rbp)
jne    1232 <main+0x112>
jmp    1245 <main+0x125>
jmp    1237 <main+0x117>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11b6 <main+0x96>
cmpl   $0x1,-0x80(%rbp)
jne    1260 <main+0x140>
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <main+0x14c>
lea    0xdd4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <gets@plt>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
lea    0x6(%rsp),%rdi
call   1040 <gets@plt>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdx
add    $0x1,%rax
cmpb   $0x0,0x10(%rsp,%rdx,1)
jne    1160 <main+0x40>
mov    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,0x7(%rsp,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1180 <main+0x60>
lea    0xea9(%rip),%rdi
cmp    %ecx,%edx
jl     11ef <main+0xcf>
sub    %ecx,%eax
xor    %r9d,%r9d
lea    0xe87(%rip),%r8
jmp    11bd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r9
add    $0x1,%r14
cmp    %rax,%r9
je     11ef <main+0xcf>
test   %ecx,%ecx
je     11b0 <main+0x90>
lea    (%rcx,%r9,1),%esi
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%edx
cmp    0x6(%rsp,%rbx,1),%dl
jne    11b0 <main+0x90>
lea    (%r9,%rbx,1),%rdx
add    $0x1,%rdx
add    $0x1,%rbx
cmp    %rsi,%rdx
jb     11d0 <main+0xb0>
mov    %r8,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"enter first string-\00"
@.str.1 = [21 x i8] c"enter second string-\00"
@.str.2 = [18 x i8] c"search successful\00"
@.str.3 = [20 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 ([20 x i8], [20 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 ([21 x i8], [21 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)
br label %15
15: ; preds = %22, %0
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %15
25: ; preds = %15
br label %26
26: ; preds = %33, %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %26
36: ; preds = %26
store i32 0, i32* %6
br label %37
37: ; preds = %75, %36
%38 = load i32, i32* %6
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = sub nsw i32 %39, %40
%42 = icmp sle i32 %38, %41
br i1 %42, label %43, label %78
43: ; preds = %37
%44 = load i32, i32* %6
store i32 %44, i32* %7
br label %45
45: ; preds = %67, %43
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = load i32, i32* %5
%49 = add nsw i32 %47, %48
%50 = icmp slt i32 %46, %49
br i1 %50, label %51, label %70
51: ; preds = %45
store i32 1, i32* %8
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = sub nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %56, %63
br i1 %64, label %65, label %66
65: ; preds = %51
store i32 0, i32* %8
br label %70
66: ; preds = %51
br label %67
67: ; preds = %66
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %45
70: ; preds = %65, %45
%71 = load i32, i32* %8
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %74
73: ; preds = %70
br label %78
74: ; preds = %70
br label %75
75: ; preds = %74
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %37
78: ; preds = %73, %37
%79 = load i32, i32* %8
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %85
83: ; preds = %78
%84 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"enter first string-\00"
@.str.1 = [21 x i8] c"enter second string-\00"
@.str.2 = [18 x i8] c"search successful\00"
@.str.3 = [20 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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = add nuw i64 %10, 1
br i1 %13, label %15, label %9
15: ; preds = %9, %15
%16 = phi i64 [ %20, %15 ], [ 0, %9 ]
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
%20 = add nuw i64 %16, 1
br i1 %19, label %21, label %15
21: ; preds = %15
%22 = trunc i64 %10 to i32
%23 = trunc i64 %16 to i32
%24 = icmp slt i32 %22, %23
br i1 %24, label %49, label %25
25: ; preds = %21
%26 = add i64 %10, 1
%27 = sub i64 %26, %16
%28 = and i64 %27, 4294967295
%29 = icmp eq i32 %23, 0
br label %30
30: ; preds = %25, %46
%31 = phi i64 [ 0, %25 ], [ %47, %46 ]
br i1 %29, label %46, label %32
32: ; preds = %30
%33 = add i64 %31, %16
%34 = and i64 %33, 4294967295
br label %37
35: ; preds = %37
%36 = icmp ult i64 %45, %34
br i1 %36, label %37, label %49
37: ; preds = %32, %35
%38 = phi i64 [ %31, %32 ], [ %45, %35 ]
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sub nuw nsw i64 %38, %31
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %40, %43
%45 = add nuw nsw i64 %38, 1
br i1 %44, label %35, label %46
46: ; preds = %37, %30
%47 = add nuw nsw i64 %31, 1
%48 = icmp eq i64 %47, %28
br i1 %48, label %49, label %30
49: ; preds = %46, %35, %21
%50 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %21 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %35 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %46 ]
%51 = call i32 @printf(i8* dereferenceable(1) %50)
ret i32 0
}