#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 */
long rand();
int /*<<< orphan*/ srand(int);
void touch_dedup(char *i, int size) {
  register int x;
  register long *ip;
  ip = (long *)i;
  srand(0x2719362);
  for (x = 0; x < size / sizeof(long); x++) {
    *ip = rand();
    ip++;
  }
}


x86 assembly (clang, -O0):
<touch_dedup>:
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    $0x2719362,%edi
call   1030 <srand@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movslq -0xc(%rbp),%rcx
shr    $0x3,%rcx
cmp    %rcx,%rax
jae    1188 <touch_dedup+0x68>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <touch_dedup+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touch_dedup>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x2719362,%edi
call   1030 <srand@plt>
cmp    $0x8,%ebp
jb     1164 <touch_dedup+0x44>
movslq %ebp,%rax
shr    $0x3,%rax
cmp    $0x2,%rax
mov    $0x1,%ebp
cmovae %rax,%rbp
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <touch_dedup+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @touch_dedup(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i64*
store i64* %8, i64** %6
%9 = call i32 @srand(i32 40997730)
store i32 0, i32* %5
br label %10
10: ; preds = %22, %2
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = udiv i64 %14, 8
%16 = icmp ult i64 %12, %15
br i1 %16, label %17, label %25
17: ; preds = %10
%18 = call i64 (...) @rand()
%19 = load i64*, i64** %6
store i64 %18, i64* %19
%20 = load i64*, i64** %6
%21 = getelementptr inbounds i64, i64* %20, i32 1
store i64* %21, i64** %6
br label %22
22: ; preds = %17
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @touch_dedup(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 @srand(i32 40997730)
%4 = icmp ult i32 %1, 8
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = sext i32 %1 to i64
%7 = lshr i64 %6, 3
%8 = bitcast i8* %0 to i64*
%9 = call i64 @llvm.umax.i64(i64 %7, i64 1)
br label %10
10: ; preds = %5, %10
%11 = phi i64 [ 0, %5 ], [ %15, %10 ]
%12 = phi i64* [ %8, %5 ], [ %14, %10 ]
%13 = tail call i64 (...) @rand()
store i64 %13, i64* %12
%14 = getelementptr inbounds i64, i64* %12, i64 1
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %2
ret void
}