#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 */
unsigned char *decodeBase64(char *, size_t *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
char *strstr(char *, char *);
unsigned char *getXMLData(char **location, size_t *dataLength) {
  char *curLoc;
  char *tagEnd;
  char *encodedData;
  unsigned char *toReturn;
  size_t strLen;
  curLoc = *location;
  curLoc = strstr(curLoc, "<data>");
  if (!curLoc)
    return NULL;
  curLoc += sizeof("<data>") - 1;
  tagEnd = strstr(curLoc, "</data>");
  strLen = (size_t)(tagEnd - curLoc);
  encodedData = (char *)malloc(strLen + 1);
  memcpy(encodedData, curLoc, strLen);
  encodedData[strLen] = '\0';
  curLoc = tagEnd + sizeof("</data>") - 1;
  *location = curLoc;
  toReturn = decodeBase64(encodedData, dataLength);
  free(encodedData);
  return toReturn;
}


x86 assembly (clang, -O0):
<getXMLData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1197 <getXMLData+0x47>
movq   $0x0,-0x8(%rbp)
jmp    1231 <getXMLData+0xe1>
mov    -0x20(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <decodeBase64@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getXMLData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rdi
lea    0xe95(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     11d6 <getXMLData+0x86>
mov    %rax,%rbx
add    $0x6,%rbx
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    %rax,%r12
mov    %rax,%r13
sub    %rbx,%r13
lea    0x1(%r13),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <memcpy@plt>
movb   $0x0,0x0(%rbp,%r13,1)
add    $0x7,%r12
mov    %r12,(%r15)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <decodeBase64@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
jmp    11d8 <getXMLData+0x88>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<data>\00"
@.str.1 = [8 x i8] c"</data>\00"
define i8* @getXMLData(i8** %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8** %0, i8*** %4
store i64* %1, i64** %5
%11 = load i8**, i8*** %4
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %2
store i8* null, i8** %3
br label %50
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 6
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i8* @strstr(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = load i8*, i8** %6
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
store i64 %27, i64* %10
%28 = load i64, i64* %10
%29 = add i64 %28, 1
%30 = call i64 @malloc(i64 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = load i8*, i8** %6
%34 = load i64, i64* %10
%35 = call i32 @memcpy(i8* %32, i8* %33, i64 %34)
%36 = load i8*, i8** %8
%37 = load i64, i64* %10
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 8
%41 = getelementptr inbounds i8, i8* %40, i64 -1
store i8* %41, i8** %6
%42 = load i8*, i8** %6
%43 = load i8**, i8*** %4
store i8* %42, i8** %43
%44 = load i8*, i8** %8
%45 = load i64*, i64** %5
%46 = call i8* @decodeBase64(i8* %44, i64* %45)
store i8* %46, i8** %9
%47 = load i8*, i8** %8
%48 = call i32 @free(i8* %47)
%49 = load i8*, i8** %9
store i8* %49, i8** %3
br label %50
50: ; preds = %18, %17
%51 = load i8*, i8** %3
ret i8* %51
}

LLVM IR (-O2):
@.str = [7 x i8] c"<data>\00"
@.str.1 = [8 x i8] c"</data>\00"
define i8* @getXMLData(i8** nocapture %0, i64* %1) {
%3 = load i8*, i8** %0
%4 = tail call i8* @strstr(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %4, i64 6
%8 = tail call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = ptrtoint i8* %8 to i64
%10 = ptrtoint i8* %7 to i64
%11 = sub i64 %9, %10
%12 = add i64 %11, 1
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @memcpy(i8* %14, i8* %7, i64 %11)
%16 = getelementptr inbounds i8, i8* %14, i64 %11
store i8 0, i8* %16
%17 = getelementptr inbounds i8, i8* %8, i64 7
store i8* %17, i8** %0
%18 = tail call i8* @decodeBase64(i8* %14, i64* %1)
%19 = tail call i32 @free(i8* %14)
br label %20
20: ; preds = %2, %6
%21 = phi i8* [ %18, %6 ], [ null, %2 ]
ret i8* %21
}