#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
void main() {
  char str1[20], str2[20], *p1, *p2;
  int sum = 0;
  printf("Please input the first string:\n");
  scanf("%s", str1);
  printf("Please input the second string:\n");
  scanf("%s", str2);
  p1 = str1;
  p2 = str2;
  while (*p1 != '\0') {
    if (*p1 == *p2) {
      while (*p1 == *p2 && *p2 != '\0') {
        p1++;
        p2++;
      }
    } else
      p1++;
    if (*p2 == '\0')
      sum++;
    p2 = str2;
  }
  printf("%d\n", sum);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x54(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xec8(%rip),%rdi
call   1050 <scanf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeaa(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1245 <main+0x115>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
mov    -0x50(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1213 <main+0xe3>
jmp    11b6 <main+0x86>
mov    -0x48(%rbp),%rax
movsbl (%rax),%ecx
mov    -0x50(%rbp),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x55(%rbp)
jne    11e1 <main+0xb1>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    11f1 <main+0xc1>
jmp    120e <main+0xde>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11b6 <main+0x86>
jmp    121f <main+0xef>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1238 <main+0x108>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    118b <main+0x5b>
mov    -0x54(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%r15
lea    0x20(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x20(%rsp),%cl
xor    %esi,%esi
test   %cl,%cl
je     11f1 <main+0xb1>
mov    (%rsp),%dil
jmp    11b4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
mov    0x1(%rbx),%cl
add    $0x1,%rbx
mov    %r14,%rdx
cmpb   $0x1,(%rdx)
adc    $0x0,%esi
test   %cl,%cl
je     11f1 <main+0xb1>
cmp    %dil,%cl
jne    11a0 <main+0x60>
test   %dil,%dil
je     11ea <main+0xaa>
mov    %r14,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
movzbl 0x1(%rdx),%eax
add    $0x1,%rdx
cmp    %al,%cl
jne    11aa <main+0x6a>
test   %al,%al
jne    11d0 <main+0x90>
jmp    11aa <main+0x6a>
cmpb   $0x1,(%rsp)
adc    $0x0,%esi
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please input the first string:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [33 x i8] c"Please input the second string:\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
store i8* %12, i8** %3
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8* %13, i8** %4
br label %14
14: ; preds = %60, %0
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %62
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %22, %25
br i1 %26, label %27, label %49
27: ; preds = %19
br label %28
28: ; preds = %43, %27
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %31, %34
br i1 %35, label %36, label %41
36: ; preds = %28
%37 = load i8*, i8** %4
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br label %41
41: ; preds = %36, %28
%42 = phi i1 [ false, %28 ], [ %40, %36 ]
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
br label %28
48: ; preds = %41
br label %52
49: ; preds = %19
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %3
br label %52
52: ; preds = %49, %48
%53 = load i8*, i8** %4
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %60
60: ; preds = %57, %52
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8* %61, i8** %4
br label %14
62: ; preds = %14
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [31 x i8] c"Please input the first string:\00"
@str.4 = [32 x i8] c"Please input the second string:\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 0
br i1 %10, label %47, label %11
11: ; preds = %0
%12 = load i8, i8* %4
%13 = icmp eq i8 %12, 0
br label %14
14: ; preds = %11, %38
%15 = phi i8 [ %9, %11 ], [ %39, %38 ]
%16 = phi i32 [ 0, %11 ], [ %45, %38 ]
%17 = phi i8* [ %3, %11 ], [ %40, %38 ]
%18 = icmp eq i8 %15, %12
br i1 %18, label %19, label %35
19: ; preds = %14
br i1 %13, label %20, label %25
20: ; preds = %19
%21 = load i8, i8* %4
%22 = icmp eq i8 %21, 0
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %16, %23
br label %47
25: ; preds = %19, %25
%26 = phi i8* [ %29, %25 ], [ %4, %19 ]
%27 = phi i8* [ %28, %25 ], [ %17, %19 ]
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = getelementptr inbounds i8, i8* %26, i64 1
%30 = load i8, i8* %28
%31 = load i8, i8* %29
%32 = icmp ne i8 %30, %31
%33 = icmp eq i8 %31, 0
%34 = or i1 %32, %33
br i1 %34, label %38, label %25
35: ; preds = %14
%36 = getelementptr inbounds i8, i8* %17, i64 1
%37 = load i8, i8* %36
br label %38
38: ; preds = %25, %35
%39 = phi i8 [ %37, %35 ], [ %30, %25 ]
%40 = phi i8* [ %36, %35 ], [ %28, %25 ]
%41 = phi i8* [ %4, %35 ], [ %29, %25 ]
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
%44 = zext i1 %43 to i32
%45 = add nuw nsw i32 %16, %44
%46 = icmp eq i8 %39, 0
br i1 %46, label %47, label %14
47: ; preds = %38, %20, %0
%48 = phi i32 [ 0, %0 ], [ %24, %20 ], [ %45, %38 ]
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = call i32 (...) @getchar()
ret void
}