#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 hostent {
  char **h_aliases;
  char **h_addr_list;
  int /*<<< orphan*/ h_name;
};

/* Variables and functions */
int /*<<< orphan*/ _xfree(char *);
void JOEfreehostent(struct hostent *h) {
  char **p;
  do {
    char **_p = (char **)&(h->h_name);
    _xfree(*_p);
    *_p = 0;
  } while (0);
  if (h->h_aliases != NULL) {
    for (p = h->h_aliases; *p != NULL; ++p)
      do {
        char **_p = (char **)&(*p);
        _xfree(*_p);
        *_p = 0;
      } while (0);
    do {
      char **_p = (char **)&(h->h_aliases);
      _xfree(*_p);
      *_p = 0;
    } while (0);
  }
  if (h->h_addr_list != NULL) {
    for (p = h->h_addr_list; *p != NULL; ++p)
      do {
        char **_p = (char **)&(*p);
        _xfree(*_p);
        *_p = 0;
      } while (0);
    do {
      char **_p = (char **)&(h->h_addr_list);
      _xfree(*_p);
      *_p = 0;
    } while (0);
  }
  do {
    char **_p = (char **)&(h);
    _xfree(*_p);
    *_p = 0;
  } while (0);
}


x86 assembly (clang, -O0):
<JOEfreehostent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%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     11c9 <JOEfreehostent+0xb9>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a0 <JOEfreehostent+0x90>
jmp    116b <JOEfreehostent+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 <JOEfreehostent+0x7f>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1158 <JOEfreehostent+0x48>
jmp    11a5 <JOEfreehostent+0x95>
mov    -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)
jmp    11c9 <JOEfreehostent+0xb9>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1259 <JOEfreehostent+0x149>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     122c <JOEfreehostent+0x11c>
jmp    11f7 <JOEfreehostent+0xe7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
jmp    121b <JOEfreehostent+0x10b>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e4 <JOEfreehostent+0xd4>
jmp    1231 <JOEfreehostent+0x121>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x38(%rbp),%rax
movq   $0x0,(%rax)
jmp    1259 <JOEfreehostent+0x149>
jmp    125e <JOEfreehostent+0x14e>
lea    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
call   1030 <_xfree@plt>
mov    -0x40(%rbp),%rax
movq   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JOEfreehostent>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x10(%rdi),%rdi
call   1030 <_xfree@plt>
movq   $0x0,0x10(%r14)
mov    (%r14),%rbx
test   %rbx,%rbx
je     116b <JOEfreehostent+0x5b>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     115c <JOEfreehostent+0x4c>
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 <JOEfreehostent+0x30>
mov    (%r14),%rbx
mov    %rbx,%rdi
call   1030 <_xfree@plt>
movq   $0x0,(%r14)
mov    0x8(%r14),%rbx
test   %rbx,%rbx
je     11ad <JOEfreehostent+0x9d>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     119d <JOEfreehostent+0x8d>
add    $0x8,%rbx
call   1030 <_xfree@plt>
movq   $0x0,-0x8(%rbx)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1180 <JOEfreehostent+0x70>
mov    0x8(%r14),%rbx
mov    %rbx,%rdi
call   1030 <_xfree@plt>
movq   $0x0,0x8(%r14)
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_xfree@plt>

