#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*/ *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
uint32_t stampstart() {
  struct timeval tv;
  struct timezone tz;
  struct tm *tm;
  uint32_t start;
  gettimeofday(&tv, &tz);
  tm = localtime(&tv.tv_sec);
  printf("TIMESTAMP-START\t  %d:%02d:%02d:%d (~%d ms)\n", tm->tm_hour,
         tm->tm_min, tm->tm_sec, tv.tv_usec,
         tm->tm_hour * 3600 * 1000 + tm->tm_min * 60 * 1000 +
             tm->tm_sec * 1000 + tv.tv_usec / 1000);
  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    $0x30,%rsp
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x8(%rbp),%r8d
mov    -0x18(%rbp),%rax
imul   $0xe10,(%rax),%eax
imul   $0x3e8,%eax,%r9d
mov    -0x18(%rbp),%rax
imul   $0x3c,0x4(%rax),%eax
imul   $0x3e8,%eax,%eax
add    %eax,%r9d
mov    -0x18(%rbp),%rax
imul   $0x3e8,0x8(%rax),%eax
add    %eax,%r9d
mov    -0x8(%rbp),%eax
mov    $0x3e8,%edi
cltd
idiv   %edi
mov    -0x24(%rbp),%edx
add    %eax,%r9d
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
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    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stampstart>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <gettimeofday@plt>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
movslq (%rsp),%r8
imul   $0x36ee80,%esi,%eax
imul   $0xea60,%edx,%edi
add    %eax,%edi
imul   $0x3e8,%ecx,%eax
add    %edi,%eax
imul   $0x10624dd3,%r8,%r9
mov    %r9,%rdi
shr    $0x3f,%rdi
sar    $0x26,%r9
add    %edi,%r9d
add    %eax,%r9d
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
imul   $0x36ee80,(%rbx),%eax
imul   $0xea60,0x4(%rbx),%ecx
imul   $0x3e8,0x8(%rbx),%edx
add    %eax,%ecx
add    %ecx,%edx
movslq (%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
add    %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32, i32, i32 }
@.str = [44 x i8] c"TIMESTAMP-START\09 %d:%02d:%02d:%d (~%d ms)\0A\00"
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 = load %struct.tm*, %struct.tm** %3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = mul nsw i32 %21, 3600
%23 = mul nsw i32 %22, 1000
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = mul nsw i32 %26, 60
%28 = mul nsw i32 %27, 1000
%29 = add nsw i32 %23, %28
%30 = load %struct.tm*, %struct.tm** %3
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 2
%32 = load i32, i32* %31
%33 = mul nsw i32 %32, 1000
%34 = add nsw i32 %29, %33
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%36 = load i32, i32* %35
%37 = sdiv i32 %36, 1000
%38 = add nsw i32 %34, %37
%39 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13, i32 %16, i32 %18, i32 %38)
%40 = load %struct.tm*, %struct.tm** %3
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = mul nsw i32 %42, 3600
%44 = mul nsw i32 %43, 1000
%45 = load %struct.tm*, %struct.tm** %3
%46 = getelementptr inbounds %struct.tm, %struct.tm* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = mul nsw i32 %47, 60
%49 = mul nsw i32 %48, 1000
%50 = add nsw i32 %44, %49
%51 = load %struct.tm*, %struct.tm** %3
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i32 0, i32 2
%53 = load i32, i32* %52
%54 = mul nsw i32 %53, 1000
%55 = add nsw i32 %50, %54
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%57 = load i32, i32* %56
%58 = sdiv i32 %57, 1000
%59 = add nsw i32 %55, %58
store i32 %59, i32* %4
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32, i32, i32 }
@.str = [44 x i8] c"TIMESTAMP-START\09 %d:%02d:%02d:%d (~%d ms)\0A\00"
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 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%15 = load i32, i32* %14
%16 = mul i32 %9, 3600000
%17 = mul i32 %11, 60000
%18 = add nsw i32 %17, %16
%19 = mul nsw i32 %13, 1000
%20 = add nsw i32 %18, %19
%21 = sdiv i32 %15, 1000
%22 = add nsw i32 %20, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %13, i32 %15, i32 %22)
%24 = load i32, i32* %8
%25 = mul i32 %24, 3600000
%26 = load i32, i32* %10
%27 = mul i32 %26, 60000
%28 = add nsw i32 %27, %25
%29 = load i32, i32* %12
%30 = mul nsw i32 %29, 1000
%31 = add nsw i32 %28, %30
%32 = load i32, i32* %14
%33 = sdiv i32 %32, 1000
%34 = add nsw i32 %31, %33
ret i32 %34
}