#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);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
char *strstr(char *, char *);
main() {
  char s1[100];
  char s2[100];
  int cnt = 0;
  char *ptr;
  puts("Enter a string s1: ");
  scanf(" %s", s1);
  puts("Enter string s2: ");
  scanf(" %s", s2);
  ptr = s1;
  while (ptr = strstr(ptr, s2)) {
    cnt++;
    ptr++;
  }
  printf("%d\n", cnt);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xe4(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
lea    -0x70(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0xf0(%rbp)
cmp    $0x0,%rax
je     11ec <main+0xac>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
jmp    11a2 <main+0x62>
mov    -0xe4(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%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
call   1030 <puts@plt>
lea    0xeb5(%rip),%r15
lea    0x70(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11b7 <main+0x77>
mov    %rsp,%r14
xchg   %ax,%ax
add    $0x1,%ebx
add    $0x1,%rax
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11a0 <main+0x60>
lea    0xe6c(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter a string s1: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [18 x i8] c"Enter string s2: \00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8* %12, i8** %5
br label %13
13: ; preds = %18, %0
%14 = load i8*, i8** %5
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = call i8* @strstr(i8* %14, i8* %15)
store i8* %16, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %5
br label %13
23: ; preds = %13
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter a string s1: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [18 x i8] c"Enter string s2: \00"
@.str.3 = [4 x i8] c"%d\0A\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i8* @strstr(i8* dereferenceable(1) %3, i8* %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %0, %11
%12 = phi i8* [ %16, %11 ], [ %9, %0 ]
%13 = phi i32 [ %14, %11 ], [ 0, %0 ]
%14 = add nuw nsw i32 %13, 1
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = call i8* @strstr(i8* dereferenceable(1) %15, i8* %4)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %11
18: ; preds = %11, %0
%19 = phi i32 [ 0, %0 ], [ %14, %11 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
ret i32 0
}