#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 */
char *Allocate(int, int);
int /*<<< orphan*/ CheckBuf(char *, int);
int /*<<< orphan*/ CopyWithXmmFault(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
void XmmCheck() {
  char *p1;
  char *p2;
  int i;
  p1 = Allocate(32, 16);
  p2 = Allocate(32, 16);
  memset(p2, 0, 32);
  for (i = 0; i < 32; i++)
    p1[i] = "abcdefghijklmnopqrstuvwxyz"[i % 26];
  CopyWithXmmFault(p2, p1, 32);
  CheckBuf(p2, 32);
}


x86 assembly (clang, -O0):
<XmmCheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x20,%edi
mov    $0x10,%esi
call   1050 <Allocate@plt>
mov    %rax,-0x8(%rbp)
mov    $0x20,%edi
mov    $0x10,%esi
call   1050 <Allocate@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11c0 <XmmCheck+0x80>
mov    -0x14(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xe5c(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <XmmCheck+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x20,%edx
call   1030 <CopyWithXmmFault@plt>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1060 <CheckBuf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XmmCheck>:
push   %r15
push   %r14
push   %rbx
mov    $0x20,%edi
mov    $0x10,%esi
call   1050 <Allocate@plt>
mov    %rax,%r15
mov    $0x20,%edi
mov    $0x10,%esi
call   1050 <Allocate@plt>
mov    %rax,%r14
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
movabs $0x4ec4ec4ec4ec4ec5,%rcx
ec c4 4e
lea    0xe75(%rip),%rsi
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
mul    %rcx
shr    $0x3,%rdx
imul   $0xffffffffffffffe6,%rdx,%rax
add    %rsi,%rax
movzwl (%rbx,%rax,1),%eax
mov    %ax,(%r15,%rbx,1)
add    $0x2,%rbx
cmp    $0x20,%rbx
jne    1190 <XmmCheck+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x20,%edx
call   1030 <CopyWithXmmFault@plt>
mov    %r14,%rdi
mov    $0x20,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <CheckBuf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
define void @XmmCheck() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = call i8* @Allocate(i32 32, i32 16)
store i8* %4, i8** %1
%5 = call i8* @Allocate(i32 32, i32 16)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @memset(i8* %6, i32 0, i32 32)
store i32 0, i32* %3
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 26
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [27 x i8], [27 x i8]* @.str, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = load i8*, i8** %1
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %11
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %8
24: ; preds = %8
%25 = load i8*, i8** %2
%26 = load i8*, i8** %1
%27 = call i32 @CopyWithXmmFault(i8* %25, i8* %26, i32 32)
%28 = load i8*, i8** %2
%29 = call i32 @CheckBuf(i8* %28, i32 32)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
define void @XmmCheck() {
%1 = tail call i8* @Allocate(i32 32, i32 16)
%2 = tail call i8* @Allocate(i32 32, i32 16)
%3 = tail call i32 @memset(i8* %2, i32 0, i32 32)
br label %4
4: ; preds = %4, %0
%5 = phi i64 [ 0, %0 ], [ %19, %4 ]
%6 = trunc i64 %5 to i8
%7 = urem i8 %6, 26
%8 = zext i8 %7 to i64
%9 = getelementptr inbounds [27 x i8], [27 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %1, i64 %5
store i8 %10, i8* %11
%12 = or i64 %5, 1
%13 = trunc i64 %12 to i8
%14 = urem i8 %13, 26
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [27 x i8], [27 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %17, i8* %18
%19 = add nuw nsw i64 %5, 2
%20 = icmp eq i64 %19, 32
br i1 %20, label %21, label %4
21: ; preds = %4
%22 = tail call i32 @CopyWithXmmFault(i8* %2, i8* %1, i32 32)
%23 = tail call i32 @CheckBuf(i8* %2, i32 32)
ret void
}