#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 sscanf(char const *, char *, char *, void **);
char *uniquestr(char *);
void unpack_pointer(const char *text, const char **prefix,
                    void **pointer_addr) {
  if (text == NULL) {
    *prefix = NULL;
    *pointer_addr = NULL;
    return;
  }
  char tmp[256] = {0};
  int matched = sscanf(text, "\"%255[^:]:%p\"", tmp, pointer_addr);
  if (matched != 2) {
    *prefix = NULL;
    *pointer_addr = NULL;
    return;
  }
  *prefix = uniquestr(tmp);
}


x86 assembly (clang, -O0):
<unpack_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116d <unpack_pointer+0x3d>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11df <unpack_pointer+0xaf>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe6a(%rip),%rsi
call   1050 <sscanf@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x2,-0x124(%rbp)
je     11c9 <unpack_pointer+0x99>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11df <unpack_pointer+0xaf>
lea    -0x120(%rbp),%rdi
call   1040 <uniquestr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack_pointer>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
test   %rdi,%rdi
je     11c7 <unpack_pointer+0xa7>
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe56(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rcx
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jne    11c7 <unpack_pointer+0xa7>
mov    %rsp,%rdi
call   1030 <uniquestr@plt>
mov    %rax,(%r14)
jmp    11d5 <unpack_pointer+0xb5>
movq   $0x0,(%r14)
movq   $0x0,(%rbx)
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\22%255[^:]:%p\22\00"
define void @unpack_pointer(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca [256 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8**, i8*** %5
store i8* null, i8** %12
%13 = load i8**, i8*** %6
store i8* null, i8** %13
br label %29
14: ; preds = %3
%15 = bitcast [256 x i8]* %7 to i8*
%16 = load i8*, i8** %4
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = load i8**, i8*** %6
%19 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %17, i8** %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = load i8**, i8*** %5
store i8* null, i8** %23
%24 = load i8**, i8*** %6
store i8* null, i8** %24
br label %29
25: ; preds = %14
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%27 = call i8* @uniquestr(i8* %26)
%28 = load i8**, i8*** %5
store i8* %27, i8** %28
br label %29
29: ; preds = %25, %22, %11
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\22%255[^:]:%p\22\00"
define void @unpack_pointer(i8* %0, i8** nocapture writeonly %1, i8** %2) {
%4 = alloca [256 x i8]
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %7
6: ; preds = %3
store i8* null, i8** %1
store i8* null, i8** %2
br label %15
7: ; preds = %3
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8, i8** %2)
%10 = icmp eq i32 %9, 2
br i1 %10, label %12, label %11
11: ; preds = %7
store i8* null, i8** %1
store i8* null, i8** %2
br label %14
12: ; preds = %7
%13 = call i8* @uniquestr(i8* %8)
store i8* %13, i8** %1
br label %14
14: ; preds = %12, %11
br label %15
15: ; preds = %14, %6
ret void
}