#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 template_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lmo_translate(char const *, unsigned int, char **, int *);
int /*<<< orphan*/ luastr_escape(struct template_buffer *, char const *,
                                 unsigned int, int);
void luastr_translate(struct template_buffer *out, const char *s,
                      unsigned int l, int escape_xml) {
  char *tr;
  int trlen;
  if (!lmo_translate(s, l, &tr, &trlen))
    luastr_escape(out, tr, trlen, escape_xml);
  else
    luastr_escape(out, s, l, escape_xml);
}


x86 assembly (clang, -O0):
<luastr_translate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1030 <lmo_translate@plt>
cmp    $0x0,%eax
jne    116b <luastr_translate+0x4b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <luastr_escape@plt>
jmp    117e <luastr_translate+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <luastr_escape@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luastr_translate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rsi,%rdi
mov    %ebp,%esi
call   1030 <lmo_translate@plt>
test   %eax,%eax
je     1157 <luastr_translate+0x37>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
jmp    1163 <luastr_translate+0x43>
mov    0x10(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %r14d,%ecx
call   1040 <luastr_escape@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.template_buffer = type { i32 }
define void @luastr_translate(%struct.template_buffer* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.template_buffer*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store %struct.template_buffer* %0, %struct.template_buffer** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i32 @lmo_translate(i8* %11, i32 %12, i8** %9, i32* %10)
%14 = icmp ne i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %4
%16 = load %struct.template_buffer*, %struct.template_buffer** %5
%17 = load i8*, i8** %9
%18 = load i32, i32* %10
%19 = load i32, i32* %8
%20 = call i32 @luastr_escape(%struct.template_buffer* %16, i8* %17, i32 %18, i32 %19)
br label %27
21: ; preds = %4
%22 = load %struct.template_buffer*, %struct.template_buffer** %5
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = call i32 @luastr_escape(%struct.template_buffer* %22, i8* %23, i32 %24, i32 %25)
br label %27
27: ; preds = %21, %15
ret void
}

LLVM IR (-O2):
%struct.template_buffer = type { i32 }
define void @luastr_translate(%struct.template_buffer* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast i8** %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = call i32 @lmo_translate(i8* %1, i32 %2, i8** %5, i32* %6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @luastr_escape(%struct.template_buffer* %0, i8* %12, i32 %13, i32 %3)
br label %17
15: ; preds = %4
%16 = call i32 @luastr_escape(%struct.template_buffer* %0, i8* %1, i32 %2, i32 %3)
br label %17
17: ; preds = %15, %11
ret void
}