int save_time(int year, int month, int day, int hour, int minute, int second,
              unsigned char *p) {
  *p++ = (unsigned char)(year >> 8) & 255;
  *p++ = (unsigned char)year & 255;
  *p++ = (unsigned char)month;
  *p++ = (unsigned char)day;
  *p++ = (unsigned char)hour;
  *p++ = (unsigned char)minute;
  *p++ = (unsigned char)second;
  return 0;
}


x86 assembly (clang, -O0):
<save_time>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
movzbl %al,%eax
and    $0xff,%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%eax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,0x10(%rbp)
mov    %cl,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_time>:
mov    %edi,%eax
mov    0x8(%rsp),%rdi
mov    %ah,(%rdi)
mov    %al,0x1(%rdi)
mov    %sil,0x2(%rdi)
mov    %dl,0x3(%rdi)
mov    %cl,0x4(%rdi)
mov    %r8b,0x5(%rdi)
mov    %r9b,0x6(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @save_time(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
%15 = load i32, i32* %8
%16 = ashr i32 %15, 8
%17 = trunc i32 %16 to i8
%18 = zext i8 %17 to i32
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %14
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %14
store i8 %20, i8* %21
%23 = load i32, i32* %8
%24 = trunc i32 %23 to i8
%25 = zext i8 %24 to i32
%26 = and i32 %25, 255
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %14
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %14
store i8 %27, i8* %28
%30 = load i32, i32* %9
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %14
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %14
store i8 %31, i8* %32
%34 = load i32, i32* %10
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %14
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %14
store i8 %35, i8* %36
%38 = load i32, i32* %11
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %14
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %14
store i8 %39, i8* %40
%42 = load i32, i32* %12
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %14
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %14
store i8 %43, i8* %44
%46 = load i32, i32* %13
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %14
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %14
store i8 %47, i8* %48
ret i32 0
}

LLVM IR (-O2):
define i32 @save_time(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i8* nocapture writeonly %6) {
%8 = lshr i32 %0, 8
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %9, i8* %6
%11 = trunc i32 %0 to i8
%12 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %11, i8* %10
%13 = trunc i32 %1 to i8
%14 = getelementptr inbounds i8, i8* %6, i64 3
store i8 %13, i8* %12
%15 = trunc i32 %2 to i8
%16 = getelementptr inbounds i8, i8* %6, i64 4
store i8 %15, i8* %14
%17 = trunc i32 %3 to i8
%18 = getelementptr inbounds i8, i8* %6, i64 5
store i8 %17, i8* %16
%19 = trunc i32 %4 to i8
%20 = getelementptr inbounds i8, i8* %6, i64 6
store i8 %19, i8* %18
%21 = trunc i32 %5 to i8
store i8 %21, i8* %20
ret i32 0
}