#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 */
typedef int /*<<< orphan*/ *Widget;
typedef int Bool;

/* Variables and functions */
int False;
int FindChildren(int /*<<< orphan*/ *, int /*<<< orphan*/ ***, int, int, int);
int True;
int /*<<< orphan*/ XtFree(char *);
Bool IsChild(Widget top, Widget parent, Widget child) {
  int i, num_children;
  Widget *children;
  if (parent == NULL)
    return (top == child);
  num_children = FindChildren(parent, &children, True, True, True);
  for (i = 0; i < num_children; i++)
    if (children[i] == child) {
      XtFree((char *)children);
      return (True);
    }
  XtFree((char *)children);
  return (False);
}


x86 assembly (clang, -O0):
<IsChild>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1157 <IsChild+0x37>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <IsChild+0xce>
mov    -0x18(%rbp),%rdi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    0x2e75(%rip),%rax
mov    (%rax),%ecx
mov    0x2e6c(%rip),%rax
mov    (%rax),%r8d
lea    -0x30(%rbp),%rsi
call   1040 <FindChildren@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11d9 <IsChild+0xb9>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x20(%rbp),%rax
jne    11c6 <IsChild+0xa6>
mov    -0x30(%rbp),%rdi
call   1030 <XtFree@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <IsChild+0xce>
jmp    11cb <IsChild+0xab>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <IsChild+0x6a>
mov    -0x30(%rbp),%rdi
call   1030 <XtFree@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsChild>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
test   %rsi,%rsi
je     1171 <IsChild+0x51>
mov    0x2ead(%rip),%r14
mov    (%r14),%ecx
mov    %rsp,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    %ecx,%edx
mov    %ecx,%r8d
call   1040 <FindChildren@plt>
test   %eax,%eax
jle    117b <IsChild+0x5b>
mov    (%rsp),%rdi
mov    %eax,%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %rbx,(%rdi,%rcx,8)
je     118f <IsChild+0x6f>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1160 <IsChild+0x40>
jmp    117f <IsChild+0x5f>
xor    %eax,%eax
cmp    %rbx,%rdi
sete   %al
jmp    1197 <IsChild+0x77>
mov    (%rsp),%rdi
call   1030 <XtFree@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
jmp    1197 <IsChild+0x77>
call   1030 <XtFree@plt>
mov    (%r14),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@True = global i32 0
@False = global i32 0
define i32 @IsChild(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%11 = load i32*, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = load i32*, i32** %7
%16 = icmp eq i32* %14, %15
%17 = zext i1 %16 to i32
store i32 %17, i32* %4
br label %50
18: ; preds = %3
%19 = load i32*, i32** %6
%20 = load i32, i32* @True
%21 = load i32, i32* @True
%22 = load i32, i32* @True
%23 = call i32 @FindChildren(i32* %19, i32*** %10, i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %9
store i32 0, i32* %8
br label %24
24: ; preds = %42, %18
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %45
28: ; preds = %24
%29 = load i32**, i32*** %10
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32*, i32** %29, i64 %31
%33 = load i32*, i32** %32
%34 = load i32*, i32** %7
%35 = icmp eq i32* %33, %34
br i1 %35, label %36, label %41
36: ; preds = %28
%37 = load i32**, i32*** %10
%38 = bitcast i32** %37 to i8*
%39 = call i32 @XtFree(i8* %38)
%40 = load i32, i32* @True
store i32 %40, i32* %4
br label %50
41: ; preds = %28
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %24
45: ; preds = %24
%46 = load i32**, i32*** %10
%47 = bitcast i32** %46 to i8*
%48 = call i32 @XtFree(i8* %47)
%49 = load i32, i32* @False
store i32 %49, i32* %4
br label %50
50: ; preds = %45, %36, %13
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@True = global i32 0
@False = global i32 0
define i32 @IsChild(i32* readnone %0, i32* %1, i32* readnone %2) {
%4 = alloca i32**
%5 = bitcast i32*** %4 to i8*
%6 = icmp eq i32* %1, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = icmp eq i32* %0, %2
%9 = zext i1 %8 to i32
br label %36
10: ; preds = %3
%11 = load i32, i32* @True
%12 = call i32 @FindChildren(i32* %1, i32*** %4, i32 %11, i32 %11, i32 %11)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = bitcast i32*** %4 to i8**
%16 = load i8*, i8** %15
br label %32
17: ; preds = %10
%18 = load i32**, i32*** %4
%19 = zext i32 %12 to i64
%20 = bitcast i32** %18 to i8*
br label %23
21: ; preds = %23
%22 = icmp eq i64 %28, %19
br i1 %22, label %32, label %23
23: ; preds = %17, %21
%24 = phi i64 [ 0, %17 ], [ %28, %21 ]
%25 = getelementptr inbounds i32*, i32** %18, i64 %24
%26 = load i32*, i32** %25
%27 = icmp eq i32* %26, %2
%28 = add nuw nsw i64 %24, 1
br i1 %27, label %29, label %21
29: ; preds = %23
%30 = call i32 @XtFree(i8* %20)
%31 = load i32, i32* @True
br label %36
32: ; preds = %21, %14
%33 = phi i8* [ %16, %14 ], [ %20, %21 ]
%34 = call i32 @XtFree(i8* %33)
%35 = load i32, i32* @False
br label %36
36: ; preds = %32, %29, %7
%37 = phi i32 [ %9, %7 ], [ %31, %29 ], [ %35, %32 ]
ret i32 %37
}