#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 *, char *, long long);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
long long strtol(char *, int /*<<< orphan*/ *, int);
void generate(char *string) {
  char buff[3];
  int i;
  int length = strlen(string);
  char desc[200] = {0};
  for (i = length - 1; i >= 0; i--) {
    sprintf(buff, "%2X", string[i]);
    strcat(desc, buff);
  }
  long long data = strtol(desc, NULL, 16);
  printf("%-10s   <====>  %ld\n", (char *)(&data), data);
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11db <generate+0x7b>
lea    -0xb(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xe4c(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
call   1080 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xb(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <generate+0x37>
lea    -0xe0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %rax,-0xe8(%rbp)
lea    -0xe8(%rbp),%rsi
mov    -0xe8(%rbp),%rdx
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%r15
call   1030 <strlen@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0xd0(%rsp)
test   %eax,%eax
jle    1208 <generate+0xb8>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe2d(%rip),%r14
lea    0x5(%rsp),%r13
lea    0x10(%rsp),%r12
nopl   (%rax)
lea    -0x2(%rbx),%eax
movsbl (%r15,%rax,1),%edx
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <sprintf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11e0 <generate+0x90>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %rax,0x8(%rsp)
lea    0xddf(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%2X\00"
@.str.1 = [21 x i8] c"%-10s <====> %ld\0A\00"
define void @generate(i8* %0) {
%2 = alloca i8*
%3 = alloca [3 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [200 x i8]
%7 = alloca i64
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = bitcast [200 x i8]* %6 to i8*
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %4
br label %13
13: ; preds = %27, %1
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %22)
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%26 = call i32 @strcat(i8* %24, i8* %25)
br label %27
27: ; preds = %16
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %13
30: ; preds = %13
%31 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%32 = call i64 @strtol(i8* %31, i32* null, i32 16)
store i64 %32, i64* %7
%33 = bitcast i64* %7 to i8*
%34 = load i64, i64* %7
%35 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %33, i64 %34)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2X\00"
@.str.1 = [21 x i8] c"%-10s <====> %ld\0A\00"
define void @generate(i8* %0) {
%2 = alloca [3 x i8]
%3 = alloca [200 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %20
9: ; preds = %1
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %10, %9 ], [ %13, %11 ]
%13 = add nsw i64 %12, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %16)
%18 = call i32 @strcat(i8* %7, i8* %5)
%19 = icmp ugt i64 %12, 1
br i1 %19, label %11, label %20
20: ; preds = %11, %1
%21 = bitcast i64* %4 to i8*
%22 = call i64 @strtol(i8* nocapture %7, i32* null, i32 16)
store i64 %22, i64* %4
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %21, i64 %22)
ret void
}