#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(void) {
  char str1[100], str2[100];
  int len1, len2, flag = 0;
  printf("Enter first string: ");
  gets(str1);
  printf("Enter second string: ");
  gets(str2);
  len1 = strlen(str1);
  len2 = strlen(str2);
  if (len1 != len2) {
    printf("The two string is not the same.");
  } else if (len1 == len2) {
    for (size_t i = 0; i < len1; i++) {
      if (str1[i] != str2[i]) {
        flag = 0;
      } else
        flag = 1;
    }
  }
  if (flag == 0) {
    printf("The two string is not the same.");
  } else
    printf("The two string is the same.");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xec(%rbp)
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <gets@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xe4(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xe8(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
je     11bd <main+0x8d>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
jmp    1253 <main+0x123>
mov    -0xe4(%rbp),%eax
cmp    -0xe8(%rbp),%eax
jne    124e <main+0x11e>
movq   $0x0,-0xf8(%rbp)
mov    -0xf8(%rbp),%rax
movslq -0xe4(%rbp),%rcx
cmp    %rcx,%rax
jae    1249 <main+0x119>
mov    -0xf8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    -0xf8(%rbp),%rcx
movsbl -0xe0(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     1223 <main+0xf3>
movl   $0x0,-0xec(%rbp)
jmp    122d <main+0xfd>
movl   $0x1,-0xec(%rbp)
jmp    1232 <main+0x102>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    11da <main+0xaa>
jmp    124e <main+0x11e>
jmp    1253 <main+0x123>
cmpl   $0x0,-0xec(%rbp)
jne    1271 <main+0x141>
lea    0xdc4(%rip),%rdi
call   1040 <printf@plt>
jmp    127d <main+0x14d>
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jne    11a3 <main+0x73>
test   %ebx,%ebx
je     11b4 <main+0x84>
movslq %ebx,%rax
mov    0x6f(%rsp,%rax,1),%cl
cmp    -0x1(%rsp,%rax,1),%cl
lea    0xeb5(%rip),%rax
lea    0xe8e(%rip),%rbx
cmove  %rax,%rbx
jmp    11bb <main+0x8b>
lea    0xe81(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
jmp    11bb <main+0x8b>
lea    0xe70(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter first string: \00"
@.str.1 = [22 x i8] c"Enter second string: \00"
@.str.2 = [32 x i8] c"The two string is not the same.\00"
@.str.3 = [28 x i8] c"The two string is the same.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %4
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %51
23: ; preds = %0
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %50
27: ; preds = %23
store i64 0, i64* %7
br label %28
28: ; preds = %46, %27
%29 = load i64, i64* %7
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = icmp ult i64 %29, %31
br i1 %32, label %33, label %49
33: ; preds = %28
%34 = load i64, i64* %7
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i64, i64* %7
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %37, %41
br i1 %42, label %43, label %44
43: ; preds = %33
store i32 0, i32* %6
br label %45
44: ; preds = %33
store i32 1, i32* %6
br label %45
45: ; preds = %44, %43
br label %46
46: ; preds = %45
%47 = load i64, i64* %7
%48 = add i64 %47, 1
store i64 %48, i64* %7
br label %28
49: ; preds = %28
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50, %21
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %58
56: ; preds = %51
%57 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter first string: \00"
@.str.1 = [22 x i8] c"Enter second string: \00"
@.str.2 = [32 x i8] c"The two string is not the same.\00"
@.str.3 = [28 x i8] c"The two string is the same.\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 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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 eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = icmp eq i32 %9, 0
br i1 %13, label %25, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %25
16: ; preds = %12
%17 = sext i32 %9 to i64
%18 = add nsw i64 %17, -1
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%22 = load i8, i8* %21
%23 = icmp eq i8 %20, %22
%24 = select i1 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0)
br label %25
25: ; preds = %16, %14, %12
%26 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %14 ], [ %24, %16 ]
%27 = call i32 @printf(i8* dereferenceable(1) %26)
ret i32 0
}