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

/* Variables and functions */
int /*<<< orphan*/ XmlDestroy(struct xmlnode **);
char *XmlGetContent(struct xmlnode *);
char *XmlParseStr(struct xmlnode **, char const *);
scalar_t__ XmlTagStrcmp(struct xmlnode *, char const *);
struct xmlnode *XmlFindSubNode(struct xmlnode *n, const char *tag) {
  if (n == NULL) {
    return NULL;
  }
  const char *s = XmlGetContent(n);
  struct xmlnode *r = NULL;
  do {
    XmlDestroy(&r);
    s = XmlParseStr(&r, s);
  } while (r && XmlTagStrcmp(r, tag) != 0);
  return r;
}


x86 assembly (clang, -O0):
<XmlFindSubNode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1168 <XmlFindSubNode+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11d1 <XmlFindSubNode+0x91>
mov    -0x10(%rbp),%rdi
call   1030 <XmlGetContent@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
call   1060 <XmlDestroy@plt>
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1050 <XmlParseStr@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x29(%rbp)
je     11be <XmlFindSubNode+0x7e>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <XmlTagStrcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    117d <XmlFindSubNode+0x3d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XmlFindSubNode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11a2 <XmlFindSubNode+0x62>
mov    %rsi,%r15
call   1030 <XmlGetContent@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1060 <XmlDestroy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <XmlParseStr@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11a5 <XmlFindSubNode+0x65>
mov    %rax,%rbx
mov    %r15,%rsi
call   1040 <XmlTagStrcmp@plt>
test   %rax,%rax
jne    1170 <XmlFindSubNode+0x30>
mov    (%rsp),%r14
jmp    11a5 <XmlFindSubNode+0x65>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.xmlnode = type { i32 }
define %struct.xmlnode* @XmlFindSubNode(%struct.xmlnode* %0, i8* %1) {
%3 = alloca %struct.xmlnode*
%4 = alloca %struct.xmlnode*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.xmlnode*
store %struct.xmlnode* %0, %struct.xmlnode** %4
store i8* %1, i8** %5
%8 = load %struct.xmlnode*, %struct.xmlnode** %4
%9 = icmp eq %struct.xmlnode* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store %struct.xmlnode* null, %struct.xmlnode** %3
br label %30
11: ; preds = %2
%12 = load %struct.xmlnode*, %struct.xmlnode** %4
%13 = call i8* @XmlGetContent(%struct.xmlnode* %12)
store i8* %13, i8** %6
store %struct.xmlnode* null, %struct.xmlnode** %7
br label %14
14: ; preds = %26, %11
%15 = call i32 @XmlDestroy(%struct.xmlnode** %7)
%16 = load i8*, i8** %6
%17 = call i8* @XmlParseStr(%struct.xmlnode** %7, i8* %16)
store i8* %17, i8** %6
br label %18
18: ; preds = %14
%19 = load %struct.xmlnode*, %struct.xmlnode** %7
%20 = icmp ne %struct.xmlnode* %19, null
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load %struct.xmlnode*, %struct.xmlnode** %7
%23 = load i8*, i8** %5
%24 = call i64 @XmlTagStrcmp(%struct.xmlnode* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %21, %18
%27 = phi i1 [ false, %18 ], [ %25, %21 ]
br i1 %27, label %14, label %28
28: ; preds = %26
%29 = load %struct.xmlnode*, %struct.xmlnode** %7
store %struct.xmlnode* %29, %struct.xmlnode** %3
br label %30
30: ; preds = %28, %10
%31 = load %struct.xmlnode*, %struct.xmlnode** %3
ret %struct.xmlnode* %31
}

LLVM IR (-O2):
%struct.xmlnode = type { i32 }
define %struct.xmlnode* @XmlFindSubNode(%struct.xmlnode* %0, i8* %1) {
%3 = alloca %struct.xmlnode*
%4 = icmp eq %struct.xmlnode* %0, null
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = tail call i8* @XmlGetContent(%struct.xmlnode* %0)
%7 = bitcast %struct.xmlnode** %3 to i8*
store %struct.xmlnode* null, %struct.xmlnode** %3
br label %8
8: ; preds = %14, %5
%9 = phi i8* [ %6, %5 ], [ %11, %14 ]
%10 = call i32 @XmlDestroy(%struct.xmlnode** %3)
%11 = call i8* @XmlParseStr(%struct.xmlnode** %3, i8* %9)
%12 = load %struct.xmlnode*, %struct.xmlnode** %3
%13 = icmp eq %struct.xmlnode* %12, null
br i1 %13, label %19, label %14
14: ; preds = %8
%15 = call i64 @XmlTagStrcmp(%struct.xmlnode* %12, i8* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %14
%18 = load %struct.xmlnode*, %struct.xmlnode** %3
br label %19
19: ; preds = %8, %17
%20 = phi %struct.xmlnode* [ %18, %17 ], [ null, %8 ]
br label %21
21: ; preds = %2, %19
%22 = phi %struct.xmlnode* [ %20, %19 ], [ null, %2 ]
ret %struct.xmlnode* %22
}