#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 main() {
  char orig_str[100] = {0};
  char match_str[100] = {0};
  int i, j;
  printf("Enter orig_str: ");
  scanf(" %s", orig_str);
  printf("orig_str : %s\n", orig_str);
  printf("Enter string(whose chars)to match\n");
  scanf(" %s", match_str);
  for (i = 0; match_str[i] != '\0'; i++) {
    for (j = 0; orig_str[j] != '\0'; j++) {
      if (match_str[i] == orig_str[j]) {
        printf("location : %d\n", j + 1);
        goto out;
      }
    }
  }
out:
  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   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1268 <main+0x138>
movl   $0x0,-0xe8(%rbp)
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     124f <main+0x11f>
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    1236 <main+0x106>
mov    -0xe8(%rbp),%esi
add    $0x1,%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126d <main+0x13d>
jmp    123b <main+0x10b>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11e2 <main+0xb2>
jmp    1254 <main+0x124>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    11c0 <main+0x90>
jmp    126d <main+0x13d>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
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    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%r14
lea    0x70(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1241 <main+0x111>
mov    0x70(%rsp),%bl
xor    %edx,%edx
jmp    120c <main+0xdc>
cs nopw 0x0(%rax,%rax,1)
mov    0x1(%rsp,%rdx,1),%al
add    $0x1,%rdx
test   %al,%al
je     1241 <main+0x111>
test   %bl,%bl
je     1200 <main+0xd0>
mov    $0x1,%esi
mov    %ebx,%ecx
nopw   0x0(%rax,%rax,1)
cmp    %cl,%al
je     1233 <main+0x103>
movzbl 0x70(%rsp,%rsi,1),%ecx
add    $0x1,%rsi
test   %cl,%cl
jne    1220 <main+0xf0>
jmp    1200 <main+0xd0>
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

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

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