#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 int UCHAR_MAX;
int /*<<< orphan*/ time(int /*<<< orphan*/);
unsigned long time_seed() {
  time_t cur_time = time(0);
  unsigned char *p = (unsigned char *)&cur_time;
  unsigned long seed = 0;
  size_t i;
  for (i = 0; i < sizeof cur_time; i++)
    seed = seed * (UCHAR_MAX + 2U) + p[i];
  return seed;
}


x86 assembly (clang, -O0):
<time_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x4,-0x20(%rbp)
jae    117f <time_seed+0x6f>
mov    -0x18(%rbp),%rax
mov    0x2ea0(%rip),%rcx
mov    (%rcx),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
imul   %rcx,%rax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113a <time_seed+0x2a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_seed>:
push   %rax
xor    %edi,%edi
call   1030 <time@plt>
mov    %eax,%ecx
movzbl %al,%edx
movzbl %ah,%esi
shr    $0x10,%eax
shr    $0x18,%ecx
mov    0x2ec3(%rip),%rdi
mov    (%rdi),%edi
add    $0x2,%edi
imul   %rdi,%rdx
add    %rdx,%rsi
imul   %rdi,%rsi
movzbl %al,%eax
add    %rsi,%rax
imul   %rdi,%rax
add    %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@UCHAR_MAX = global i32 0
define i64 @time_seed() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = call i32 @time(i32 0)
store i32 %5, i32* %1
%6 = bitcast i32* %1 to i8*
store i8* %6, i8** %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %7
7: ; preds = %22, %0
%8 = load i64, i64* %4
%9 = icmp ult i64 %8, 4
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i64, i64* %3
%12 = load i32, i32* @UCHAR_MAX
%13 = add i32 %12, 2
%14 = zext i32 %13 to i64
%15 = mul i64 %11, %14
%16 = load i8*, i8** %2
%17 = load i64, i64* %4
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
%21 = add i64 %15, %20
store i64 %21, i64* %3
br label %22
22: ; preds = %10
%23 = load i64, i64* %4
%24 = add i64 %23, 1
store i64 %24, i64* %4
br label %7
25: ; preds = %7
%26 = load i64, i64* %3
ret i64 %26
}

LLVM IR (-O2):
@UCHAR_MAX = global i32 0
define i64 @time_seed() {
%1 = tail call i32 @time(i32 0)
%2 = lshr i32 %1, 8
%3 = lshr i32 %1, 16
%4 = lshr i32 %1, 24
%5 = zext i32 %4 to i64
%6 = load i32, i32* @UCHAR_MAX
%7 = add i32 %6, 2
%8 = zext i32 %7 to i64
%9 = and i32 %1, 255
%10 = zext i32 %9 to i64
%11 = mul nuw nsw i64 %10, %8
%12 = and i32 %2, 255
%13 = zext i32 %12 to i64
%14 = add nuw nsw i64 %11, %13
%15 = mul i64 %14, %8
%16 = and i32 %3, 255
%17 = zext i32 %16 to i64
%18 = add i64 %15, %17
%19 = mul i64 %18, %8
%20 = add i64 %19, %5
ret i64 %20
}