char *put8(out, s)
char *out;
char *s;
{
  sprintf(out, "%02X%02X %02X%02X %02X%02X %02X%02X", s[0] & 0xff, s[1] & 0xff,
          s[2] & 0xff, s[3] & 0xff, s[4] & 0xff, s[5] & 0xff, s[6] & 0xff,
          s[7] & 0xff);
  return out;
}


x86 assembly (clang, -O0):
<put8>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
and    $0xff,%edx
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%r8d
and    $0xff,%r8d
mov    -0x18(%rbp),%rax
movsbl 0x3(%rax),%r9d
and    $0xff,%r9d
mov    -0x18(%rbp),%rax
movsbl 0x4(%rax),%ebx
and    $0xff,%ebx
mov    -0x18(%rbp),%rax
movsbl 0x5(%rax),%r11d
and    $0xff,%r11d
mov    -0x18(%rbp),%rax
movsbl 0x6(%rax),%r10d
and    $0xff,%r10d
mov    -0x18(%rbp),%rax
movsbl 0x7(%rax),%eax
and    $0xff,%eax
lea    0xe5e(%rip),%rsi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<put8>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
movzbl (%rsi),%edx
movzbl 0x1(%rsi),%ecx
movzbl 0x2(%rsi),%r8d
movzbl 0x3(%rsi),%r9d
movzbl 0x4(%rsi),%r10d
movzbl 0x5(%rsi),%r11d
movzbl 0x6(%rsi),%r14d
movzbl 0x7(%rsi),%ebx
lea    0xebd(%rip),%rsi
xor    %eax,%eax
push   %rbx
push   %r14
push   %r11
push   %r10
call   1030 <sprintf@plt>
add    $0x20,%rsp
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%02X%02X %02X%02X %02X%02X %02X%02X\00"
define i8* @put8(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = and i32 %9, 255
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = and i32 %14, 255
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = and i32 %19, 255
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = and i32 %24, 255
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 4
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = and i32 %29, 255
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = and i32 %34, 255
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = and i32 %39, 255
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 7
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = and i32 %44, 255
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %15, i32 %20, i32 %25, i32 %30, i32 %35, i32 %40, i32 %45)
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
@.str = [36 x i8] c"%02X%02X %02X%02X %02X%02X %02X%02X\00"
define i8* @put8(i8* returned writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = zext i8 %3 to i32
%5 = getelementptr inbounds i8, i8* %1, i64 1
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = getelementptr inbounds i8, i8* %1, i64 2
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = getelementptr inbounds i8, i8* %1, i64 3
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = getelementptr inbounds i8, i8* %1, i64 4
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = getelementptr inbounds i8, i8* %1, i64 5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds i8, i8* %1, i64 6
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = getelementptr inbounds i8, i8* %1, i64 7
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %7, i32 %10, i32 %13, i32 %16, i32 %19, i32 %22, i32 %25)
ret i8* %0
}