#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*/ printf(char *, ...);
void print_byte_l(long s) {
  int i;
  unsigned char *p;
  p = (unsigned char *)&s;
  for (i = 0; i < sizeof(long); i++) {
    printf("%02x", *p);
    p++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_byte_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x8,%rax
jae    1168 <print_byte_l+0x58>
mov    -0x18(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112b <print_byte_l+0x1b>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_byte_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %ebx,%r14d
shr    $0x10,%r14d
mov    %ebx,%eax
shr    $0x18,%eax
mov    %eax,0xc(%rsp)
mov    %rdi,%rbp
shr    $0x20,%rbp
mov    %rdi,%r12
shr    $0x28,%r12
mov    %rdi,%r15
shr    $0x30,%r15
mov    %rdi,%rax
shr    $0x38,%rax
mov    %rax,0x10(%rsp)
movzbl %bl,%esi
lea    0xe94(%rip),%r13
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %bh,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %r14b,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %bpl,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %r12b,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl %r15b,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_byte_l(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i8*
store i64 %0, i64* %2
%5 = bitcast i64* %2 to i8*
store i8* %5, i8** %4
store i32 0, i32* %3
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = icmp ult i64 %8, 8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
br label %17
17: ; preds = %10
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %6
20: ; preds = %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @print_byte_l(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = trunc i64 %0 to i32
%4 = lshr i32 %3, 8
%5 = trunc i64 %0 to i32
%6 = lshr i32 %5, 16
%7 = trunc i64 %0 to i32
%8 = lshr i32 %7, 24
%9 = lshr i64 %0, 32
%10 = trunc i64 %9 to i32
%11 = lshr i64 %0, 40
%12 = trunc i64 %11 to i32
%13 = lshr i64 %0, 48
%14 = trunc i64 %13 to i32
%15 = lshr i64 %0, 56
%16 = trunc i64 %15 to i32
%17 = and i32 %2, 255
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = and i32 %4, 255
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = and i32 %6, 255
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%24 = and i32 %10, 255
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = and i32 %12, 255
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = and i32 %14, 255
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
%31 = tail call i32 @putchar(i32 10)
ret void
}