#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*/ memcpy(unsigned char *, long long *, int);
int /*<<< orphan*/ printf(char *, ...);
void print64bit(long long int value) {
  unsigned char tmp[8];
  int i;
  memcpy(tmp, &value, 8);
  printf("0x");
  for (i = 7; i >= 0; i--)
    printf("%02x", tmp[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<print64bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1182 <print64bit+0x62>
movslq -0x14(%rbp),%rax
movzbl -0x10(%rbp,%rax,1),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1153 <print64bit+0x33>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print64bit>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1050 <memcpy@plt>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x7(%rsp),%esi
lea    0xe9d(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x6(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x5(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
@.str.1 = [5 x i8] c"%02x\00"
define void @print64bit(i64 %0) {
%2 = alloca i64
%3 = alloca [8 x i8]
store i64 %0, i64* %2
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = call i32 @memcpy(i8* %4, i64* %2, i32 8)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i8, i8* %4
%36 = zext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = call i32 @putchar(i32 10)
ret void
}