#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*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int test_pval(int, int, int);
void test_all_pvals(int *pvals, int *collisions, int num, int num_runs,
                    int len) {
  int i;
  memset(collisions, 0, num);
  for (i = 0; i < num; i++) {
    collisions[i] = test_pval(i, num_runs, len);
    printf("%d\t", collisions[i]);
  }
  puts("");
}


x86 assembly (clang, -O0):
<test_all_pvals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <test_all_pvals+0x7b>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <test_pval@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116f <test_all_pvals+0x2f>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_all_pvals>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r13
mov    %rsi,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
test   %ebp,%ebp
jle    1195 <test_all_pvals+0x55>
mov    %ebp,%ebx
xor    %ebp,%ebp
lea    0xe91(%rip),%r12
nop
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1060 <test_pval@plt>
mov    %eax,0x0(%r13,%rbp,4)
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1170 <test_all_pvals+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
@.str.1 = [1 x i8] zeroinitializer
define void @test_all_pvals(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32*, i32** %7
%13 = load i32, i32* %8
%14 = call i32 @memset(i32* %12, i32 0, i32 %13)
store i32 0, i32* %11
br label %15
15: ; preds = %34, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = load i32, i32* %11
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = call i32 @test_pval(i32 %20, i32 %21, i32 %22)
%24 = load i32*, i32** %7
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %23, i32* %27
%28 = load i32*, i32** %7
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %19
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
store i32 %36, i32* %11
br label %15
37: ; preds = %15
%38 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @test_all_pvals(i32* nocapture readnone %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @memset(i32* %1, i32 0, i32 %2)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %16, %10 ]
%12 = trunc i64 %11 to i32
%13 = tail call i32 @test_pval(i32 %12, i32 %3, i32 %4)
%14 = getelementptr inbounds i32, i32* %1, i64 %11
store i32 %13, i32* %14
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %18, label %10
18: ; preds = %10, %5
%19 = tail call i32 @putchar(i32 10)
ret void
}