#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ proc_tag(char **, int, char **, int *, char *);
char *proc_fake(char *inblk, int *len, char *optfile) {
  char *newblk, *oldblk, *npos, *ppos;
  int outlen;
  oldblk = inblk;
  ppos = oldblk;
  if (*len == 0)
    return NULL;
  newblk = (char *)malloc(*len + 1);
  memset(newblk, 0, *len + 1);
  npos = newblk;
  outlen = 0;
  if (proc_tag(&ppos, *len, &npos, &outlen, optfile) < 0) {
    return NULL;
  }
  free(inblk);
  *len = outlen;
  return newblk;
}


x86 assembly (clang, -O0):
<proc_fake>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    117e <proc_fake+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    11ff <proc_fake+0xbf>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%r8
lea    -0x40(%rbp),%rdi
lea    -0x38(%rbp),%rdx
lea    -0x44(%rbp),%rcx
call   1060 <proc_tag@plt>
cmp    $0x0,%rax
jge    11e5 <proc_fake+0xa5>
movq   $0x0,-0x8(%rbp)
jmp    11ff <proc_fake+0xbf>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x44(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proc_fake>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
mov    %rdi,0x10(%rsp)
mov    (%rsi),%edi
test   %edi,%edi
je     11bc <proc_fake+0x7c>
mov    %rdx,%r12
mov    %rsi,%rbx
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    (%rbx),%edx
add    $0x1,%edx
xor    %r13d,%r13d
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r15,0x18(%rsp)
movl   $0x0,0xc(%rsp)
mov    (%rbx),%esi
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r12,%r8
call   1060 <proc_tag@plt>
test   %rax,%rax
js     11bf <proc_fake+0x7f>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%eax
mov    %eax,(%rbx)
mov    %r15,%r13
jmp    11bf <proc_fake+0x7f>
xor    %r13d,%r13d
mov    %r13,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @proc_fake(i8* %0, i32* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%13 = load i8*, i8** %5
store i8* %13, i8** %9
%14 = load i8*, i8** %9
store i8* %14, i8** %11
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %3
store i8* null, i8** %4
br label %43
19: ; preds = %3
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
%29 = call i32 @memset(i8* %25, i32 0, i32 %28)
%30 = load i8*, i8** %8
store i8* %30, i8** %10
store i32 0, i32* %12
%31 = load i32*, i32** %6
%32 = load i32, i32* %31
%33 = load i8*, i8** %7
%34 = call i64 @proc_tag(i8** %11, i32 %32, i8** %10, i32* %12, i8* %33)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %19
store i8* null, i8** %4
br label %43
37: ; preds = %19
%38 = load i8*, i8** %5
%39 = call i32 @free(i8* %38)
%40 = load i32, i32* %12
%41 = load i32*, i32** %6
store i32 %40, i32* %41
%42 = load i8*, i8** %8
store i8* %42, i8** %4
br label %43
43: ; preds = %37, %36, %18
%44 = load i8*, i8** %4
ret i8* %44
}

LLVM IR (-O2):
define i8* @proc_fake(i8* %0, i32* nocapture %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast i8** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = bitcast i32* %6 to i8*
store i8* %0, i8** %5
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %3
%13 = add nsw i32 %10, 1
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
%18 = tail call i32 @memset(i8* %15, i32 0, i32 %17)
store i8* %15, i8** %4
store i32 0, i32* %6
%19 = load i32, i32* %1
%20 = call i64 @proc_tag(i8** %5, i32 %19, i8** %4, i32* %6, i8* %2)
%21 = icmp slt i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %12
%23 = call i32 @free(i8* %0)
%24 = load i32, i32* %6
store i32 %24, i32* %1
br label %25
25: ; preds = %12, %3, %22
%26 = phi i8* [ %15, %22 ], [ null, %3 ], [ null, %12 ]
ret i8* %26
}