#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 /*<<< orphan*/ free(void *);
void *malloc(int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void seed_random(void) {
  void *ap = malloc(1);
  void *bp = malloc(1);
  unsigned int a = (unsigned int)(long)ap;
  unsigned int b = (unsigned int)(long)bp;
  unsigned int c = (unsigned int)time(NULL);
  free(ap);
  free(bp);
  b = (b << (4 * sizeof(unsigned int))) | (b >> (4 * sizeof(unsigned int)));
  srand(a ^ b ^ c);
}


x86 assembly (clang, -O0):
<seed_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
shl    $0x10,%eax
mov    -0x18(%rbp),%ecx
shr    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
xor    -0x18(%rbp),%edi
xor    -0x1c(%rbp),%edi
call   1040 <srand@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seed_random>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
rol    $0x10,%r15d
xor    %r14d,%ebx
xor    %r15d,%ebx
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <srand@plt>

LLVM IR (-O0):
define void @seed_random() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i8* @malloc(i32 1)
store i8* %6, i8** %1
%7 = call i8* @malloc(i32 1)
store i8* %7, i8** %2
%8 = load i8*, i8** %1
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
store i32 %10, i32* %3
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %11 to i64
%13 = trunc i64 %12 to i32
store i32 %13, i32* %4
%14 = call i64 @time(i32* null)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %5
%16 = load i8*, i8** %1
%17 = call i32 @free(i8* %16)
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
%20 = load i32, i32* %4
%21 = shl i32 %20, 16
%22 = load i32, i32* %4
%23 = lshr i32 %22, 16
%24 = or i32 %21, %23
store i32 %24, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = xor i32 %25, %26
%28 = load i32, i32* %5
%29 = xor i32 %27, %28
%30 = call i32 @srand(i32 %29)
ret void
}

LLVM IR (-O2):
define void @seed_random() {
%1 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%2 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%3 = ptrtoint i8* %1 to i64
%4 = ptrtoint i8* %2 to i64
%5 = trunc i64 %4 to i32
%6 = tail call i64 @time(i32* null)
%7 = tail call i32 @free(i8* %1)
%8 = tail call i32 @free(i8* %2)
%9 = tail call i32 @llvm.fshl.i32(i32 %5, i32 %5, i32 16)
%10 = xor i64 %6, %3
%11 = trunc i64 %10 to i32
%12 = xor i32 %9, %11
%13 = tail call i32 @srand(i32 %12)
ret void
}