#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 *);
void markblock(volatile void *ptr, size_t size, unsigned bias, int doprint) {
  size_t n, i;
  unsigned long *pl;
  unsigned long val;
  pl = (unsigned long *)ptr;
  n = size / sizeof(unsigned long);
  for (i = 0; i < n; i++) {
    val = ((unsigned long)i ^ (unsigned long)bias);
    pl[i] = val;
    if (doprint && (i % 64 == 63)) {
      printf(".");
    }
  }
  if (doprint) {
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<markblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x3,%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ac <markblock+0x9c>
mov    -0x28(%rbp),%rax
mov    -0x14(%rbp),%ecx
xor    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpl   $0x0,-0x18(%rbp)
je     1196 <markblock+0x86>
mov    -0x28(%rbp),%rax
and    $0x3f,%rax
cmp    $0x3f,%rax
jne    1196 <markblock+0x86>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
jmp    119b <markblock+0x8b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1142 <markblock+0x32>
cmpl   $0x0,-0x18(%rbp)
je     11c2 <markblock+0xb2>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<markblock>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
cmp    $0x8,%rsi
jae    1138 <markblock+0x28>
test   %r14d,%r14d
je     117e <markblock+0x6e>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %rsi,%rbx
mov    %rdi,%r15
shr    $0x3,%rbx
mov    %edx,%r12d
xor    %ebp,%ebp
jmp    1159 <markblock+0x49>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1121 <markblock+0x11>
mov    %rbp,%rax
xor    %r12,%rax
mov    %rax,(%r15,%rbp,8)
test   %r14d,%r14d
je     1150 <markblock+0x40>
mov    %ebp,%eax
and    $0x3f,%eax
cmp    $0x3f,%eax
jne    1150 <markblock+0x40>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    1150 <markblock+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @markblock(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i8*, i8** %5
%14 = bitcast i8* %13 to i64*
store i64* %14, i64** %11
%15 = load i64, i64* %6
%16 = udiv i64 %15, 8
store i64 %16, i64* %9
store i64 0, i64* %10
br label %17
17: ; preds = %39, %4
%18 = load i64, i64* %10
%19 = load i64, i64* %9
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i64, i64* %10
%23 = load i32, i32* %7
%24 = zext i32 %23 to i64
%25 = xor i64 %22, %24
store i64 %25, i64* %12
%26 = load i64, i64* %12
%27 = load i64*, i64** %11
%28 = load i64, i64* %10
%29 = getelementptr inbounds i64, i64* %27, i64 %28
store i64 %26, i64* %29
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %21
%33 = load i64, i64* %10
%34 = urem i64 %33, 64
%35 = icmp eq i64 %34, 63
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %38
38: ; preds = %36, %32, %21
br label %39
39: ; preds = %38
%40 = load i64, i64* %10
%41 = add i64 %40, 1
store i64 %41, i64* %10
br label %17
42: ; preds = %17
%43 = load i32, i32* %8
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %45, %42
ret void
}

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