#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 */
unsigned long long get_dev_random();
unsigned long long get_dev_urandom();
int /*<<< orphan*/ init_random();
int /*<<< orphan*/ printf(char *, ...);
unsigned int rand();
int /*<<< orphan*/ showalphnum(unsigned long long);
int main(int argc, char *argv[]) {
  time_t tm;
  unsigned int val;
  unsigned long long max;
  unsigned int min;
  int ii;
  init_random();
  val = rand();
  max = 0;
  min = 0;
  ii = 10;
  while (ii--) {
    max *= 10;
    max += max ? 9 : 8;
    min *= 10;
    min += min ? 0 : 1;
  }
  printf("max = %d\n", (unsigned int)max);
  val = min + ((unsigned long long)val) * max / 0xffffffff;
  printf("rand pass word create: %6d\n", val);
  printf("dev rand pass word create: %6u\n",
         ((unsigned int)(min + (get_dev_random() * max) / 0xffffffff)));
  printf("dev urand pass word create: %6u\n",
         (unsigned int)(min + (get_dev_urandom() * max) / 0xffffffff));
  printf(" dev rand ");
  showalphnum(get_dev_random());
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <init_random@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0xa,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
je     11fb <main+0x9b>
imul   $0xa,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    $0x8,%eax
mov    $0x9,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
cltq
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
imul   $0xa,-0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    119d <main+0x3d>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x20(%rbp),%rax
mov    $0xffffffff,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1060 <get_dev_random@plt>
imul   -0x20(%rbp),%rax
mov    $0xffffffff,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %eax,%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <get_dev_urandom@plt>
imul   -0x20(%rbp),%rax
mov    $0xffffffff,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %eax,%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <get_dev_random@plt>
mov    %rax,%rdi
call   1050 <showalphnum@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <init_random@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
lea    0xe85(%rip),%rdi
mov    $0x187119ff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
movabs $0x2187119ff,%r14
imul   %r14,%rax
movabs $0x8000000080000001,%rbx
mul    %rbx
shr    $0x1f,%rdx
lea    0x3b9aca00(%rdx),%esi
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_dev_random@plt>
imul   %r14,%rax
mul    %rbx
shr    $0x1f,%rdx
lea    0x3b9aca00(%rdx),%esi
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <get_dev_urandom@plt>
imul   %r14,%rax
mul    %rbx
shr    $0x1f,%rdx
lea    0x3b9aca00(%rdx),%esi
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_dev_random@plt>
mov    %rax,%rdi
call   1050 <showalphnum@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"max = %d\0A\00"
@.str.1 = [28 x i8] c"rand pass word create: %6d\0A\00"
@.str.2 = [32 x i8] c"dev rand pass word create: %6u\0A\00"
@.str.3 = [33 x i8] c"dev urand pass word create: %6u\0A\00"
@.str.4 = [11 x i8] c" dev rand \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @init_random()
%12 = call i32 (...) @rand()
store i32 %12, i32* %7
store i64 0, i64* %8
store i32 0, i32* %9
store i32 10, i32* %10
br label %13
13: ; preds = %17, %2
%14 = load i32, i32* %10
%15 = add nsw i32 %14, -1
store i32 %15, i32* %10
%16 = icmp ne i32 %14, 0
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = load i64, i64* %8
%19 = mul i64 %18, 10
store i64 %19, i64* %8
%20 = load i64, i64* %8
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 9, i32 8
%24 = sext i32 %23 to i64
%25 = load i64, i64* %8
%26 = add i64 %25, %24
store i64 %26, i64* %8
%27 = load i32, i32* %9
%28 = mul i32 %27, 10
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 0, i32 1
%33 = load i32, i32* %9
%34 = add i32 %33, %32
store i32 %34, i32* %9
br label %13
35: ; preds = %13
%36 = load i64, i64* %8
%37 = trunc i64 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %9
%40 = zext i32 %39 to i64
%41 = load i32, i32* %7
%42 = zext i32 %41 to i64
%43 = load i64, i64* %8
%44 = mul i64 %42, %43
%45 = udiv i64 %44, 4294967295
%46 = add i64 %40, %45
%47 = trunc i64 %46 to i32
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %9
%51 = zext i32 %50 to i64
%52 = call i64 (...) @get_dev_random()
%53 = load i64, i64* %8
%54 = mul i64 %52, %53
%55 = udiv i64 %54, 4294967295
%56 = add i64 %51, %55
%57 = trunc i64 %56 to i32
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %9
%60 = zext i32 %59 to i64
%61 = call i64 (...) @get_dev_urandom()
%62 = load i64, i64* %8
%63 = mul i64 %61, %62
%64 = udiv i64 %63, 4294967295
%65 = add i64 %60, %64
%66 = trunc i64 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%69 = call i64 (...) @get_dev_random()
%70 = call i32 @showalphnum(i64 %69)
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [10 x i8] c"max = %d\0A\00"
@.str.1 = [28 x i8] c"rand pass word create: %6d\0A\00"
@.str.2 = [32 x i8] c"dev rand pass word create: %6u\0A\00"
@.str.3 = [33 x i8] c"dev urand pass word create: %6u\0A\00"
@.str.4 = [11 x i8] c" dev rand \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init_random()
%4 = tail call i32 (...) @rand()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 410065407)
%6 = zext i32 %4 to i64
%7 = mul i64 %6, 8999999999
%8 = udiv i64 %7, 4294967295
%9 = trunc i64 %8 to i32
%10 = add i32 %9, 1000000000
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i64 (...) @get_dev_random()
%13 = mul i64 %12, 8999999999
%14 = udiv i64 %13, 4294967295
%15 = trunc i64 %14 to i32
%16 = add i32 %15, 1000000000
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i64 (...) @get_dev_urandom()
%19 = mul i64 %18, 8999999999
%20 = udiv i64 %19, 4294967295
%21 = trunc i64 %20 to i32
%22 = add i32 %21, 1000000000
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%25 = tail call i64 (...) @get_dev_random()
%26 = tail call i32 @showalphnum(i64 %25)
ret i32 0
}