#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);
int wordPattern(char *, char *);
int main() {
  char pattern[] = "aabb";
  char str1[] = "dog dog cat cat";
  char str2[] = "dog cat cat dog";
  printf("%d\n", wordPattern(pattern, str1));
  printf("%d\n", wordPattern(pattern, str2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec2(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xebf(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x9(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <wordPattern@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
lea    -0x9(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <wordPattern@plt>
mov    %eax,%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x62626161,0x8(%rsp)
62
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x8(%rsp),%r14
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1040 <wordPattern@plt>
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1040 <wordPattern@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.pattern = [5 x i8] c"aabb\00"
@__const.main.str1 = [16 x i8] c"dog dog cat cat\00"
@__const.main.str2 = [16 x i8] c"dog cat cat dog\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
store i32 0, i32* %1
%5 = bitcast [5 x i8]* %2 to i8*
%6 = bitcast [16 x i8]* %3 to i8*
%7 = bitcast [16 x i8]* %4 to i8*
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%10 = call i32 @wordPattern(i8* %8, i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%14 = call i32 @wordPattern(i8* %12, i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.pattern = [5 x i8] c"aabb\00"
@__const.main.str1 = [16 x i8] c"dog dog cat cat\00"
@__const.main.str2 = [16 x i8] c"dog cat cat dog\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [16 x i8]
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = call i32 @wordPattern(i8* %4, i8* %5)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @wordPattern(i8* %4, i8* %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}