#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) {
  struct xmlnode *r = NULL;
  const char *s;
  if (n == NULL) {
    return NULL;
  }
  s = XmlGetContent(n);
  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)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <XmlFindSubNode+0x30>
movq   $0x0,-0x8(%rbp)
jmp    11d1 <XmlFindSubNode+0x91>
mov    -0x10(%rbp),%rdi
call   1030 <XmlGetContent@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <XmlDestroy@plt>
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1050 <XmlParseStr@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x29(%rbp)
je     11be <XmlFindSubNode+0x7e>
mov    -0x20(%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    -0x20(%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
movq   $0x0,(%rsp)
test   %rdi,%rdi
je     11a2 <XmlFindSubNode+0x62>
mov    %rsi,%r15
call   1030 <XmlGetContent@plt>
mov    %rax,%rbx
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 %struct.xmlnode*
%7 = alloca i8*
store %struct.xmlnode* %0, %struct.xmlnode** %4
store i8* %1, i8** %5
store %struct.xmlnode* null, %struct.xmlnode** %6
%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** %7
br label %14
14: ; preds = %26, %11
%15 = call i32 @XmlDestroy(%struct.xmlnode** %6)
%16 = load i8*, i8** %7
%17 = call i8* @XmlParseStr(%struct.xmlnode** %6, i8* %16)
store i8* %17, i8** %7
br label %18
18: ; preds = %14
%19 = load %struct.xmlnode*, %struct.xmlnode** %6
%20 = icmp ne %struct.xmlnode* %19, null
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load %struct.xmlnode*, %struct.xmlnode** %6
%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** %6
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 = bitcast %struct.xmlnode** %3 to i8*
store %struct.xmlnode* null, %struct.xmlnode** %3
%5 = icmp eq %struct.xmlnode* %0, null
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = tail call i8* @XmlGetContent(%struct.xmlnode* %0)
br label %8
8: ; preds = %14, %6
%9 = phi i8* [ %7, %6 ], [ %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, %2
%20 = phi %struct.xmlnode* [ null, %2 ], [ %18, %17 ], [ null, %8 ]
ret %struct.xmlnode* %20
}