void dump_time_struct_bytes(struct tm *time_ptr, int size) {
  int i;
  unsigned char *raw_ptr;
  printf("bytes of struct located at 0x%08x\n", time_ptr);
  raw_ptr = (unsigned char *)time_ptr;
  for (i = 0; i < size; i++) {
    printf("%02x ", raw_ptr[i]);
    if (i % 16 == 15)
      printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_time_struct_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119b <dump_time_struct_bytes+0x8b>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    1188 <dump_time_struct_bytes+0x78>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118d <dump_time_struct_bytes+0x7d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <dump_time_struct_bytes+0x30>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_time_struct_bytes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xecd(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    117c <dump_time_struct_bytes+0x5c>
mov    %ebp,%ebp
lea    0xed9(%rip),%r14
xor    %ebx,%ebx
jmp    1159 <dump_time_struct_bytes+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     117c <dump_time_struct_bytes+0x5c>
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1150 <dump_time_struct_bytes+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <dump_time_struct_bytes+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.tm = type opaque
@.str = [35 x i8] c"bytes of struct located at 0x%08x\0A\00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_time_struct_bytes(%struct.tm* %0, i32 %1) {
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store %struct.tm* %0, %struct.tm** %3
store i32 %1, i32* %4
%7 = load %struct.tm*, %struct.tm** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = load %struct.tm*, %struct.tm** %3
%10 = bitcast %struct.tm* %9 to i8*
store i8* %10, i8** %6
store i32 0, i32* %5
br label %11
11: ; preds = %29, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %32
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %5
%24 = srem i32 %23, 16
%25 = icmp eq i32 %24, 15
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %11
32: ; preds = %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.tm = type opaque
@.str = [35 x i8] c"bytes of struct located at 0x%08x\0A\00"
@.str.1 = [6 x i8] c"%02x \00"
define void @dump_time_struct_bytes(%struct.tm* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %struct.tm* %0)
%4 = bitcast %struct.tm* %0 to i8*
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %21
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %18
%9 = phi i64 [ 0, %6 ], [ %19, %18 ]
%10 = getelementptr inbounds i8, i8* %4, i64 %9
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = and i64 %9, 15
%15 = icmp eq i64 %14, 15
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = tail call i32 @putchar(i32 10)
br label %18
18: ; preds = %8, %16
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %7
br i1 %20, label %21, label %8
21: ; preds = %18, %2
%22 = tail call i32 @putchar(i32 10)
ret void
}