#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 materialize_buf(char *buf, int size) {
  int j;
  assert(((long)buf) % 4096 == 0);
  assert(size % 4096 == 0);
  for (j = 0; j < size; j += 4096)
    buf[j] = 0;
}


x86 assembly (clang, -O0):
<materialize_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x1000,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <materialize_buf+0x78>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x10(%rbp)
jmp    1160 <materialize_buf+0x50>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<materialize_buf>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
test   $0xfff,%ebx
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   $0xfff,%ebp
sete   %dil
call   1030 <assert@plt>
test   %ebp,%ebp
jle    11e0 <materialize_buf+0xd0>
mov    %ebp,%edx
add    $0xffffffffffffffff,%rdx
mov    %rdx,%rcx
shr    $0xc,%rcx
add    $0x1,%rcx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7000,%rdx
jae    1165 <materialize_buf+0x55>
xor    %edx,%edx
jmp    11b9 <materialize_buf+0xa9>
and    $0xfffffffffffffff8,%rcx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rbx,%rdx,1)
movb   $0x0,0x1000(%rbx,%rdx,1)
movb   $0x0,0x2000(%rbx,%rdx,1)
movb   $0x0,0x3000(%rbx,%rdx,1)
movb   $0x0,0x4000(%rbx,%rdx,1)
movb   $0x0,0x5000(%rbx,%rdx,1)
movb   $0x0,0x6000(%rbx,%rdx,1)
movb   $0x0,0x7000(%rbx,%rdx,1)
add    $0x8000,%rdx
add    $0xfffffffffffffff8,%rcx
jne    1170 <materialize_buf+0x60>
test   %rax,%rax
je     11e0 <materialize_buf+0xd0>
add    %rdx,%rbx
shl    $0xc,%rax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movb   $0x0,(%rbx,%rcx,1)
add    $0x1000,%rcx
cmp    %rcx,%rax
jne    11d0 <materialize_buf+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @materialize_buf(i8* %0, i32 %1) {
%3 = ptrtoint i8* %0 to i64
%4 = and i64 %3, 4095
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = and i32 %1, 4095
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %53
13: ; preds = %2
%14 = zext i32 %1 to i64
%15 = add nsw i64 %14, -1
%16 = lshr i64 %15, 12
%17 = add nuw nsw i64 %16, 1
%18 = and i64 %17, 7
%19 = icmp ult i64 %15, 28672
br i1 %19, label %43, label %20
20: ; preds = %13
%21 = and i64 %17, 9007199254740984
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %40, %22 ]
%24 = phi i64 [ 0, %20 ], [ %41, %22 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %25
%26 = or i64 %23, 4096
%27 = getelementptr inbounds i8, i8* %0, i64 %26
store i8 0, i8* %27
%28 = or i64 %23, 8192
%29 = getelementptr inbounds i8, i8* %0, i64 %28
store i8 0, i8* %29
%30 = or i64 %23, 12288
%31 = getelementptr inbounds i8, i8* %0, i64 %30
store i8 0, i8* %31
%32 = or i64 %23, 16384
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
%34 = or i64 %23, 20480
%35 = getelementptr inbounds i8, i8* %0, i64 %34
store i8 0, i8* %35
%36 = or i64 %23, 24576
%37 = getelementptr inbounds i8, i8* %0, i64 %36
store i8 0, i8* %37
%38 = or i64 %23, 28672
%39 = getelementptr inbounds i8, i8* %0, i64 %38
store i8 0, i8* %39
%40 = add nuw nsw i64 %23, 32768
%41 = add i64 %24, 8
%42 = icmp eq i64 %41, %21
br i1 %42, label %43, label %22
43: ; preds = %22, %13
%44 = phi i64 [ 0, %13 ], [ %40, %22 ]
%45 = icmp eq i64 %18, 0
br i1 %45, label %53, label %46
46: ; preds = %43, %46
%47 = phi i64 [ %50, %46 ], [ %44, %43 ]
%48 = phi i64 [ %51, %46 ], [ 0, %43 ]
%49 = getelementptr inbounds i8, i8* %0, i64 %47
store i8 0, i8* %49
%50 = add nuw nsw i64 %47, 4096
%51 = add i64 %48, 1
%52 = icmp eq i64 %51, %18
br i1 %52, label %53, label %46
53: ; preds = %43, %46, %2
ret void
}