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

/* Variables and functions */
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int numberGenerator() {
  int num = 0, randDigit, i;
  int numbers[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  time_t t;
  srand((unsigned)time(&t));
  for (i = 0; i < 4; i++) {
    randDigit = rand() % (9 - i);
    num = num * 10 + numbers[randDigit];
    numbers[randDigit] = numbers[8 - i];
  }
  return num;
}


x86 assembly (clang, -O0):
<numberGenerator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x34(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11cd <numberGenerator+0x8d>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x9,%ecx
sub    -0xc(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
imul   $0xa,-0x4(%rbp),%eax
movslq -0x8(%rbp),%rcx
add    -0x30(%rbp,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    $0x8,%eax
sub    -0xc(%rbp),%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <numberGenerator+0x3b>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numberGenerator>:
push   %rbx
sub    $0x30,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x2c(%rsp),%rdi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    %ecx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
cltq
mov    (%rsp,%rax,4),%ebx
movl   $0x9,(%rsp,%rax,4)
xor    %eax,%eax
call   1050 <rand@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
lea    (%rbx,%rbx,4),%ebx
add    %ebx,%ebx
cltq
add    (%rsp,%rax,4),%ebx
mov    0x1c(%rsp),%ecx
mov    %ecx,(%rsp,%rax,4)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
lea    (%rbx,%rbx,4),%ebx
add    %ebx,%ebx
movslq %ecx,%rax
add    (%rsp,%rax,4),%ebx
mov    0x18(%rsp),%ecx
mov    %ecx,(%rsp,%rax,4)
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rcx
imul   $0x2aaaaaab,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ecx
lea    (%rbx,%rbx,4),%eax
add    %eax,%eax
movslq %ecx,%rcx
add    (%rsp,%rcx,4),%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.numberGenerator.numbers = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32 @numberGenerator() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [9 x i32]* %4 to i8*
%7 = call i64 @time(i32* %5)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %3
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = load i32, i32* %3
%16 = sub nsw i32 9, %15
%17 = srem i32 %14, %16
store i32 %17, i32* %2
%18 = load i32, i32* %1
%19 = mul nsw i32 %18, 10
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nsw i32 %19, %23
store i32 %24, i32* %1
%25 = load i32, i32* %3
%26 = sub nsw i32 8, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 %31
store i32 %29, i32* %32
br label %33
33: ; preds = %13
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %10
36: ; preds = %10
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@__const.numberGenerator.numbers = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32 @numberGenerator() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = bitcast [9 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @time(i32* %2)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 9
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
store i32 9, i32* %11
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 8
%15 = mul nsw i32 %12, 10
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, %15
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 7
%21 = load i32, i32* %20
store i32 %21, i32* %17
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 7
%24 = mul nsw i32 %19, 10
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %24
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 6
%30 = load i32, i32* %29
store i32 %30, i32* %26
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 6
%33 = mul nsw i32 %28, 10
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = add nsw i32 %36, %33
ret i32 %37
}