#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*/ assert(int);
long rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
long get_init_rand_port(void) {
  long seed;
  srand((unsigned int)time(NULL));
  do {
    seed = ((long)rand()) * rand();
    seed += ((long)rand()) * rand();
  } while (seed > (2147483647L - 1));
  assert(seed > 0);
  return seed;
}


x86 assembly (clang, -O0):
<get_init_rand_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
imul   %rcx,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x7ffffffe,-0x8(%rbp)
7f
jg     1158 <get_init_rand_port+0x18>
cmpq   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_init_rand_port>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%r14
imul   %rbx,%r14
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%rbx
imul   %r15,%rbx
add    %r14,%rbx
cmp    $0x7ffffffe,%rbx
jg     1160 <get_init_rand_port+0x20>
xor    %edi,%edi
test   %rbx,%rbx
setg   %dil
call   1040 <assert@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @get_init_rand_port() {
%1 = alloca i64
%2 = call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = call i32 @srand(i32 %3)
br label %5
5: ; preds = %14, %0
%6 = call i64 (...) @rand()
%7 = call i64 (...) @rand()
%8 = mul nsw i64 %6, %7
store i64 %8, i64* %1
%9 = call i64 (...) @rand()
%10 = call i64 (...) @rand()
%11 = mul nsw i64 %9, %10
%12 = load i64, i64* %1
%13 = add nsw i64 %12, %11
store i64 %13, i64* %1
br label %14
14: ; preds = %5
%15 = load i64, i64* %1
%16 = icmp sgt i64 %15, 2147483646
br i1 %16, label %5, label %17
17: ; preds = %14
%18 = load i64, i64* %1
%19 = icmp sgt i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i64, i64* %1
ret i64 %22
}

LLVM IR (-O2):
define i64 @get_init_rand_port() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
br label %4
4: ; preds = %4, %0
%5 = tail call i64 (...) @rand()
%6 = tail call i64 (...) @rand()
%7 = mul nsw i64 %6, %5
%8 = tail call i64 (...) @rand()
%9 = tail call i64 (...) @rand()
%10 = mul nsw i64 %9, %8
%11 = add nsw i64 %10, %7
%12 = icmp sgt i64 %11, 2147483646
br i1 %12, label %4, label %13
13: ; preds = %4
%14 = icmp sgt i64 %11, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
ret i64 %11
}