int main() {
  int i;
  char c, input1[1000], input2[1000];
  printf("Type two strings seperated by a newline.\n");
  for (i = 0; (c = getchar()) != '\n' && i < 1000 - 1; i++)
    input1[i] = c;
  input1[i] = '\0';
  for (i = 0; (c = getchar()) != '\n' && i < 1000 - 1; i++)
    input2[i] = c;
  input2[i] = '\0';
  i = (any(input1, input2)) + 1;
  printf("The first location in string 1 where any char from string 2"
         " occurs is : %d \n(0 if no match)\n",
         i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x7f1(%rbp)
je     1185 <main+0x55>
cmpl   $0x3e7,-0x8(%rbp)
setl   %al
mov    %al,-0x7f1(%rbp)
mov    -0x7f1(%rbp),%al
test   $0x1,%al
jne    1198 <main+0x68>
jmp    11b4 <main+0x84>
mov    -0x9(%rbp),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <main+0x27>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x7f2(%rbp)
je     11f5 <main+0xc5>
cmpl   $0x3e7,-0x8(%rbp)
setl   %al
mov    %al,-0x7f2(%rbp)
mov    -0x7f2(%rbp),%al
test   $0x1,%al
jne    1208 <main+0xd8>
jmp    1224 <main+0xf4>
mov    -0x9(%rbp),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x7f0(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <main+0x97>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x7f0(%rbp,%rax,1)
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
mov    $0x0,%al
call   1050 <any@plt>
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1192 <main+0x52>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %al,0x3f0(%rsp,%rbx,1)
lea    0x1(%rbx),%r14
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1192 <main+0x52>
cmp    $0x3e6,%rbx
mov    %r14,%rbx
jb     1170 <main+0x30>
movb   $0x0,0x3f0(%rsp,%r14,1)
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11ce <main+0x8e>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %al,(%rsp,%rbx,1)
lea    0x1(%rbx),%r14
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11ce <main+0x8e>
cmp    $0x3e6,%rbx
mov    %r14,%rbx
jb     11b0 <main+0x70>
movb   $0x0,(%rsp,%r14,1)
lea    0x3f0(%rsp),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <any@plt>
lea    0x1(%rax),%esi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Type two strings seperated by a newline.\0A\00"
@.str.1 = [93 x i8] c"The first location in string 1 where any char from string 2 occurs is : %d \0A(0 if no match)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %22, %0
%8 = call i32 (...) @getchar()
%9 = trunc i32 %8 to i8
store i8 %9, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 999
br label %15
15: ; preds = %12, %7
%16 = phi i1 [ false, %7 ], [ %14, %12 ]
br i1 %16, label %17, label %25
17: ; preds = %15
%18 = load i8, i8* %3
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %17
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %7
25: ; preds = %15
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %27
store i8 0, i8* %28
store i32 0, i32* %2
br label %29
29: ; preds = %44, %25
%30 = call i32 (...) @getchar()
%31 = trunc i32 %30 to i8
store i8 %31, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i32, i32* %2
%36 = icmp slt i32 %35, 999
br label %37
37: ; preds = %34, %29
%38 = phi i1 [ false, %29 ], [ %36, %34 ]
br i1 %38, label %39, label %47
39: ; preds = %37
%40 = load i8, i8* %3
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %39
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %29
47: ; preds = %37
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %49
store i8 0, i8* %50
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%53 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @any to i32 (i8*, i8*, ...)*)(i8* %51, i8* %52)
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
%55 = load i32, i32* %2
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [93 x i8] c"The first location in string 1 where any char from string 2 occurs is : %d \0A(0 if no match)\0A\00"
@str = [41 x i8] c"Type two strings seperated by a newline.\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @getchar()
%7 = and i32 %6, 255
%8 = icmp eq i32 %7, 10
br i1 %8, label %20, label %9
9: ; preds = %0, %9
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = phi i32 [ %15, %9 ], [ %6, %0 ]
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %10
store i8 %12, i8* %13
%14 = add nuw nsw i64 %10, 1
%15 = tail call i32 (...) @getchar()
%16 = and i32 %15, 255
%17 = icmp ne i32 %16, 10
%18 = icmp ult i64 %10, 998
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %9, label %20
20: ; preds = %9, %0
%21 = phi i64 [ 0, %0 ], [ %14, %9 ]
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %21
store i8 0, i8* %22
%23 = tail call i32 (...) @getchar()
%24 = and i32 %23, 255
%25 = icmp eq i32 %24, 10
br i1 %25, label %37, label %26
26: ; preds = %20, %26
%27 = phi i64 [ %31, %26 ], [ 0, %20 ]
%28 = phi i32 [ %32, %26 ], [ %23, %20 ]
%29 = trunc i32 %28 to i8
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %27
store i8 %29, i8* %30
%31 = add nuw nsw i64 %27, 1
%32 = tail call i32 (...) @getchar()
%33 = and i32 %32, 255
%34 = icmp ne i32 %33, 10
%35 = icmp ult i64 %27, 998
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %26, label %37
37: ; preds = %26, %20
%38 = phi i64 [ 0, %20 ], [ %31, %26 ]
%39 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @any to i32 (i8*, i8*, ...)*)(i8* %3, i8* %4)
%41 = add nsw i32 %40, 1
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0), i32 %41)
ret i32 0
}