#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ decode_hex_string(char const *, int, int /*<<< orphan*/ *);
char *bson_uuid_value_from_string(char *buf, const char *src) {
  *((int32_t *)buf) = 16;
  char *loc = buf + 4;
  *(loc++) = 0x04;
  decode_hex_string(src + 0, 8, (uint8_t *)loc);
  decode_hex_string(src + 9, 4, (uint8_t *)loc + 4);
  decode_hex_string(src + 14, 4, (uint8_t *)loc + 6);
  decode_hex_string(src + 19, 4, (uint8_t *)loc + 8);
  decode_hex_string(src + 24, 12, (uint8_t *)loc + 10);
  return buf + 21;
}


x86 assembly (clang, -O0):
<bson_uuid_value_from_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x10,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x4,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x8,%esi
call   1030 <decode_hex_string@plt>
mov    -0x10(%rbp),%rdi
add    $0x9,%rdi
mov    -0x18(%rbp),%rdx
add    $0x10,%rdx
mov    $0x4,%esi
call   1030 <decode_hex_string@plt>
mov    -0x10(%rbp),%rdi
add    $0xe,%rdi
mov    -0x18(%rbp),%rdx
add    $0x18,%rdx
mov    $0x4,%esi
call   1030 <decode_hex_string@plt>
mov    -0x10(%rbp),%rdi
add    $0x13,%rdi
mov    -0x18(%rbp),%rdx
add    $0x20,%rdx
mov    $0x4,%esi
call   1030 <decode_hex_string@plt>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
mov    -0x18(%rbp),%rdx
add    $0x28,%rdx
mov    $0xc,%esi
call   1030 <decode_hex_string@plt>
mov    -0x8(%rbp),%rax
add    $0x15,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bson_uuid_value_from_string>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x10,(%rdi)
lea    0x5(%rdi),%rdx
movb   $0x4,0x4(%rdi)
mov    %rsi,%rdi
mov    $0x8,%esi
call   1030 <decode_hex_string@plt>
lea    0x9(%r14),%rdi
lea    0x15(%rbx),%r15
mov    $0x4,%esi
mov    %r15,%rdx
call   1030 <decode_hex_string@plt>
lea    0xe(%r14),%rdi
lea    0x1d(%rbx),%rdx
mov    $0x4,%esi
call   1030 <decode_hex_string@plt>
lea    0x13(%r14),%rdi
lea    0x25(%rbx),%rdx
mov    $0x4,%esi
call   1030 <decode_hex_string@plt>
add    $0x18,%r14
add    $0x2d,%rbx
mov    %r14,%rdi
mov    $0xc,%esi
mov    %rbx,%rdx
call   1030 <decode_hex_string@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @bson_uuid_value_from_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i32*
store i32 16, i32* %7
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 4
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %5
store i8 4, i8* %10
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8*, i8** %5
%15 = bitcast i8* %14 to i32*
%16 = call i32 @decode_hex_string(i8* %13, i32 8, i32* %15)
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 9
%19 = load i8*, i8** %5
%20 = bitcast i8* %19 to i32*
%21 = getelementptr inbounds i32, i32* %20, i64 4
%22 = call i32 @decode_hex_string(i8* %18, i32 4, i32* %21)
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 14
%25 = load i8*, i8** %5
%26 = bitcast i8* %25 to i32*
%27 = getelementptr inbounds i32, i32* %26, i64 6
%28 = call i32 @decode_hex_string(i8* %24, i32 4, i32* %27)
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 19
%31 = load i8*, i8** %5
%32 = bitcast i8* %31 to i32*
%33 = getelementptr inbounds i32, i32* %32, i64 8
%34 = call i32 @decode_hex_string(i8* %30, i32 4, i32* %33)
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 24
%37 = load i8*, i8** %5
%38 = bitcast i8* %37 to i32*
%39 = getelementptr inbounds i32, i32* %38, i64 10
%40 = call i32 @decode_hex_string(i8* %36, i32 12, i32* %39)
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 21
ret i8* %42
}

LLVM IR (-O2):
define i8* @bson_uuid_value_from_string(i8* %0, i8* %1) {
%3 = bitcast i8* %0 to i32*
store i32 16, i32* %3
%4 = getelementptr inbounds i8, i8* %0, i64 4
%5 = getelementptr inbounds i8, i8* %0, i64 5
store i8 4, i8* %4
%6 = bitcast i8* %5 to i32*
%7 = tail call i32 @decode_hex_string(i8* %1, i32 8, i32* %6)
%8 = getelementptr inbounds i8, i8* %1, i64 9
%9 = getelementptr inbounds i8, i8* %0, i64 21
%10 = bitcast i8* %9 to i32*
%11 = tail call i32 @decode_hex_string(i8* %8, i32 4, i32* %10)
%12 = getelementptr inbounds i8, i8* %1, i64 14
%13 = getelementptr inbounds i8, i8* %0, i64 29
%14 = bitcast i8* %13 to i32*
%15 = tail call i32 @decode_hex_string(i8* %12, i32 4, i32* %14)
%16 = getelementptr inbounds i8, i8* %1, i64 19
%17 = getelementptr inbounds i8, i8* %0, i64 37
%18 = bitcast i8* %17 to i32*
%19 = tail call i32 @decode_hex_string(i8* %16, i32 4, i32* %18)
%20 = getelementptr inbounds i8, i8* %1, i64 24
%21 = getelementptr inbounds i8, i8* %0, i64 45
%22 = bitcast i8* %21 to i32*
%23 = tail call i32 @decode_hex_string(i8* %20, i32 12, i32* %22)
ret i8* %9
}