#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void fxmlDecodeCDATA(char **in, char **out) {
  char *s = *in;
  char *e;
  if (0 != strncmp(s, "<![CDATA[", strlen("<![CDATA["))) {
    fprintf(stderr, "FXML: cannot parse non CDATA tag as CDATA.\n");
    return;
  }
  s += strlen("<!CDATA[") + 1;
  e = strstr(s, "]]>");
  if (!e) {
    fprintf(stderr, "FXML: unexpected end of input in fxmlDecodeCDATA.\n");
    return;
  }
  strncpy(*out, s, e - s);
  *out += e - s;
  *in = e + strlen("]]>");
}


x86 assembly (clang, -O0):
<fxmlDecodeCDATA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe86(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe74(%rip),%rsi
call   1040 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11b9 <fxmlDecodeCDATA+0x69>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1267 <fxmlDecodeCDATA+0x117>
lea    0xe76(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1211 <fxmlDecodeCDATA+0xc1>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1267 <fxmlDecodeCDATA+0x117>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rax,%rcx
mov    -0x10(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xded(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fxmlDecodeCDATA>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rbx
lea    0xe97(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11a1 <fxmlDecodeCDATA+0x51>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <fprintf@plt>
lea    0xe8e(%rip),%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%r13
add    $0x1,%r13
lea    0xe81(%rip),%rsi
mov    %r13,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     1202 <fxmlDecodeCDATA+0xb2>
mov    %rax,%r12
mov    (%r14),%rdi
mov    %rax,%rbx
sub    %r13,%rbx
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
add    %rbx,(%r14)
lea    0xe54(%rip),%rdi
call   1050 <strlen@plt>
cltq
add    %r12,%rax
mov    %rax,(%r15)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
jmp    1193 <fxmlDecodeCDATA+0x43>

LLVM IR (-O0):
@.str = [10 x i8] c"<![CDATA[\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"FXML: cannot parse non CDATA tag as CDATA.\0A\00"
@.str.2 = [9 x i8] c"<!CDATA[\00"
@.str.3 = [4 x i8] c"]]>\00"
@.str.4 = [51 x i8] c"FXML: unexpected end of input in fxmlDecodeCDATA.\0A\00"
define void @fxmlDecodeCDATA(i8** %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %3
store i8** %1, i8*** %4
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp ne i64 0, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %53
16: ; preds = %2
%17 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%18 = add nsw i32 %17, 1
%19 = load i8*, i8** %5
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = call i8* @strstr(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %16
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
br label %53
29: ; preds = %16
%30 = load i8**, i8*** %4
%31 = load i8*, i8** %30
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = load i8*, i8** %5
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
%38 = trunc i64 %37 to i32
%39 = call i32 @strncpy(i8* %31, i8* %32, i32 %38)
%40 = load i8*, i8** %6
%41 = load i8*, i8** %5
%42 = ptrtoint i8* %40 to i64
%43 = ptrtoint i8* %41 to i64
%44 = sub i64 %42, %43
%45 = load i8**, i8*** %4
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i64 %44
store i8* %47, i8** %45
%48 = load i8*, i8** %6
%49 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8**, i8*** %3
store i8* %51, i8** %52
br label %53
53: ; preds = %29, %26, %13
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"<![CDATA[\00"
@stderr = global i32 0
@.str.1 = [44 x i8] c"FXML: cannot parse non CDATA tag as CDATA.\0A\00"
@.str.2 = [9 x i8] c"<!CDATA[\00"
@.str.3 = [4 x i8] c"]]>\00"
@.str.4 = [51 x i8] c"FXML: unexpected end of input in fxmlDecodeCDATA.\0A\00"
define void @fxmlDecodeCDATA(i8** nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %0
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %32
10: ; preds = %2
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %3, i64 %13
%15 = tail call i8* @strstr(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
br label %32
20: ; preds = %10
%21 = load i8*, i8** %1
%22 = ptrtoint i8* %15 to i64
%23 = ptrtoint i8* %14 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = tail call i32 @strncpy(i8* %21, i8* %14, i32 %25)
%27 = load i8*, i8** %1
%28 = getelementptr inbounds i8, i8* %27, i64 %24
store i8* %28, i8** %1
%29 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %15, i64 %30
store i8* %31, i8** %0
br label %32
32: ; preds = %20, %17, %7
ret void
}