#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  unsigned char r[16];
  int i;
  (void)srand((unsigned int)time(NULL));
  for (i = 0; i < 16; i++) {
    r[i] = (unsigned char)rand() % 255;
    if (i == 6) {
      r[i] = 0x40 | (r[i] & 0xf);
    }
    if (i == 8) {
      r[i] = 0x80 | (r[i] & 0x3f);
    }
    printf("%02x", r[i]);
  }
  printf("\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    11f9 <main+0xb9>
mov    $0x0,%al
call   1060 <rand@plt>
movzbl %al,%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
cmpl   $0x6,-0x24(%rbp)
jne    11af <main+0x6f>
movslq -0x24(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%eax
and    $0xf,%eax
or     $0x40,%eax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
cmpl   $0x8,-0x24(%rbp)
jne    11d4 <main+0x94>
movslq -0x24(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
movslq -0x24(%rbp),%rax
movzbl -0x20(%rbp,%rax,1),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1166 <main+0x26>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x8,%ebp
lea    0xe8f(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cmp    $0xff,%al
cmove  %r14d,%eax
mov    %eax,%ecx
and    $0xf,%cl
or     $0x40,%cl
cmp    $0x2,%ebp
movzbl %cl,%ecx
cmovne %eax,%ecx
mov    %ecx,%eax
and    $0x3f,%al
or     $0x80,%al
sub    $0x1,%ebp
movzbl %al,%eax
cmovae %ecx,%eax
movzbl %al,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xfffffff8,%ebp
jne    1180 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @time(i32* null)
%5 = trunc i64 %4 to i32
%6 = call i32 @srand(i32 %5)
store i32 0, i32* %3
br label %7
7: ; preds = %55, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %58
10: ; preds = %7
%11 = call i64 (...) @rand()
%12 = trunc i64 %11 to i8
%13 = zext i8 %12 to i32
%14 = srem i32 %13, 255
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %17
store i8 %15, i8* %18
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 6
br i1 %20, label %21, label %33
21: ; preds = %10
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 15
%28 = or i32 64, %27
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %31
store i8 %29, i8* %32
br label %33
33: ; preds = %21, %10
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 8
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = and i32 %41, 63
%43 = or i32 128, %42
%44 = trunc i32 %43 to i8
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %46
store i8 %44, i8* %47
br label %48
48: ; preds = %36, %33
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %7
58: ; preds = %7
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%60 = load i32, i32* @EXIT_SUCCESS
ret i32 %60
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %20, %4 ]
%6 = tail call i64 (...) @rand()
%7 = trunc i64 %6 to i8
%8 = icmp eq i8 %7, -1
%9 = select i1 %8, i8 0, i8 %7
%10 = icmp eq i32 %5, 6
%11 = and i8 %9, 15
%12 = or i8 %11, 64
%13 = select i1 %10, i8 %12, i8 %9
%14 = icmp eq i32 %5, 8
%15 = and i8 %13, 63
%16 = or i8 %15, -128
%17 = select i1 %14, i8 %16, i8 %13
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i32 %5, 1
%21 = icmp eq i32 %20, 16
br i1 %21, label %22, label %4
22: ; preds = %4
%23 = tail call i32 @putchar(i32 10)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}