#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 uint64_t;

/* Variables and functions */
int getpid();
int lrand48();
int /*<<< orphan*/ seed48(unsigned short *);
uint64_t genera_id() {
  int pid = getpid();
  unsigned short seed[3] = {pid, pid, pid};
  seed48(seed);
  uint64_t hi = lrand48();
  uint64_t md = lrand48();
  uint64_t lo = lrand48();
  return ((hi << 42) + (md << 21) + lo);
}


x86 assembly (clang, -O0):
<genera_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %ax,-0xa(%rbp)
mov    -0x4(%rbp),%eax
mov    %ax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %ax,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
call   1040 <seed48@plt>
mov    $0x0,%al
call   1050 <lrand48@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <lrand48@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <lrand48@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2a,%ecx
shl    %cl,%eax
mov    -0x14(%rbp),%ecx
shl    $0x15,%ecx
add    %ecx,%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genera_id>:
push   %rax
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %ax,0x2(%rsp)
mov    %ax,0x4(%rsp)
mov    %ax,0x6(%rsp)
lea    0x2(%rsp),%rdi
call   1040 <seed48@plt>
xor    %eax,%eax
call   1050 <lrand48@plt>
xor    %eax,%eax
call   1050 <lrand48@plt>
xor    %eax,%eax
call   1050 <lrand48@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @genera_id() {
%1 = alloca i32
%2 = alloca [3 x i16]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @getpid()
store i32 %6, i32* %1
%7 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%8 = load i32, i32* %1
%9 = trunc i32 %8 to i16
store i16 %9, i16* %7
%10 = getelementptr inbounds i16, i16* %7, i64 1
%11 = load i32, i32* %1
%12 = trunc i32 %11 to i16
store i16 %12, i16* %10
%13 = getelementptr inbounds i16, i16* %10, i64 1
%14 = load i32, i32* %1
%15 = trunc i32 %14 to i16
store i16 %15, i16* %13
%16 = getelementptr inbounds [3 x i16], [3 x i16]* %2, i64 0, i64 0
%17 = call i32 @seed48(i16* %16)
%18 = call i32 (...) @lrand48()
store i32 %18, i32* %3
%19 = call i32 (...) @lrand48()
store i32 %19, i32* %4
%20 = call i32 (...) @lrand48()
store i32 %20, i32* %5
%21 = load i32, i32* %3
%22 = shl i32 %21, 42
%23 = load i32, i32* %4
%24 = shl i32 %23, 21
%25 = add nsw i32 %22, %24
%26 = load i32, i32* %5
%27 = add nsw i32 %25, %26
ret i32 %27
}

LLVM IR (-O2):
define i32 @genera_id() {
%1 = alloca [3 x i16]
%2 = tail call i32 (...) @getpid()
%3 = bitcast [3 x i16]* %1 to i8*
%4 = getelementptr inbounds [3 x i16], [3 x i16]* %1, i64 0, i64 0
%5 = trunc i32 %2 to i16
store i16 %5, i16* %4
%6 = getelementptr inbounds [3 x i16], [3 x i16]* %1, i64 0, i64 1
store i16 %5, i16* %6
%7 = getelementptr inbounds [3 x i16], [3 x i16]* %1, i64 0, i64 2
store i16 %5, i16* %7
%8 = call i32 @seed48(i16* %4)
%9 = call i32 (...) @lrand48()
%10 = call i32 (...) @lrand48()
%11 = call i32 (...) @lrand48()
ret i32 poison
}