#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*/ int32_t;

/* Variables and functions */
int h(char const);
int /*<<< orphan*/ rgba_from_rgb(int, int, int);
int32_t rgba_from_hex3_string(const char *str) {
  return rgba_from_rgb((h(str[0]) << 4) + h(str[0]),
                       (h(str[1]) << 4) + h(str[1]),
                       (h(str[2]) << 4) + h(str[2]));
}


x86 assembly (clang, -O0):
<rgba_from_hex3_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <h@plt>
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <h@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <h@plt>
shl    $0x4,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <h@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <h@plt>
shl    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <h@plt>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
add    %eax,%edx
call   1040 <rgba_from_rgb@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgba_from_hex3_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1030 <h@plt>
mov    %eax,%r14d
shl    $0x4,%r14d
movsbl (%r15),%edi
call   1030 <h@plt>
add    %eax,%r14d
movsbl 0x1(%r15),%edi
call   1030 <h@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x1(%r15),%edi
call   1030 <h@plt>
add    %eax,%ebp
movsbl 0x2(%r15),%edi
call   1030 <h@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x2(%r15),%edi
call   1030 <h@plt>
add    %eax,%ebx
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <rgba_from_rgb@plt>

LLVM IR (-O0):
define i32 @rgba_from_hex3_string(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = call i32 @h(i8 signext %5)
%7 = shl i32 %6, 4
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = call i32 @h(i8 signext %10)
%12 = add nsw i32 %7, %11
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = call i32 @h(i8 signext %15)
%17 = shl i32 %16, 4
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = call i32 @h(i8 signext %20)
%22 = add nsw i32 %17, %21
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = call i32 @h(i8 signext %25)
%27 = shl i32 %26, 4
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = load i8, i8* %29
%31 = call i32 @h(i8 signext %30)
%32 = add nsw i32 %27, %31
%33 = call i32 @rgba_from_rgb(i32 %12, i32 %22, i32 %32)
ret i32 %33
}

LLVM IR (-O2):
define i32 @rgba_from_hex3_string(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @h(i8 signext %2)
%4 = shl i32 %3, 4
%5 = load i8, i8* %0
%6 = tail call i32 @h(i8 signext %5)
%7 = add nsw i32 %6, %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call i32 @h(i8 signext %9)
%11 = shl i32 %10, 4
%12 = load i8, i8* %8
%13 = tail call i32 @h(i8 signext %12)
%14 = add nsw i32 %13, %11
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
%17 = tail call i32 @h(i8 signext %16)
%18 = shl i32 %17, 4
%19 = load i8, i8* %15
%20 = tail call i32 @h(i8 signext %19)
%21 = add nsw i32 %20, %18
%22 = tail call i32 @rgba_from_rgb(i32 %7, i32 %14, i32 %21)
ret i32 %22
}