#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 */
typedef int time_t;

/* Variables and functions */
int *RandNumber(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
void testRand(void) {
  time_t start, end;
  int *result = NULL;
  printf("n = %d, k = %d\n", 20, 20 / 2);
  start = time(NULL);
  result = RandNumber(20, 20 / 2);
  end = time(NULL);
  printf("time = %d\n\n", end - start);
  if (result) {
    if (20 < 200) {
      int i;
      for (i = 0; i < 20 / 2; i++) {
        printf("%d, ", result[i]);
      }
      printf("\n");
    }
    free(result);
    result = NULL;
  } else {
    printf("RandNumber failed!\n\n");
  }
}


x86 assembly (clang, -O0):
<testRand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x14,%esi
mov    $0xa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x4(%rbp)
mov    $0x14,%edi
mov    $0xa,%esi
call   1060 <RandNumber@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
sub    -0x4(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     120e <testRand+0xce>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11ea <testRand+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b9 <testRand+0x79>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
jmp    121c <testRand+0xdc>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testRand>:
push   %rbp
push   %r14
push   %rbx
lea    0xe95(%rip),%rdi
mov    $0x14,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%ebp
mov    $0x14,%edi
mov    $0xa,%esi
call   1080 <RandNumber@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1070 <time@plt>
sub    %ebp,%eax
lea    0xe69(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     1257 <testRand+0xf7>
mov    (%rbx),%esi
lea    0xe5a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>
lea    0xdc3(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <puts@plt>

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

LLVM IR (-O2):
@.str = [16 x i8] c"n = %d, k = %d\0A\00"
@.str.1 = [12 x i8] c"time = %d\0A\0A\00"
@.str.2 = [5 x i8] c"%d, \00"
@str = [20 x i8] c"RandNumber failed!\0A\00"
define void @testRand() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 20, i32 10)
%2 = tail call i32 @time(i32* null)
%3 = tail call i32* @RandNumber(i32 20, i32 10)
%4 = tail call i32 @time(i32* null)
%5 = sub nsw i32 %4, %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = icmp eq i32* %3, null
br i1 %7, label %40, label %8
8: ; preds = %0
%9 = load i32, i32* %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i32, i32* %3, i64 1
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i32, i32* %3, i64 2
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %3, i64 3
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds i32, i32* %3, i64 4
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i32, i32* %3, i64 5
%24 = load i32, i32* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds i32, i32* %3, i64 6
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i32, i32* %3, i64 7
%30 = load i32, i32* %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds i32, i32* %3, i64 8
%33 = load i32, i32* %32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds i32, i32* %3, i64 9
%36 = load i32, i32* %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = tail call i32 @putchar(i32 10)
%39 = tail call i32 @free(i32* %3)
br label %42
40: ; preds = %0
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %40, %8
ret void
}