#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 strlen(char *);
int numJewelsInStones(char *J, char *S) {
  int cnt = 0;
  unsigned char arr['z' + 1] = {0};
  for (int i = 0; i < strlen(S); i++) {
    arr[S[i]]++;
  }
  for (int i = 0; i < strlen(J); i++) {
    cnt += arr[J[i]];
  }
  return cnt;
}


x86 assembly (clang, -O0):
<numJewelsInStones>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x7b,%edx
call   1040 <memset@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cmp    %ecx,%eax
jge    11b1 <numJewelsInStones+0x91>
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsbq (%rax,%rcx,1),%rax
mov    -0x90(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1157 <numJewelsInStones+0x37>
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
cmp    %ecx,%eax
jge    1212 <numJewelsInStones+0xf2>
mov    -0x8(%rbp),%rax
movslq -0x98(%rbp),%rcx
movsbq (%rax,%rcx,1),%rax
movzbl -0x90(%rbp,%rax,1),%eax
ff
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11bb <numJewelsInStones+0x9b>
mov    -0x14(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numJewelsInStones>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movups %xmm0,0x6b(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    117c <numJewelsInStones+0x6c>
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbq (%rbx,%rbp,1),%rax
addb   $0x1,(%rsp,%rax,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1160 <numJewelsInStones+0x50>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b0 <numJewelsInStones+0xa0>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
movsbq (%r14,%rbx,1),%rax
movzbl (%rsp,%rax,1),%eax
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1190 <numJewelsInStones+0x80>
jmp    11b2 <numJewelsInStones+0xa2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @numJewelsInStones(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [123 x i8]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%9 = bitcast [123 x i8]* %6 to i8*
store i32 0, i32* %7
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %7
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %28
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i64
%22 = getelementptr inbounds [123 x i8], [123 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = add i8 %23, 1
store i8 %24, i8* %22
br label %25
25: ; preds = %15
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %10
28: ; preds = %10
store i32 0, i32* %8
br label %29
29: ; preds = %46, %28
%30 = load i32, i32* %8
%31 = load i8*, i8** %3
%32 = call i32 @strlen(i8* %31)
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %49
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i64
%41 = getelementptr inbounds [123 x i8], [123 x i8]* %6, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = load i32, i32* %5
%45 = add nsw i32 %44, %43
store i32 %45, i32* %5
br label %46
46: ; preds = %34
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %29
49: ; preds = %29
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
define i32 @numJewelsInStones(i8* %0, i8* %1) {
%3 = alloca [123 x i8]
%4 = getelementptr inbounds [123 x i8], [123 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %10, %2
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %24, label %22
10: ; preds = %2, %10
%11 = phi i64 [ %18, %10 ], [ 0, %2 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i64
%15 = getelementptr inbounds [123 x i8], [123 x i8]* %3, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = add i8 %16, 1
store i8 %17, i8* %15
%18 = add nuw nsw i64 %11, 1
%19 = tail call i32 @strlen(i8* %1)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %10, label %7
22: ; preds = %24, %7
%23 = phi i32 [ 0, %7 ], [ %33, %24 ]
ret i32 %23
24: ; preds = %7, %24
%25 = phi i64 [ %34, %24 ], [ 0, %7 ]
%26 = phi i32 [ %33, %24 ], [ 0, %7 ]
%27 = getelementptr inbounds i8, i8* %0, i64 %25
%28 = load i8, i8* %27
%29 = sext i8 %28 to i64
%30 = getelementptr inbounds [123 x i8], [123 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = add nuw nsw i32 %26, %32
%34 = add nuw nsw i64 %25, 1
%35 = tail call i32 @strlen(i8* %0)
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %24, label %22
}