#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 /*<<< orphan*/ scanf(char *, char *, char *);
int main() {
  char arr1[20], arr2[20];
  int i, j, k = 0;
  printf("Enter two strings\n");
  scanf("%s %s", arr1, arr2);
  for (i = 0; i < 20 && arr1[i] != '\0'; i++) {
    if (arr1[i] == arr2[i]) {
      k++;
    }
  }
  if (i == k - 1) {
    printf("strings are equal\n");
  } else {
    printf("Strings are not equal\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4c(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xec2(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x44(%rbp)
xor    %eax,%eax
cmpl   $0x14,-0x44(%rbp)
mov    %al,-0x4d(%rbp)
jge    117e <main+0x5e>
movslq -0x44(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    118e <main+0x6e>
jmp    11c4 <main+0xa4>
movslq -0x44(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
movslq -0x44(%rbp),%rcx
movsbl -0x40(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11b1 <main+0x91>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11b6 <main+0x96>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    115d <main+0x3d>
mov    -0x44(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11e6 <main+0xc6>
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
xor    %eax,%eax
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
movzbl 0x1f(%rsp,%rcx,1),%edx
test   %dl,%dl
je     118a <main+0x6a>
xor    %esi,%esi
cmp    -0x1(%rsp,%rcx,1),%dl
sete   %sil
add    %esi,%eax
movzbl 0x20(%rsp,%rcx,1),%edx
test   %dl,%dl
je     118e <main+0x6e>
xor    %esi,%esi
cmp    (%rsp,%rcx,1),%dl
sete   %sil
add    %esi,%eax
add    $0x2,%rcx
cmp    $0x15,%rcx
jne    1150 <main+0x30>
mov    $0x14,%ecx
jmp    118e <main+0x6e>
add    $0xffffffffffffffff,%rcx
add    $0xffffffff,%eax
cmp    %eax,%ecx
lea    0xe94(%rip),%rax
lea    0xe77(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter two strings\0A\00"
@.str.1 = [6 x i8] c"%s %s\00"
@.str.2 = [19 x i8] c"strings are equal\0A\00"
@.str.3 = [23 x i8] c"Strings are not equal\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %9)
store i32 0, i32* %4
br label %11
11: ; preds = %39, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 20
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %14, %11
%22 = phi i1 [ false, %11 ], [ %20, %14 ]
br i1 %22, label %23, label %42
23: ; preds = %21
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %28, %33
br i1 %34, label %35, label %38
35: ; preds = %23
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %38
38: ; preds = %35, %23
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %11
42: ; preds = %21
%43 = load i32, i32* %4
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, 1
%46 = icmp eq i32 %43, %45
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %51
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%s %s\00"
@str = [18 x i8] c"Enter two strings\00"
@str.4 = [22 x i8] c"Strings are not equal\00"
@str.5 = [18 x i8] c"strings are equal\00"
define i32 @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 ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
br label %7
7: ; preds = %23, %0
%8 = phi i64 [ 0, %0 ], [ %29, %23 ]
%9 = phi i32 [ 0, %0 ], [ %28, %23 ]
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %8
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %7
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %8
%15 = load i8, i8* %14
%16 = icmp eq i8 %11, %15
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %9, %17
%19 = or i64 %8, 1
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %13
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %19
%25 = load i8, i8* %24
%26 = icmp eq i8 %21, %25
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %18, %27
%29 = add nuw nsw i64 %8, 2
%30 = icmp eq i64 %29, 20
br i1 %30, label %35, label %7
31: ; preds = %13, %7
%32 = phi i64 [ %8, %7 ], [ %19, %13 ]
%33 = phi i32 [ %9, %7 ], [ %18, %13 ]
%34 = trunc i64 %32 to i32
br label %35
35: ; preds = %23, %31
%36 = phi i32 [ %34, %31 ], [ 20, %23 ]
%37 = phi i32 [ %33, %31 ], [ %28, %23 ]
%38 = add nsw i32 %37, -1
%39 = icmp eq i32 %36, %38
%40 = select i1 %39, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0)
%41 = call i32 @puts(i8* dereferenceable(1) %40)
ret i32 0
}