#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 *);
int strlen(char *);
int main() {
  char str1[100] = {0};
  char str2[100] = {0};
  int i = 0, j = 0;
  printf("Enter str: ");
  scanf(" %s", str1);
  printf("str1 is : %s\n", str1);
  printf("Enter str: ");
  scanf(" %s", str2);
  printf("str2 is : %s\n", str2);
  for (i = 0; i < strlen(str2); i++) {
    for (j = 0; j < strlen(str1); j++) {
      if (str2[i] == str1[j]) {
        printf(" %c %d \n", str1[j], j + 1);
        return 0;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xec(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xec(%rbp),%eax
cmp    %ecx,%eax
jge    12d4 <main+0x194>
movl   $0x0,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
mov    %eax,-0xf0(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xf0(%rbp),%eax
cmp    %ecx,%eax
jge    12bb <main+0x17b>
movslq -0xe4(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
movslq -0xe8(%rbp),%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    12a2 <main+0x162>
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
mov    -0xe8(%rbp),%edx
add    $0x1,%edx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12db <main+0x19b>
jmp    12a7 <main+0x167>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    122b <main+0xeb>
jmp    12c0 <main+0x180>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    11f9 <main+0xb9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe5b(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe56(%rip),%r15
lea    0x70(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe28(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1284 <main+0x154>
xor    %r12d,%r12d
lea    0x70(%rsp),%r15
mov    %rsp,%r14
jmp    1233 <main+0x103>
nopl   0x0(%rax)
add    $0x1,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r12
jge    1284 <main+0x154>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1220 <main+0xf0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%r12,1),%esi
cmp    0x70(%rsp,%rbx,1),%sil
je     1271 <main+0x141>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1250 <main+0x120>
jmp    1220 <main+0xf0>
add    $0x1,%ebx
lea    0xdb1(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Enter str: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [14 x i8] c"str1 is : %s\0A\00"
@.str.3 = [14 x i8] c"str2 is : %s\0A\00"
@.str.4 = [9 x i8] c" %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 i32
store i32 0, i32* %1
%6 = bitcast [100 x i8]* %2 to i8*
%7 = bitcast [100 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %16)
store i32 0, i32* %4
br label %18
18: ; preds = %55, %0
%19 = load i32, i32* %4
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %58
23: ; preds = %18
store i32 0, i32* %5
br label %24
24: ; preds = %51, %23
%25 = load i32, i32* %5
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %54
29: ; preds = %24
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %34, %39
br i1 %40, label %41, label %50
41: ; preds = %29
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %48)
store i32 0, i32* %1
br label %59
50: ; preds = %29
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %24
54: ; preds = %24
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %18
58: ; preds = %18
store i32 0, i32* %1
br label %59
59: ; preds = %58, %41
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [12 x i8] c"Enter str: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [14 x i8] c"str1 is : %s\0A\00"
@.str.3 = [14 x i8] c"str2 is : %s\0A\00"
@.str.4 = [9 x i8] c" %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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%11 = call i32 @strlen(i8* %4)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %0, %35
%14 = phi i64 [ %36, %35 ], [ 0, %0 ]
%15 = call i32 @strlen(i8* %3)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %14
br label %19
19: ; preds = %17, %30
%20 = phi i64 [ 0, %17 ], [ %31, %30 ]
%21 = load i8, i8* %18
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %20
%23 = load i8, i8* %22
%24 = icmp eq i8 %21, %23
br i1 %24, label %25, label %30
25: ; preds = %19
%26 = trunc i64 %20 to i32
%27 = sext i8 %21 to i32
%28 = add nuw nsw i32 %26, 1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %28)
br label %40
30: ; preds = %19
%31 = add nuw nsw i64 %20, 1
%32 = call i32 @strlen(i8* %3)
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %19, label %35
35: ; preds = %30, %13
%36 = add nuw nsw i64 %14, 1
%37 = call i32 @strlen(i8* %4)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %36, %38
br i1 %39, label %13, label %40
40: ; preds = %35, %0, %25
ret i32 0
}