#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
typedef TYPE_1__ *XdmAuthKeyPtr;
struct TYPE_3__ {
  scalar_t__ data;
};

/* Variables and functions */
int /*<<< orphan*/ getbits(long, scalar_t__);
scalar_t__ getpid();
long random();
int /*<<< orphan*/ srandom(int);
int time(int /*<<< orphan*/ *);
void XdmcpGenerateKey(XdmAuthKeyPtr key) {
  long lowbits, highbits;
  srandom((int)getpid() ^ time((time_t *)0));
  lowbits = random();
  highbits = random();
  getbits(lowbits, key->data);
  getbits(highbits, key->data + 4);
}


x86 assembly (clang, -O0):
<XdmcpGenerateKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    -0x1c(%rbp),%edi
xor    %eax,%edi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1070 <random@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <random@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
call   1050 <getbits@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
add    $0x4,%rsi
call   1050 <getbits@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XdmcpGenerateKey>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1060 <time@plt>
xor    %eax,%ebx
mov    %ebx,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1070 <random@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <random@plt>
mov    %rax,%r15
mov    (%r14),%rsi
mov    %rbx,%rdi
call   1050 <getbits@plt>
mov    (%r14),%rsi
add    $0x4,%rsi
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <getbits@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
define void @XdmcpGenerateKey(%struct.TYPE_3__* %0) {
%2 = alloca %struct.TYPE_3__*
%3 = alloca i64
%4 = alloca i64
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %2
%5 = call i64 (...) @getpid()
%6 = trunc i64 %5 to i32
%7 = call i32 @time(i32* null)
%8 = xor i32 %6, %7
%9 = call i32 @srandom(i32 %8)
%10 = call i64 (...) @random()
store i64 %10, i64* %3
%11 = call i64 (...) @random()
store i64 %11, i64* %4
%12 = load i64, i64* %3
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load i64, i64* %14
%16 = call i32 @getbits(i64 %12, i64 %15)
%17 = load i64, i64* %4
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
%20 = load i64, i64* %19
%21 = add nsw i64 %20, 4
%22 = call i32 @getbits(i64 %17, i64 %21)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64 }
define void @XdmcpGenerateKey(%struct.TYPE_3__* nocapture %0) {
%2 = tail call i64 (...) @getpid()
%3 = trunc i64 %2 to i32
%4 = tail call i32 @time(i32* null)
%5 = xor i32 %4, %3
%6 = tail call i32 @srandom(i32 %5)
%7 = tail call i64 (...) @random()
%8 = tail call i64 (...) @random()
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%10 = load i64, i64* %9
%11 = tail call i32 @getbits(i64 %7, i64 %10)
%12 = load i64, i64* %9
%13 = add nsw i64 %12, 4
%14 = tail call i32 @getbits(i64 %8, i64 %13)
ret void
}