#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 */
struct timezone {
  int /*<<< orphan*/ tv_usec;
};
struct timeval {
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ free(struct timezone *);
int /*<<< orphan*/ gettimeofday(struct timezone *, struct timezone *);
scalar_t__ malloc(int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
void randomize(void) {
  struct timeval *tv = (struct timeval *)malloc(sizeof(struct timeval));
  struct timezone *tz = (struct timezone *)malloc(sizeof(struct timezone));
  gettimeofday(tv, tz);
  srand(tv->tv_usec);
  free(tv);
  free(tz);
}


x86 assembly (clang, -O0):
<randomize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <srand@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randomize>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <gettimeofday@plt>
mov    (%rbx),%edi
call   1050 <srand@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
define void @randomize() {
%1 = alloca %struct.timeval*
%2 = alloca %struct.timezone*
%3 = call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to %struct.timeval*
store %struct.timeval* %4, %struct.timeval** %1
%5 = call i64 @malloc(i32 4)
%6 = inttoptr i64 %5 to %struct.timezone*
store %struct.timezone* %6, %struct.timezone** %2
%7 = load %struct.timeval*, %struct.timeval** %1
%8 = bitcast %struct.timeval* %7 to %struct.timezone*
%9 = load %struct.timezone*, %struct.timezone** %2
%10 = call i32 @gettimeofday(%struct.timezone* %8, %struct.timezone* %9)
%11 = load %struct.timeval*, %struct.timeval** %1
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @srand(i32 %13)
%15 = load %struct.timeval*, %struct.timeval** %1
%16 = bitcast %struct.timeval* %15 to %struct.timezone*
%17 = call i32 @free(%struct.timezone* %16)
%18 = load %struct.timezone*, %struct.timezone** %2
%19 = call i32 @free(%struct.timezone* %18)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.timezone = type { i32 }
define void @randomize() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to %struct.timeval*
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to %struct.timezone*
%5 = inttoptr i64 %1 to %struct.timezone*
%6 = tail call i32 @gettimeofday(%struct.timezone* %5, %struct.timezone* %4)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32 @free(%struct.timezone* %5)
%11 = tail call i32 @free(%struct.timezone* %4)
ret void
}