#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 any(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char a[6] = {'a', 'x', 'c', 'c', 'r', 0};
  char b[3] = {'d', 'x', 0};
  int result;
  result = 0;
  printf("Here are the chars I am searching:\t\t%s\n", a);
  printf("I am looking for any occurance of these:\t%s\n\n", b);
  result = any(a, b);
  if (result != -1)
    printf("Found char in element %d.\n\n", result + 1);
  else
    printf("No matching chars found.\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0xd(%rbp)
mov    0xeb4(%rip),%al
mov    %al,-0xb(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xa(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    -0xd(%rbp),%rsi
call   1040 <any@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11b5 <main+0x95>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <main+0xa3>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movw   $0x72,0x14(%rsp)
movl   $0x63637861,0x10(%rsp)
63
movb   $0x0,0xe(%rsp)
movw   $0x7864,0xc(%rsp)
lea    0xeb0(%rip),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <any@plt>
cmp    $0xffffffff,%eax
je     11a3 <main+0x73>
add    $0x1,%eax
lea    0xec7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11af <main+0x7f>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [6 x i8] c"axccr\00"
@__const.main.b = [3 x i8] c"dx\00"
@.str = [40 x i8] c"Here are the chars I am searching:\09\09%s\0A\00"
@.str.1 = [46 x i8] c"I am looking for any occurance of these:\09%s\0A\0A\00"
@.str.2 = [28 x i8] c"Found char in element %d.\0A\0A\00"
@.str.3 = [27 x i8] c"No matching chars found.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [3 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [6 x i8]* %2 to i8*
%6 = bitcast [3 x i8]* %3 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%13 = call i32 @any(i8* %11, i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [6 x i8] c"axccr\00"
@__const.main.b = [3 x i8] c"dx\00"
@.str = [40 x i8] c"Here are the chars I am searching:\09\09%s\0A\00"
@.str.1 = [46 x i8] c"I am looking for any occurance of these:\09%s\0A\0A\00"
@.str.2 = [28 x i8] c"Found char in element %d.\0A\0A\00"
@str = [26 x i8] c"No matching chars found.\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 @any(i8* %3, i8* %4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = add nuw nsw i32 %7, 1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
ret i32 0
}