#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 *, char *);
int /*<<< orphan*/ string_2_hex(char *, char *);
int main(void) {
  char *str = "abcd";
  char str_hex[100];
  char buf_1[100] = "abcd";
  char buf_2[100];
  string_2_hex(buf_1, buf_2);
  printf("buf_1 = %s, buf_2 = %s\n", buf_1, buf_2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movb   $0x61,-0xf0(%rbp)
movb   $0x62,-0xef(%rbp)
movb   $0x63,-0xee(%rbp)
movb   $0x64,-0xed(%rbp)
lea    -0xf0(%rbp),%rdi
lea    -0x160(%rbp),%rsi
call   1050 <string_2_hex@plt>
lea    -0xf0(%rbp),%rsi
lea    -0x160(%rbp),%rdx
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x60(%rsp)
movl   $0x64636261,(%rsp)
mov    %rsp,%rbx
lea    0x70(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <string_2_hex@plt>
lea    0xe8d(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"abcd\00"
@.str.1 = [24 x i8] c"buf_1 = %s, buf_2 = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = bitcast [100 x i8]* %4 to i8*
%7 = bitcast i8* %6 to [100 x i8]*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i32 0, i32 0
store i8 97, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i32 0, i32 1
store i8 98, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i32 0, i32 2
store i8 99, i8* %10
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i32 0, i32 3
store i8 100, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%14 = call i32 @string_2_hex(i8* %12, i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"buf_1 = %s, buf_2 = %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
store i8 97, i8* %3
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 1
store i8 98, i8* %4
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 2
store i8 99, i8* %5
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 3
store i8 100, i8* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @string_2_hex(i8* %3, i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %7)
ret i32 0
}