#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 uint32_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct timezone {
  int dummy;
};
struct timeval {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
struct tm *localtime(int /*<<< orphan*/ *);
uint32_t stampstart() {
  struct timeval tv;
  struct timezone tz;
  struct tm *tm;
  uint32_t start;
  gettimeofday(&tv, &tz);
  tm = localtime(&tv.tv_sec);
  start = tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
          tm->tm_sec * 1000 + tv.tv_usec / 1000;
  return (start);
}


x86 assembly (clang, -O0):
<stampstart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
imul   $0xe10,(%rax),%eax
imul   $0x3e8,%eax,%eax
mov    -0x18(%rbp),%rcx
imul   $0x3c,0x4(%rcx),%ecx
imul   $0x3e8,%ecx,%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
imul   $0x3e8,0x8(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stampstart>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <gettimeofday@plt>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
imul   $0x36ee80,(%rax),%ecx
imul   $0xea60,0x4(%rax),%edx
imul   $0x3e8,0x8(%rax),%esi
add    %ecx,%edx
add    %edx,%esi
movslq 0x8(%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
add    %esi,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32, i32, i32 }
define i32 @stampstart() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%7 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %7, %struct.tm** %3
%8 = load %struct.tm*, %struct.tm** %3
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 3600
%12 = mul nsw i32 %11, 1000
%13 = load %struct.tm*, %struct.tm** %3
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, 60
%17 = mul nsw i32 %16, 1000
%18 = add nsw i32 %12, %17
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 2
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, 1000
%23 = add nsw i32 %18, %22
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1000
%27 = add nsw i32 %23, %26
store i32 %27, i32* %4
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32, i32, i32 }
define i32 @stampstart() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timezone* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%7 = call %struct.tm* @localtime(i32* %6)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = mul i32 %9, 3600000
%11 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%12 = load i32, i32* %11
%13 = mul i32 %12, 60000
%14 = add nsw i32 %13, %10
%15 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%16 = load i32, i32* %15
%17 = mul nsw i32 %16, 1000
%18 = add nsw i32 %14, %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%20 = load i32, i32* %19
%21 = sdiv i32 %20, 1000
%22 = add nsw i32 %18, %21
ret i32 %22
}