#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 {
  scalar_t__ tz_dsttime;
  scalar_t__ tz_minuteswest;
};
struct timeval {
  long tv_usec;
};

/* Variables and functions */
scalar_t__ gettimeofday(struct timeval *, struct timezone *);
scalar_t__ time(int /*<<< orphan*/ *);
__attribute__((visibility("hidden"))) int SYS_GetSeed(void) {
  struct timeval tv;
  struct timezone tz;
  long myseed = 0;
  tz.tz_minuteswest = 0;
  tz.tz_dsttime = 0;
  if (gettimeofday(&tv, &tz) == 0) {
    myseed = tv.tv_usec;
  } else {
    myseed = (long)time(NULL);
  }
  return myseed;
}


x86 assembly (clang, -O0):
<SYS_GetSeed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
jne    1164 <SYS_GetSeed+0x44>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1171 <SYS_GetSeed+0x51>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SYS_GetSeed>:
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <gettimeofday@plt>
test   %rax,%rax
je     114c <SYS_GetSeed+0x2c>
xor    %edi,%edi
call   1040 <time@plt>
add    $0x28,%rsp
ret
mov    0x8(%rsp),%rax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
%struct.timezone = type { i64, i64 }
define hidden i32 @SYS_GetSeed() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = alloca i64
store i64 0, i64* %3
%4 = getelementptr inbounds %struct.timezone, %struct.timezone* %2, i32 0, i32 1
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.timezone, %struct.timezone* %2, i32 0, i32 0
store i64 0, i64* %5
%6 = call i64 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%10 = load i64, i64* %9
store i64 %10, i64* %3
br label %13
11: ; preds = %0
%12 = call i64 @time(i32* null)
store i64 %12, i64* %3
br label %13
13: ; preds = %11, %8
%14 = load i64, i64* %3
%15 = trunc i64 %14 to i32
ret i32 %15
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
%struct.timezone = type { i64, i64 }
define hidden i32 @SYS_GetSeed() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timezone* %2 to i8*
%5 = bitcast %struct.timezone* %2 to i8*
%6 = call i64 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%10 = load i64, i64* %9
br label %13
11: ; preds = %0
%12 = tail call i64 @time(i32* null)
br label %13
13: ; preds = %11, %8
%14 = phi i64 [ %10, %8 ], [ %12, %11 ]
%15 = trunc i64 %14 to i32
ret i32 %15
}