#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 */
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *, int, int, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
int main(int argc, char **argv) {
  struct timespec nowtime;
  clock_gettime(CLOCK_MONOTONIC, &nowtime);
  srand((unsigned int)(nowtime.tv_sec + nowtime.tv_nsec));
  printf("ec:17:2f:%02x:%02x:%02x", rand() % 0x100, rand() % 0x100,
         rand() % 0x100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x28(%rbp),%esi
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x24(%rbp),%edx
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    0x8(%rsp),%edi
add    0x10(%rsp),%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%r14d
lea    0xff(%r14),%eax
test   %r14d,%r14d
cmovns %r14d,%eax
and    $0xffffff00,%eax
sub    %eax,%r14d
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
lea    0xff(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xffffff00,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
lea    0xe3d(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [24 x i8] c"ec:17:2f:%02x:%02x:%02x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @CLOCK_MONOTONIC
%8 = call i32 @clock_gettime(i32 %7, %struct.timespec* %6)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%12 = load i64, i64* %11
%13 = add nsw i64 %10, %12
%14 = trunc i64 %13 to i32
%15 = call i32 @srand(i32 %14)
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 256
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 256
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 256
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19, i32 %21)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
@.str = [24 x i8] c"ec:17:2f:%02x:%02x:%02x\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %3 to i8*
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* %3)
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%8 = load i64, i64* %7
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%10 = load i64, i64* %9
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
%13 = call i32 @srand(i32 %12)
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 256
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 256
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 256
%20 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17, i32 %19)
ret i32 0
}