#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 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;
  switch (lmo_translate(s, l, &tr, &trlen)) {
  case 0:
    luastr_escape(out, tr, trlen, escape_xml);
    break;
  case -1:
    luastr_escape(out, s, l, escape_xml);
    break;
  default:
    break;
  }
}


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>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
sub    $0xffffffff,%eax
je     1185 <luastr_translate+0x65>
jmp    115d <luastr_translate+0x3d>
mov    -0x28(%rbp),%eax
test   %eax,%eax
jne    119d <luastr_translate+0x7d>
jmp    116d <luastr_translate+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <luastr_escape@plt>
jmp    11a2 <luastr_translate+0x82>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <luastr_escape@plt>
jmp    11a2 <luastr_translate+0x82>
jmp    11a2 <luastr_translate+0x82>
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>
cmp    $0xffffffff,%eax
je     1160 <luastr_translate+0x40>
test   %eax,%eax
jne    1170 <luastr_translate+0x50>
mov    0x10(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    %r15,%rdi
jmp    1168 <luastr_translate+0x48>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
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)
switch i32 %13, label %26 [
i32 0, label %14
i32 -1, label %20
]
14: ; preds = %4
%15 = load %struct.template_buffer*, %struct.template_buffer** %5
%16 = load i8*, i8** %9
%17 = load i32, i32* %10
%18 = load i32, i32* %8
%19 = call i32 @luastr_escape(%struct.template_buffer* %15, i8* %16, i32 %17, i32 %18)
br label %27
20: ; preds = %4
%21 = load %struct.template_buffer*, %struct.template_buffer** %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @luastr_escape(%struct.template_buffer* %21, i8* %22, i32 %23, i32 %24)
br label %27
26: ; preds = %4
br label %27
27: ; preds = %26, %20, %14
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)
switch i32 %9, label %16 [
i32 0, label %10
i32 -1, label %14
]
10: ; preds = %4
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @luastr_escape(%struct.template_buffer* %0, i8* %11, i32 %12, i32 %3)
br label %16
14: ; preds = %4
%15 = call i32 @luastr_escape(%struct.template_buffer* %0, i8* %1, i32 %2, i32 %3)
br label %16
16: ; preds = %4, %14, %10
ret void
}