#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 rand();
int /*<<< orphan*/ srand(int);
void touch_dedup(char *i, int size) {
  register int x;
  register int *ip;
  ip = (int *)i;
  srand(0x2719362);
  for (x = 0; x < size / sizeof(int); 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    $0x2,%rcx
cmp    %rcx,%rax
jae    1186 <touch_dedup+0x66>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%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    $0x4,%ebp
jb     1164 <touch_dedup+0x44>
movslq %ebp,%rax
shr    $0x2,%rax
cmp    $0x2,%rax
mov    $0x1,%ebp
cmovae %rax,%rbp
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,(%r14,%rbx,4)
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 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 = 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, 4
%16 = icmp ult i64 %12, %15
br i1 %16, label %17, label %25
17: ; preds = %10
%18 = call i32 (...) @rand()
%19 = load i32*, i32** %6
store i32 %18, i32* %19
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %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, 4
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = sext i32 %1 to i64
%7 = lshr i64 %6, 2
%8 = bitcast i8* %0 to i32*
%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 i32* [ %8, %5 ], [ %14, %10 ]
%13 = tail call i32 (...) @rand()
store i32 %13, i32* %12
%14 = getelementptr inbounds i32, i32* %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
}