#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[10];
  char str1[10];
  int i;
  i = 0;
  printf("enter string 1-");
  gets(str);
  printf("enter string 2-");
  gets(str1);
  while ((str[i] == str1[i]) && str[i] != '\0' && str1[i] != '\0') {
    i++;
  }
  if (str[i] == '\0' && str1[i] == '\0')
    printf("same string");
  else
    printf("not same");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
call   1040 <gets@plt>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1040 <gets@plt>
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%ecx
movslq -0x1c(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x1d(%rbp)
jne    11a8 <main+0x88>
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     11a8 <main+0x88>
movslq -0x1c(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11b8 <main+0x98>
jmp    11c6 <main+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1160 <main+0x40>
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11fb <main+0xdb>
movslq -0x1c(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11fb <main+0xdb>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xe(%rsp),%rdi
call   1040 <gets@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0x4(%rsp),%rdi
call   1040 <gets@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0xe(%rsp,%rax,1),%ecx
movzbl 0x4(%rsp,%rax,1),%edx
test   %dl,%dl
je     117a <main+0x5a>
test   %cl,%cl
je     117a <main+0x5a>
add    $0x1,%rax
cmp    %dl,%cl
je     1160 <main+0x40>
lea    0xe9f(%rip),%rax
lea    0xea4(%rip),%rdi
or     %dl,%cl
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"enter string 1-\00"
@.str.1 = [16 x i8] c"enter string 2-\00"
@.str.2 = [12 x i8] c"same string\00"
@.str.3 = [9 x i8] c"not same\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 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 ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ %20, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = icmp ne i8 %12, %14
%16 = icmp eq i8 %12, 0
%17 = or i1 %16, %15
%18 = icmp eq i8 %14, 0
%19 = or i1 %18, %17
%20 = add nuw i64 %10, 1
br i1 %19, label %21, label %9
21: ; preds = %9
%22 = select i1 %16, i1 %18, i1 false
%23 = select i1 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%24 = call i32 @printf(i8* dereferenceable(1) %23)
ret i32 0
}