#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*/ blob_new_data(unsigned char *, size_t);
int hc2i(char);
unsigned char *malloc(int);
int /*<<< orphan*/ pushblob(int /*<<< orphan*/);
void procblob(char *cmd) {
  cmd++;
  size_t sz = 0;
  char *ncmd = cmd;
  unsigned char *blob;
  size_t i = 0;
  while (*ncmd && *ncmd != ']')
    ncmd++;
  blob = malloc(ncmd - cmd);
  sz = ncmd - cmd;
  while (*cmd && *cmd != ']') {
    char d1 = *(cmd++);
    char d2 = *(cmd++);
    blob[i++] = (hc2i(d1) << 4) | hc2i(d2);
  }
  pushblob(blob_new_data(blob, i));
}


x86 assembly (clang, -O0):
<procblob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2b(%rbp)
je     1195 <procblob+0x55>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
setne  %al
mov    %al,-0x2b(%rbp)
mov    -0x2b(%rbp),%al
test   $0x1,%al
jne    11a5 <procblob+0x65>
jmp    11b6 <procblob+0x76>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1170 <procblob+0x30>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2c(%rbp)
je     1200 <procblob+0xc0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
setne  %al
mov    %al,-0x2c(%rbp)
mov    -0x2c(%rbp),%al
test   $0x1,%al
jne    1210 <procblob+0xd0>
jmp    1274 <procblob+0x134>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x2a(%rbp)
movsbl -0x29(%rbp),%edi
call   1030 <hc2i@plt>
shl    $0x4,%eax
mov    %eax,-0x30(%rbp)
movsbl -0x2a(%rbp),%edi
call   1030 <hc2i@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
or     %ecx,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x28(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    11db <procblob+0x9b>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <blob_new_data@plt>
mov    %eax,%edi
call   1050 <pushblob@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<procblob>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
xor    %edi,%edi
nopl   (%rax)
movzbl 0x1(%r15,%rdi,1),%eax
test   %al,%al
je     1164 <procblob+0x24>
cmp    $0x5d,%al
je     1164 <procblob+0x24>
add    $0x1,%rdi
jmp    1150 <procblob+0x10>
call   1040 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl 0x1(%r15,%rbx,2),%eax
test   %al,%al
je     11a5 <procblob+0x65>
cmp    $0x5d,%al
je     11a5 <procblob+0x65>
movsbl 0x2(%r15,%rbx,2),%r12d
movsbl %al,%edi
call   1030 <hc2i@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
mov    %r12d,%edi
call   1030 <hc2i@plt>
or     %ebp,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
jmp    1170 <procblob+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <blob_new_data@plt>
mov    %eax,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <pushblob@plt>

LLVM IR (-O0):
define void @procblob(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8
%8 = alloca i8
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
store i64 0, i64* %3
%11 = load i8*, i8** %2
store i8* %11, i8** %4
store i64 0, i64* %6
br label %12
12: ; preds = %24, %1
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 93
br label %22
22: ; preds = %17, %12
%23 = phi i1 [ false, %12 ], [ %21, %17 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
br label %12
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = load i8*, i8** %2
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
store i8* %34, i8** %5
%35 = load i8*, i8** %4
%36 = load i8*, i8** %2
%37 = ptrtoint i8* %35 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
store i64 %39, i64* %3
br label %40
40: ; preds = %52, %27
%41 = load i8*, i8** %2
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i8*, i8** %2
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 93
br label %50
50: ; preds = %45, %40
%51 = phi i1 [ false, %40 ], [ %49, %45 ]
br i1 %51, label %52, label %70
52: ; preds = %50
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %2
%55 = load i8, i8* %53
store i8 %55, i8* %7
%56 = load i8*, i8** %2
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %2
%58 = load i8, i8* %56
store i8 %58, i8* %8
%59 = load i8, i8* %7
%60 = call i32 @hc2i(i8 signext %59)
%61 = shl i32 %60, 4
%62 = load i8, i8* %8
%63 = call i32 @hc2i(i8 signext %62)
%64 = or i32 %61, %63
%65 = trunc i32 %64 to i8
%66 = load i8*, i8** %5
%67 = load i64, i64* %6
%68 = add i64 %67, 1
store i64 %68, i64* %6
%69 = getelementptr inbounds i8, i8* %66, i64 %67
store i8 %65, i8* %69
br label %40
70: ; preds = %50
%71 = load i8*, i8** %5
%72 = load i64, i64* %6
%73 = call i32 @blob_new_data(i8* %71, i64 %72)
%74 = call i32 @pushblob(i32 %73)
ret void
}

LLVM IR (-O2):
define void @procblob(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
br label %3
3: ; preds = %6, %1
%4 = phi i8* [ %2, %1 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %8
i8 93, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3, %3
%9 = ptrtoint i8* %4 to i64
%10 = ptrtoint i8* %2 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = tail call i8* @malloc(i32 %12)
br label %14
14: ; preds = %18, %8
%15 = phi i64 [ 0, %8 ], [ %27, %18 ]
%16 = phi i8* [ %2, %8 ], [ %20, %18 ]
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 0, label %29
i8 93, label %29
]
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %16, i64 1
%20 = getelementptr inbounds i8, i8* %16, i64 2
%21 = load i8, i8* %19
%22 = tail call i32 @hc2i(i8 signext %17)
%23 = shl i32 %22, 4
%24 = tail call i32 @hc2i(i8 signext %21)
%25 = or i32 %23, %24
%26 = trunc i32 %25 to i8
%27 = add i64 %15, 1
%28 = getelementptr inbounds i8, i8* %13, i64 %15
store i8 %26, i8* %28
br label %14
29: ; preds = %14, %14
%30 = tail call i32 @blob_new_data(i8* %13, i64 %15)
%31 = tail call i32 @pushblob(i32 %30)
ret void
}