#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 rnode {
  int dummy;
};
struct llist {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_child(struct rnode *, struct rnode *);
int /*<<< orphan*/ append_element(struct llist *, struct rnode *);
struct rnode *create_rnode(char *, char *);
scalar_t__ geo_has_children(double);
int geo_visit_leaf(struct rnode *leaf, double prob_node_has_children,
                   struct llist *leaves_queue) {
  if (geo_has_children(prob_node_has_children)) {
    struct rnode *kid1 = create_rnode("kid1", "");
    if (NULL == kid1)
      return 0;
    struct rnode *kid2 = create_rnode("kid2", "");
    if (NULL == kid2)
      return 0;
    if (!add_child(leaf, kid1))
      return 0;
    if (!add_child(leaf, kid2))
      return 0;
    if (!append_element(leaves_queue, kid1))
      return 0;
    if (!append_element(leaves_queue, kid2))
      return 0;
  } else {
  }
  return 1;
}


x86 assembly (clang, -O0):
<geo_visit_leaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <geo_has_children@plt>
cmp    $0x0,%rax
je     1254 <geo_visit_leaf+0x114>
lea    0xe90(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <create_rnode@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    1198 <geo_visit_leaf+0x58>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
lea    0xe66(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1060 <create_rnode@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    11c7 <geo_visit_leaf+0x87>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <add_child@plt>
cmp    $0x0,%eax
jne    11e9 <geo_visit_leaf+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <add_child@plt>
cmp    $0x0,%eax
jne    120b <geo_visit_leaf+0xcb>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <append_element@plt>
cmp    $0x0,%eax
jne    122d <geo_visit_leaf+0xed>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <append_element@plt>
cmp    $0x0,%eax
jne    124f <geo_visit_leaf+0x10f>
movl   $0x0,-0x4(%rbp)
jmp    1260 <geo_visit_leaf+0x120>
jmp    1259 <geo_visit_leaf+0x119>
jmp    1259 <geo_visit_leaf+0x119>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geo_visit_leaf>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <geo_has_children@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     11d2 <geo_visit_leaf+0x92>
lea    0xe9b(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <create_rnode@plt>
test   %rax,%rax
je     11d0 <geo_visit_leaf+0x90>
mov    %rax,%r12
lea    0xe85(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <create_rnode@plt>
test   %rax,%rax
je     11d0 <geo_visit_leaf+0x90>
mov    %rax,%r13
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <add_child@plt>
test   %eax,%eax
je     11d0 <geo_visit_leaf+0x90>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <add_child@plt>
test   %eax,%eax
je     11d0 <geo_visit_leaf+0x90>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <append_element@plt>
test   %eax,%eax
je     11d0 <geo_visit_leaf+0x90>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <append_element@plt>
test   %eax,%eax
jne    11d2 <geo_visit_leaf+0x92>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rnode = type { i32 }
%struct.llist = type { i32 }
@.str = [5 x i8] c"kid1\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"kid2\00"
define i32 @geo_visit_leaf(%struct.rnode* %0, double %1, %struct.llist* %2) {
%4 = alloca i32
%5 = alloca %struct.rnode*
%6 = alloca double
%7 = alloca %struct.llist*
%8 = alloca %struct.rnode*
%9 = alloca %struct.rnode*
store %struct.rnode* %0, %struct.rnode** %5
store double %1, double* %6
store %struct.llist* %2, %struct.llist** %7
%10 = load double, double* %6
%11 = call i64 @geo_has_children(double %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %48
13: ; preds = %3
%14 = call %struct.rnode* @create_rnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store %struct.rnode* %14, %struct.rnode** %8
%15 = load %struct.rnode*, %struct.rnode** %8
%16 = icmp eq %struct.rnode* null, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %4
br label %50
18: ; preds = %13
%19 = call %struct.rnode* @create_rnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store %struct.rnode* %19, %struct.rnode** %9
%20 = load %struct.rnode*, %struct.rnode** %9
%21 = icmp eq %struct.rnode* null, %20
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %4
br label %50
23: ; preds = %18
%24 = load %struct.rnode*, %struct.rnode** %5
%25 = load %struct.rnode*, %struct.rnode** %8
%26 = call i32 @add_child(%struct.rnode* %24, %struct.rnode* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %23
store i32 0, i32* %4
br label %50
29: ; preds = %23
%30 = load %struct.rnode*, %struct.rnode** %5
%31 = load %struct.rnode*, %struct.rnode** %9
%32 = call i32 @add_child(%struct.rnode* %30, %struct.rnode* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %29
store i32 0, i32* %4
br label %50
35: ; preds = %29
%36 = load %struct.llist*, %struct.llist** %7
%37 = load %struct.rnode*, %struct.rnode** %8
%38 = call i32 @append_element(%struct.llist* %36, %struct.rnode* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %35
store i32 0, i32* %4
br label %50
41: ; preds = %35
%42 = load %struct.llist*, %struct.llist** %7
%43 = load %struct.rnode*, %struct.rnode** %9
%44 = call i32 @append_element(%struct.llist* %42, %struct.rnode* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %41
store i32 0, i32* %4
br label %50
47: ; preds = %41
br label %49
48: ; preds = %3
br label %49
49: ; preds = %48, %47
store i32 1, i32* %4
br label %50
50: ; preds = %49, %46, %40, %34, %28, %22, %17
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
%struct.rnode = type { i32 }
%struct.llist = type { i32 }
@.str = [5 x i8] c"kid1\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"kid2\00"
define i32 @geo_visit_leaf(%struct.rnode* %0, double %1, %struct.llist* %2) {
%4 = tail call i64 @geo_has_children(double %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = tail call %struct.rnode* @create_rnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq %struct.rnode* %7, null
br i1 %8, label %24, label %9
9: ; preds = %6
%10 = tail call %struct.rnode* @create_rnode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq %struct.rnode* %10, null
br i1 %11, label %24, label %12
12: ; preds = %9
%13 = tail call i32 @add_child(%struct.rnode* %0, %struct.rnode* %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = tail call i32 @add_child(%struct.rnode* %0, %struct.rnode* %10)
%17 = icmp eq i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = tail call i32 @append_element(%struct.llist* %2, %struct.rnode* %7)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @append_element(%struct.llist* %2, %struct.rnode* %10)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %6, %9, %12, %15, %18, %21
br label %25
25: ; preds = %3, %21, %24
%26 = phi i32 [ 0, %24 ], [ 1, %21 ], [ 1, %3 ]
ret i32 %26
}