#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 */

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char, char, char, char, char, char,
                           char, char);
char *byteorder_64(void) {
  static char buf[64 / 4 + 1];
  union {
    long long int all;
    struct {
      char a;
      char b;
      char c;
      char d;
      char e;
      char f;
      char g;
      char h;
    };
  } test = {.all = 0x0102030405060708LL};
  sprintf(buf, "%02i%02i%02i%02i%02i%02i%02i%02i", test.a, test.b, test.c,
          test.d, test.e, test.f, test.g, test.h);
  return buf;
}


x86 assembly (clang, -O0):
<byteorder_64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%dl
mov    -0x7(%rbp),%cl
mov    -0x6(%rbp),%r8b
mov    -0x5(%rbp),%r9b
mov    -0x4(%rbp),%r11b
mov    -0x3(%rbp),%r10b
mov    -0x2(%rbp),%al
lea    0x2efd(%rip),%rdi
lea    0xebe(%rip),%rsi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
movsbl %r11b,%r11d
mov    %r11d,(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x8(%rsp)
movsbl %al,%eax
mov    %eax,0x10(%rsp)
movsbl -0x1(%rbp),%eax
mov    %eax,0x18(%rsp)
call   1030 <sprintf@plt>
lea    0x2ebc(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<byteorder_64>:
push   %rbx
lea    0x2f28(%rip),%rbx
lea    0xee1(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
mov    $0x7,%ecx
mov    $0x6,%r8d
mov    $0x5,%r9d
push   $0x1
push   $0x2
push   $0x3
push   $0x4
call   1030 <sprintf@plt>
add    $0x20,%rsp
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%union.anon = type { i64 }
%struct.anon = type { i8, i8, i8, i8, i8, i8, i8, i8 }
@byteorder_64.buf = internal global [17 x i8] zeroinitializer
@__const.byteorder_64.test = %union.anon { i64 72623859790382856 }
@.str = [33 x i8] c"%02i%02i%02i%02i%02i%02i%02i%02i\00"
define i8* @byteorder_64() {
%1 = alloca %union.anon
%2 = bitcast %union.anon* %1 to i8*
%3 = bitcast %union.anon* %1 to %struct.anon*
%4 = getelementptr inbounds %struct.anon, %struct.anon* %3, i32 0, i32 0
%5 = load i8, i8* %4
%6 = bitcast %union.anon* %1 to %struct.anon*
%7 = getelementptr inbounds %struct.anon, %struct.anon* %6, i32 0, i32 1
%8 = load i8, i8* %7
%9 = bitcast %union.anon* %1 to %struct.anon*
%10 = getelementptr inbounds %struct.anon, %struct.anon* %9, i32 0, i32 2
%11 = load i8, i8* %10
%12 = bitcast %union.anon* %1 to %struct.anon*
%13 = getelementptr inbounds %struct.anon, %struct.anon* %12, i32 0, i32 3
%14 = load i8, i8* %13
%15 = bitcast %union.anon* %1 to %struct.anon*
%16 = getelementptr inbounds %struct.anon, %struct.anon* %15, i32 0, i32 4
%17 = load i8, i8* %16
%18 = bitcast %union.anon* %1 to %struct.anon*
%19 = getelementptr inbounds %struct.anon, %struct.anon* %18, i32 0, i32 5
%20 = load i8, i8* %19
%21 = bitcast %union.anon* %1 to %struct.anon*
%22 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 0, i32 6
%23 = load i8, i8* %22
%24 = bitcast %union.anon* %1 to %struct.anon*
%25 = getelementptr inbounds %struct.anon, %struct.anon* %24, i32 0, i32 7
%26 = load i8, i8* %25
%27 = call i32 @sprintf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @byteorder_64.buf, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext %5, i8 signext %8, i8 signext %11, i8 signext %14, i8 signext %17, i8 signext %20, i8 signext %23, i8 signext %26)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @byteorder_64.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@byteorder_64.buf = internal global [17 x i8] zeroinitializer
@.str = [33 x i8] c"%02i%02i%02i%02i%02i%02i%02i%02i\00"
define i8* @byteorder_64() {
%1 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @byteorder_64.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8 signext 8, i8 signext 7, i8 signext 6, i8 signext 5, i8 signext 4, i8 signext 3, i8 signext 2, i8 signext 1)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @byteorder_64.buf, i64 0, i64 0)
}