#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 protoent {
  char **p_aliases;
  int /*<<< orphan*/ p_name;
};

/* Variables and functions */
int /*<<< orphan*/ _xfree(char *);
void JOEfreeprotoent(struct protoent *p) {
  char **a;
  do {
    char **_p = (char **)&(p->p_name);
    _xfree(*_p);
    *_p = 0;
  } while (0);
  if (p->p_aliases != NULL) {
    for (a = p->p_aliases; *a != NULL; a++) {
      do {
        char **_p = (char **)&(*a);
        _xfree(*_p);
        *_p = 0;
      } while (0);
    }
  }
  do {
    char **_p = (char **)&(p);
    _xfree(*_p);
    *_p = 0;
  } while (0);
}


x86 assembly (clang, -O0):
<JOEfreeprotoent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a5 <JOEfreeprotoent+0x95>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a0 <JOEfreeprotoent+0x90>
jmp    116b <JOEfreeprotoent+0x5b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
jmp    118f <JOEfreeprotoent+0x7f>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1158 <JOEfreeprotoent+0x48>
jmp    11a5 <JOEfreeprotoent+0x95>
jmp    11aa <JOEfreeprotoent+0x9a>
lea    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JOEfreeprotoent>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x8(%rdi),%rdi
call   1030 <_xfree@plt>
movq   $0x0,0x8(%r14)
mov    (%r14),%rbx
test   %rbx,%rbx
je     1159 <JOEfreeprotoent+0x49>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1159 <JOEfreeprotoent+0x49>
add    $0x8,%rbx
nopl   0x0(%rax)
call   1030 <_xfree@plt>
movq   $0x0,-0x8(%rbx)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <JOEfreeprotoent+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_xfree@plt>

LLVM IR (-O0):
%struct.protoent = type { i8**, i32 }
define void @JOEfreeprotoent(%struct.protoent* %0) {
%2 = alloca %struct.protoent*
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8**
store %struct.protoent* %0, %struct.protoent** %2
br label %7
7: ; preds = %1
%8 = load %struct.protoent*, %struct.protoent** %2
%9 = getelementptr inbounds %struct.protoent, %struct.protoent* %8, i32 0, i32 1
%10 = bitcast i32* %9 to i8**
store i8** %10, i8*** %4
%11 = load i8**, i8*** %4
%12 = load i8*, i8** %11
%13 = call i32 @_xfree(i8* %12)
%14 = load i8**, i8*** %4
store i8* null, i8** %14
br label %15
15: ; preds = %7
%16 = load %struct.protoent*, %struct.protoent** %2
%17 = getelementptr inbounds %struct.protoent, %struct.protoent* %16, i32 0, i32 0
%18 = load i8**, i8*** %17
%19 = icmp ne i8** %18, null
br i1 %19, label %20, label %40
20: ; preds = %15
%21 = load %struct.protoent*, %struct.protoent** %2
%22 = getelementptr inbounds %struct.protoent, %struct.protoent* %21, i32 0, i32 0
%23 = load i8**, i8*** %22
store i8** %23, i8*** %3
br label %24
24: ; preds = %36, %20
%25 = load i8**, i8*** %3
%26 = load i8*, i8** %25
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %39
28: ; preds = %24
br label %29
29: ; preds = %28
%30 = load i8**, i8*** %3
store i8** %30, i8*** %5
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 @_xfree(i8* %32)
%34 = load i8**, i8*** %5
store i8* null, i8** %34
br label %35
35: ; preds = %29
br label %36
36: ; preds = %35
%37 = load i8**, i8*** %3
%38 = getelementptr inbounds i8*, i8** %37, i32 1
store i8** %38, i8*** %3
br label %24
39: ; preds = %24
br label %40
40: ; preds = %39, %15
br label %41
41: ; preds = %40
%42 = bitcast %struct.protoent** %2 to i8**
store i8** %42, i8*** %6
%43 = load i8**, i8*** %6
%44 = load i8*, i8** %43
%45 = call i32 @_xfree(i8* %44)
%46 = load i8**, i8*** %6
store i8* null, i8** %46
br label %47
47: ; preds = %41
ret void
}

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