LLVM IR (-O0):
%struct.hostent = type { i8**, i8**, i32 }
define void @JOEfreehostent(%struct.hostent* %0) {
%2 = alloca %struct.hostent*
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
store %struct.hostent* %0, %struct.hostent** %2
br label %10
10: ; preds = %1
%11 = load %struct.hostent*, %struct.hostent** %2
%12 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i32 0, i32 2
%13 = bitcast i32* %12 to i8**
store i8** %13, i8*** %4
%14 = load i8**, i8*** %4
%15 = load i8*, i8** %14
%16 = call i32 @_xfree(i8* %15)
%17 = load i8**, i8*** %4
store i8* null, i8** %17
br label %18
18: ; preds = %10
%19 = load %struct.hostent*, %struct.hostent** %2
%20 = getelementptr inbounds %struct.hostent, %struct.hostent* %19, i32 0, i32 0
%21 = load i8**, i8*** %20
%22 = icmp ne i8** %21, null
br i1 %22, label %23, label %52
23: ; preds = %18
%24 = load %struct.hostent*, %struct.hostent** %2
%25 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i32 0, i32 0
%26 = load i8**, i8*** %25
store i8** %26, i8*** %3
br label %27
27: ; preds = %39, %23
%28 = load i8**, i8*** %3
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %42
31: ; preds = %27
br label %32
32: ; preds = %31
%33 = load i8**, i8*** %3
store i8** %33, i8*** %5
%34 = load i8**, i8*** %5
%35 = load i8*, i8** %34
%36 = call i32 @_xfree(i8* %35)
%37 = load i8**, i8*** %5
store i8* null, i8** %37
br label %38
38: ; preds = %32
br label %39
39: ; preds = %38
%40 = load i8**, i8*** %3
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %3
br label %27
42: ; preds = %27
br label %43
43: ; preds = %42
%44 = load %struct.hostent*, %struct.hostent** %2
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %44, i32 0, i32 0
%46 = bitcast i8*** %45 to i8**
store i8** %46, i8*** %6
%47 = load i8**, i8*** %6
%48 = load i8*, i8** %47
%49 = call i32 @_xfree(i8* %48)
%50 = load i8**, i8*** %6
store i8* null, i8** %50
br label %51
51: ; preds = %43
br label %52
52: ; preds = %51, %18
%53 = load %struct.hostent*, %struct.hostent** %2
%54 = getelementptr inbounds %struct.hostent, %struct.hostent* %53, i32 0, i32 1
%55 = load i8**, i8*** %54
%56 = icmp ne i8** %55, null
br i1 %56, label %57, label %86
57: ; preds = %52
%58 = load %struct.hostent*, %struct.hostent** %2
%59 = getelementptr inbounds %struct.hostent, %struct.hostent* %58, i32 0, i32 1
%60 = load i8**, i8*** %59
store i8** %60, i8*** %3
br label %61
61: ; preds = %73, %57
%62 = load i8**, i8*** %3
%63 = load i8*, i8** %62
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %76
65: ; preds = %61
br label %66
66: ; preds = %65
%67 = load i8**, i8*** %3
store i8** %67, i8*** %7
%68 = load i8**, i8*** %7
%69 = load i8*, i8** %68
%70 = call i32 @_xfree(i8* %69)
%71 = load i8**, i8*** %7
store i8* null, i8** %71
br label %72
72: ; preds = %66
br label %73
73: ; preds = %72
%74 = load i8**, i8*** %3
%75 = getelementptr inbounds i8*, i8** %74, i32 1
store i8** %75, i8*** %3
br label %61
76: ; preds = %61
br label %77
77: ; preds = %76
%78 = load %struct.hostent*, %struct.hostent** %2
%79 = getelementptr inbounds %struct.hostent, %struct.hostent* %78, i32 0, i32 1
%80 = bitcast i8*** %79 to i8**
store i8** %80, i8*** %8
%81 = load i8**, i8*** %8
%82 = load i8*, i8** %81
%83 = call i32 @_xfree(i8* %82)
%84 = load i8**, i8*** %8
store i8* null, i8** %84
br label %85
85: ; preds = %77
br label %86
86: ; preds = %85, %52
br label %87
87: ; preds = %86
%88 = bitcast %struct.hostent** %2 to i8**
store i8** %88, i8*** %9
%89 = load i8**, i8*** %9
%90 = load i8*, i8** %89
%91 = call i32 @_xfree(i8* %90)
%92 = load i8**, i8*** %9
store i8* null, i8** %92
br label %93
93: ; preds = %87
ret void
}

LLVM IR (-O2):
%struct.hostent = type { i8**, i8**, i32 }
define void @JOEfreehostent(%struct.hostent* %0) {
%2 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 2
%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.hostent, %struct.hostent* %0, i64 0, i32 0
%7 = load i8**, i8*** %6
%8 = icmp eq i8** %7, null
br i1 %8, label %27, label %9
9: ; preds = %1
%10 = bitcast i8** %7 to i8*
%11 = load i8*, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %23, label %13
13: ; preds = %9, %13
%14 = phi i8* [ %18, %13 ], [ %11, %9 ]
%15 = phi i8** [ %17, %13 ], [ %7, %9 ]
%16 = tail call i32 @_xfree(i8* %14)
store i8* null, i8** %15
%17 = getelementptr inbounds i8*, i8** %15, i64 1
%18 = load i8*, i8** %17
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = bitcast %struct.hostent* %0 to i8**
%22 = load i8*, i8** %21
br label %23
23: ; preds = %9, %20
%24 = phi i8* [ %22, %20 ], [ %10, %9 ]
%25 = bitcast %struct.hostent* %0 to i8**
%26 = tail call i32 @_xfree(i8* %24)
store i8* null, i8** %25
br label %27
27: ; preds = %23, %1
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %0, i64 0, i32 1
%29 = load i8**, i8*** %28
%30 = icmp eq i8** %29, null
br i1 %30, label %49, label %31
31: ; preds = %27
%32 = bitcast i8** %29 to i8*
%33 = load i8*, i8** %29
%34 = icmp eq i8* %33, null
br i1 %34, label %45, label %35
35: ; preds = %31, %35
%36 = phi i8* [ %40, %35 ], [ %33, %31 ]
%37 = phi i8** [ %39, %35 ], [ %29, %31 ]
%38 = tail call i32 @_xfree(i8* %36)
store i8* null, i8** %37
%39 = getelementptr inbounds i8*, i8** %37, i64 1
%40 = load i8*, i8** %39
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %35
42: ; preds = %35
%43 = bitcast i8*** %28 to i8**
%44 = load i8*, i8** %43
br label %45
45: ; preds = %31, %42
%46 = phi i8* [ %44, %42 ], [ %32, %31 ]
%47 = bitcast i8*** %28 to i8**
%48 = tail call i32 @_xfree(i8* %46)
store i8* null, i8** %47
br label %49
49: ; preds = %27, %45
%50 = bitcast %struct.hostent* %0 to i8*
%51 = tail call i32 @_xfree(i8* %50)
ret void
}