#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 */
struct lm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ jsonStringEscapeBuf(char *, char *, int);
int jsonStringEscapeSize(char *);
char *lmAlloc(struct lm *, int);
char *needMem(int);
char *jsonStringEscapeLm(char *inString, struct lm *lm) {
  int outSize = jsonStringEscapeSize(inString);
  char *outString = lm ? lmAlloc(lm, outSize) : needMem(outSize);
  jsonStringEscapeBuf(inString, outString, outSize);
  return outString;
}


x86 assembly (clang, -O0):
<jsonStringEscapeLm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <jsonStringEscapeSize@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <jsonStringEscapeLm+0x3c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <lmAlloc@plt>
mov    %rax,-0x28(%rbp)
jmp    1188 <jsonStringEscapeLm+0x48>
mov    -0x14(%rbp),%edi
call   1050 <needMem@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <jsonStringEscapeBuf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsonStringEscapeLm>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <jsonStringEscapeSize@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     1162 <jsonStringEscapeLm+0x22>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <lmAlloc@plt>
jmp    1169 <jsonStringEscapeLm+0x29>
mov    %ebp,%edi
call   1050 <needMem@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1040 <jsonStringEscapeBuf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lm = type { i32 }
define i8* @jsonStringEscapeLm(i8* %0, %struct.lm* %1) {
%3 = alloca i8*
%4 = alloca %struct.lm*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store %struct.lm* %1, %struct.lm** %4
%7 = load i8*, i8** %3
%8 = call i32 @jsonStringEscapeSize(i8* %7)
store i32 %8, i32* %5
%9 = load %struct.lm*, %struct.lm** %4
%10 = icmp ne %struct.lm* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load %struct.lm*, %struct.lm** %4
%13 = load i32, i32* %5
%14 = call i8* @lmAlloc(%struct.lm* %12, i32 %13)
br label %18
15: ; preds = %2
%16 = load i32, i32* %5
%17 = call i8* @needMem(i32 %16)
br label %18
18: ; preds = %15, %11
%19 = phi i8* [ %14, %11 ], [ %17, %15 ]
store i8* %19, i8** %6
%20 = load i8*, i8** %3
%21 = load i8*, i8** %6
%22 = load i32, i32* %5
%23 = call i32 @jsonStringEscapeBuf(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %6
ret i8* %24
}

LLVM IR (-O2):
%struct.lm = type { i32 }
define i8* @jsonStringEscapeLm(i8* %0, %struct.lm* %1) {
%3 = tail call i32 @jsonStringEscapeSize(i8* %0)
%4 = icmp eq %struct.lm* %1, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i8* @lmAlloc(%struct.lm* %1, i32 %3)
br label %9
7: ; preds = %2
%8 = tail call i8* @needMem(i32 %3)
br label %9
9: ; preds = %7, %5
%10 = phi i8* [ %6, %5 ], [ %8, %7 ]
%11 = tail call i32 @jsonStringEscapeBuf(i8* %0, i8* %10, i32 %3)
ret i8* %10
}