#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 scalar_t__ uint8_t;
typedef scalar_t__ uint32_t;
typedef int /*<<< orphan*/ ts_usec;
typedef int /*<<< orphan*/ ts_sec;
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ orig_len;
typedef int /*<<< orphan*/ incl_len;

/* Variables and functions */
int /*<<< orphan*/ data_write(scalar_t__ *, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void write_frame_hdr(uint8_t len) {
  uint32_t ts_sec;
  uint32_t ts_usec;
  uint32_t incl_len;
  uint32_t orig_len;
  struct timeval tv;
  gettimeofday(&tv, NULL);
  ts_sec = tv.tv_sec;
  ts_usec = tv.tv_usec;
  incl_len = len;
  orig_len = len + 2;
  data_write(&ts_sec, sizeof(ts_sec));
  data_write(&ts_usec, sizeof(ts_usec));
  data_write(&incl_len, sizeof(incl_len));
  data_write(&orig_len, sizeof(orig_len));
}


x86 assembly (clang, -O0):
<write_frame_hdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
lea    -0x18(%rbp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
lea    -0x20(%rbp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_frame_hdr>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x20(%rsp),%rax
mov    0x28(%rsp),%rcx
mov    %rcx,0x18(%rsp)
mov    %rax,0x10(%rsp)
mov    %rbx,0x8(%rsp)
add    $0x2,%rbx
mov    %rbx,(%rsp)
lea    0x18(%rsp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
mov    %rsp,%rdi
mov    $0x8,%esi
call   1040 <data_write@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @write_frame_hdr(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca %struct.timeval
store i64 %0, i64* %2
%8 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%10 = load i64, i64* %9
store i64 %10, i64* %3
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%12 = load i64, i64* %11
store i64 %12, i64* %4
%13 = load i64, i64* %2
store i64 %13, i64* %5
%14 = load i64, i64* %2
%15 = add nsw i64 %14, 2
store i64 %15, i64* %6
%16 = call i32 @data_write(i64* %3, i32 8)
%17 = call i32 @data_write(i64* %4, i32 8)
%18 = call i32 @data_write(i64* %5, i32 8)
%19 = call i32 @data_write(i64* %6, i32 8)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @write_frame_hdr(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca %struct.timeval
%7 = bitcast i64* %2 to i8*
%8 = bitcast i64* %3 to i8*
%9 = bitcast i64* %4 to i8*
%10 = bitcast i64* %5 to i8*
%11 = bitcast %struct.timeval* %6 to i8*
%12 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%14 = load i64, i64* %13
store i64 %14, i64* %2
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%16 = load i64, i64* %15
store i64 %16, i64* %3
store i64 %0, i64* %4
%17 = add nsw i64 %0, 2
store i64 %17, i64* %5
%18 = call i32 @data_write(i64* %2, i32 8)
%19 = call i32 @data_write(i64* %3, i32 8)
%20 = call i32 @data_write(i64* %4, i32 8)
%21 = call i32 @data_write(i64* %5, i32 8)
ret void
}