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

/* Variables and functions */
int *RandNumberMN(int, int, int, int *, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
void testRandMN(void) {
  time_t start, end;
  int *result = NULL;
  int m = 490, n = 540, k = 10;
  int inum[] = {3, 90, 200, 305, 487, 503, 500, 501, 502, 504};
  printf("m = %d, n = %d, k = %d\n", m, n, k);
  start = time(NULL);
  result = RandNumberMN(m, n, k, inum, sizeof(inum) / sizeof(inum[0]));
  end = time(NULL);
  printf("time = %d\n\n", end - start);
  if (result) {
    printf("RandNumber success!\n");
    if (k < 200) {
      int i;
      for (i = 0; i < k; i++) {
        printf("%d, ", result[i]);
      }
      printf("\n");
    }
    free(result);
    result = NULL;
  } else {
    printf("RandNumber failed!\n\n");
  }
}


x86 assembly (clang, -O0):
<testRandMN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movq   $0x0,-0x10(%rbp)
movl   $0x1ea,-0x14(%rbp)
movl   $0x21c,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0x50(%rbp),%rcx
mov    $0xa,%r8d
call   1050 <RandNumberMN@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
sub    -0x4(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     126d <testRandMN+0x11d>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xc8,-0x1c(%rbp)
jge    1257 <testRandMN+0x107>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1249 <testRandMN+0xf9>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1216 <testRandMN+0xc6>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
jmp    127b <testRandMN+0x12b>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testRandMN>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe96(%rip),%rdi
mov    $0x1ea,%esi
mov    $0x21c,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%ebp
mov    %rsp,%rcx
mov    $0x1ea,%edi
mov    $0x21c,%esi
mov    $0xa,%edx
mov    $0xa,%r8d
call   1070 <RandNumberMN@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1080 <time@plt>
sub    %ebp,%eax
lea    0xe5f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %rbx,%rbx
je     129b <testRandMN+0x13b>
lea    0xe6b(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
lea    0xe44(%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
call   1030 <free@plt>
jmp    12a7 <testRandMN+0x147>
lea    0xdaf(%rip),%rdi
call   1050 <puts@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.testRandMN.inum = [10 x i32] [i32 3, i32 90, i32 200, i32 305, i32 487, i32 503, i32 500, i32 501, i32 502, i32 504]
@.str = [24 x i8] c"m = %d, n = %d, k = %d\0A\00"
@.str.1 = [12 x i8] c"time = %d\0A\0A\00"
@.str.2 = [21 x i8] c"RandNumber success!\0A\00"
@.str.3 = [5 x i8] c"%d, \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [21 x i8] c"RandNumber failed!\0A\0A\00"
define void @testRandMN() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i32]
%8 = alloca i32
store i32* null, i32** %3
store i32 490, i32* %4
store i32 540, i32* %5
store i32 10, i32* %6
%9 = bitcast [10 x i32]* %7 to i8*
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = call i32 @time(i32* null)
store i32 %14, i32* %1
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%19 = call i32* @RandNumberMN(i32 %15, i32 %16, i32 %17, i32* %18, i32 10)
store i32* %19, i32** %3
%20 = call i32 @time(i32* null)
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = sub nsw i32 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %3
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %51
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 200
br i1 %30, label %31, label %48
31: ; preds = %27
store i32 0, i32* %8
br label %32
32: ; preds = %43, %31
%33 = load i32, i32* %8
%34 = load i32, i32* %6
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32*, i32** %3
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %36
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %32
46: ; preds = %32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %27
%49 = load i32*, i32** %3
%50 = call i32 @free(i32* %49)
store i32* null, i32** %3
br label %53
51: ; preds = %0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %48
ret void
}

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