#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 */
void *malloc(scalar_t__);
int /*<<< orphan*/ mangle_deserialize(void *, scalar_t__, void *);
int /*<<< orphan*/ mangle_gc_add_ptr(void *);
int /*<<< orphan*/ strcpy(void *, char const *);
scalar_t__ strlen(void *);
void *mangle_deserialize_const(const char *a_sdata, size_t is) {
  void *os = malloc(strlen(a_sdata) + 1);
  if (os) {
    mangle_gc_add_ptr(os);
    strcpy(os, a_sdata);
    mangle_deserialize(os, strlen(os), os);
  }
  return os;
}


x86 assembly (clang, -O0):
<mangle_deserialize_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11bb <mangle_deserialize_const+0x6b>
mov    -0x18(%rbp),%rdi
call   1070 <mangle_gc_add_ptr@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <mangle_deserialize@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mangle_deserialize_const>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1196 <mangle_deserialize_const+0x46>
mov    %rbx,%rdi
call   1070 <mangle_gc_add_ptr@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1040 <mangle_deserialize@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @mangle_deserialize_const(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = add nsw i64 %7, 1
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i32 @mangle_gc_add_ptr(i8* %13)
%15 = load i8*, i8** %5
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i8*, i8** %5
%19 = load i8*, i8** %5
%20 = call i64 @strlen(i8* %19)
%21 = load i8*, i8** %5
%22 = call i32 @mangle_deserialize(i8* %18, i64 %20, i8* %21)
br label %23
23: ; preds = %12, %2
%24 = load i8*, i8** %5
ret i8* %24
}

LLVM IR (-O2):
define i8* @mangle_deserialize_const(i8* %0, i64 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 1
%5 = tail call i8* @malloc(i64 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i32 @mangle_gc_add_ptr(i8* %5)
%9 = tail call i32 @strcpy(i8* %5, i8* %0)
%10 = tail call i64 @strlen(i8* %5)
%11 = tail call i32 @mangle_deserialize(i8* %5, i64 %10, i8* %5)
br label %12
12: ; preds = %7, %2
ret i8* %5
}