#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*/ assert(int);
void set_pattern(char *buf, unsigned seed) {
  int i;
  unsigned *lbuf = (unsigned *)buf;
  assert(((long)buf & 3) == 0);
  for (i = 0; i < 16384 / 4; i++) {
    lbuf[i] = seed;
    if (seed & 1)
      seed = (seed >> 1) ^ 0x80000057;
    else
      seed >>= 1;
  }
}


x86 assembly (clang, -O0):
<set_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1000,-0x10(%rbp)
jge    11a0 <set_pattern+0x90>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1184 <set_pattern+0x74>
mov    -0xc(%rbp),%eax
shr    $0x1,%eax
xor    $0x80000057,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <set_pattern+0x7d>
mov    -0xc(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <set_pattern+0x82>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1147 <set_pattern+0x37>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pattern>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
test   $0x3,%bl
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %ebp,(%rbx,%rax,4)
mov    %ebp,%ecx
shr    %ecx
mov    %ecx,%edx
xor    $0x80000057,%edx
test   $0x1,%bpl
cmove  %ecx,%edx
mov    %edx,0x4(%rbx,%rax,4)
mov    %edx,%ecx
shr    %ecx
mov    %ecx,%ebp
xor    $0x80000057,%ebp
test   $0x1,%dl
cmove  %ecx,%ebp
add    $0x2,%rax
cmp    $0x1000,%rax
jne    1130 <set_pattern+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @set_pattern(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %6
%9 = load i8*, i8** %3
%10 = ptrtoint i8* %9 to i64
%11 = and i64 %10, 3
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
store i32 0, i32* %5
br label %15
15: ; preds = %35, %2
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 4096
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32*, i32** %6
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 %19, i32* %23
%24 = load i32, i32* %4
%25 = and i32 %24, 1
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %18
%28 = load i32, i32* %4
%29 = lshr i32 %28, 1
%30 = xor i32 %29, -2147483561
store i32 %30, i32* %4
br label %34
31: ; preds = %18
%32 = load i32, i32* %4
%33 = lshr i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %15
38: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @set_pattern(i8* %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = ptrtoint i8* %0 to i64
%5 = and i64 %4, 3
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
br label %9
9: ; preds = %9, %2
%10 = phi i64 [ 0, %2 ], [ %25, %9 ]
%11 = phi i32 [ %1, %2 ], [ %24, %9 ]
%12 = getelementptr inbounds i32, i32* %3, i64 %10
store i32 %11, i32* %12
%13 = and i32 %11, 1
%14 = icmp eq i32 %13, 0
%15 = lshr i32 %11, 1
%16 = xor i32 %15, -2147483561
%17 = select i1 %14, i32 %15, i32 %16
%18 = or i64 %10, 1
%19 = getelementptr inbounds i32, i32* %3, i64 %18
store i32 %17, i32* %19
%20 = and i32 %17, 1
%21 = icmp eq i32 %20, 0
%22 = lshr i32 %17, 1
%23 = xor i32 %22, -2147483561
%24 = select i1 %21, i32 %22, i32 %23
%25 = add nuw nsw i64 %10, 2
%26 = icmp eq i64 %25, 4096
br i1 %26, label %27, label %9
27: ; preds = %9
ret void
}