#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 asprintf(char **, char *, unsigned char, unsigned char, char *);
char *blackstrap_stringify_uchar_bin(unsigned char);
int /*<<< orphan*/ free(char *);
char *blackstrap_stringify_uchar(unsigned char value) {
  char *bin_str = blackstrap_stringify_uchar_bin(value);
  if (!bin_str)
    return NULL;
  char *string = NULL;
  int result = asprintf(&string, "%ud, %02xh, %sb", value, value, bin_str);
  free(bin_str);
  if (result < 0)
    return NULL;
  return string;
}


x86 assembly (clang, -O0):
<blackstrap_stringify_uchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edi
call   1040 <blackstrap_stringify_uchar_bin@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <blackstrap_stringify_uchar+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <blackstrap_stringify_uchar+0x86>
movq   $0x0,-0x20(%rbp)
mov    -0x9(%rbp),%cl
mov    -0x9(%rbp),%al
mov    -0x18(%rbp),%r8
lea    -0x20(%rbp),%rdi
lea    0xe80(%rip),%rsi
movzbl %cl,%edx
movzbl %al,%ecx
call   1050 <asprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x24(%rbp)
jge    11ae <blackstrap_stringify_uchar+0x7e>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <blackstrap_stringify_uchar+0x86>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blackstrap_stringify_uchar>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1040 <blackstrap_stringify_uchar_bin@plt>
test   %rax,%rax
je     1176 <blackstrap_stringify_uchar+0x46>
mov    %rax,%rbx
movq   $0x0,(%rsp)
movzbl %bpl,%ecx
lea    0xeab(%rip),%rsi
mov    %rsp,%rdi
mov    %ecx,%edx
mov    %rax,%r8
call   1050 <asprintf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
js     1176 <blackstrap_stringify_uchar+0x46>
mov    (%rsp),%rax
jmp    1178 <blackstrap_stringify_uchar+0x48>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%ud, %02xh, %sb\00"
define i8* @blackstrap_stringify_uchar(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8 %0, i8* %3
%7 = load i8, i8* %3
%8 = call i8* @blackstrap_stringify_uchar_bin(i8 zeroext %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i8* null, i8** %2
br label %24
12: ; preds = %1
store i8* null, i8** %5
%13 = load i8, i8* %3
%14 = load i8, i8* %3
%15 = load i8*, i8** %4
%16 = call i32 @asprintf(i8** %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 zeroext %13, i8 zeroext %14, i8* %15)
store i32 %16, i32* %6
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %12
store i8* null, i8** %2
br label %24
22: ; preds = %12
%23 = load i8*, i8** %5
store i8* %23, i8** %2
br label %24
24: ; preds = %22, %21, %11
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [16 x i8] c"%ud, %02xh, %sb\00"
define i8* @blackstrap_stringify_uchar(i8 zeroext %0) {
%2 = alloca i8*
%3 = tail call i8* @blackstrap_stringify_uchar_bin(i8 zeroext %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%7 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 zeroext %0, i8 zeroext %0, i8* %3)
%8 = call i32 @free(i8* %3)
%9 = icmp slt i32 %7, 0
%10 = load i8*, i8** %2
%11 = select i1 %9, i8* null, i8* %10
br label %12
12: ; preds = %1, %5
%13 = phi i8* [ %11, %5 ], [ null, %1 ]
ret i8* %13
}