#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_name;
  int /*<<< orphan*/ *h_aliases;
  int /*<<< orphan*/ *h_addr;
};

/* Variables and functions */
int /*<<< orphan*/ endhostent();
struct hostent *gethostent();
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sethostent(int);
int main() {
  struct hostent *ent;
  sethostent(1);
  while (1) {
    ent = gethostent();
    if (ent == 0) {
      break;
    }
    printf("name:%s IP name:%hhu.%hhu.%hhu.%hhu alarm:%s\n", ent->h_name,
           ent->h_addr[0], ent->h_addr[1], ent->h_addr[2], ent->h_addr[3],
           ent->h_aliases[0]);
  }
  endhostent();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1050 <sethostent@plt>
mov    $0x0,%al
call   1030 <gethostent@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <main+0x34>
jmp    11c6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
lea    0xe47(%rip),%rdi
mov    %eax,(%rsp)
call   1040 <printf@plt>
jmp    1159 <main+0x19>
mov    $0x0,%al
call   1060 <endhostent@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1050 <sethostent@plt>
xor    %eax,%eax
call   1030 <gethostent@plt>
test   %rax,%rax
je     11a1 <main+0x61>
lea    0xe9e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rax),%rsi
mov    (%rsi),%edx
mov    0x4(%rsi),%ecx
mov    0x8(%rsi),%r8d
mov    0xc(%rsi),%r9d
mov    (%rax),%rsi
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <gethostent@plt>
test   %rax,%rax
jne    1170 <main+0x30>
xor    %eax,%eax
call   1060 <endhostent@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.hostent = type { i8*, i32*, i32* }
@.str = [46 x i8] c"name:%s IP name:%hhu.%hhu.%hhu.%hhu alarm:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.hostent*
store i32 0, i32* %1
%3 = call i32 @sethostent(i32 1)
br label %4
4: ; preds = %0, %9
%5 = call %struct.hostent* (...) @gethostent()
store %struct.hostent* %5, %struct.hostent** %2
%6 = load %struct.hostent*, %struct.hostent** %2
%7 = icmp eq %struct.hostent* %6, null
br i1 %7, label %8, label %9
8: ; preds = %4
br label %39
9: ; preds = %4
%10 = load %struct.hostent*, %struct.hostent** %2
%11 = getelementptr inbounds %struct.hostent, %struct.hostent* %10, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = load %struct.hostent*, %struct.hostent** %2
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i32 0, i32 2
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = load %struct.hostent*, %struct.hostent** %2
%19 = getelementptr inbounds %struct.hostent, %struct.hostent* %18, i32 0, i32 2
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = load %struct.hostent*, %struct.hostent** %2
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i32 0, i32 2
%25 = load i32*, i32** %24
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = load %struct.hostent*, %struct.hostent** %2
%29 = getelementptr inbounds %struct.hostent, %struct.hostent* %28, i32 0, i32 2
%30 = load i32*, i32** %29
%31 = getelementptr inbounds i32, i32* %30, i64 3
%32 = load i32, i32* %31
%33 = load %struct.hostent*, %struct.hostent** %2
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %33, i32 0, i32 1
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 0
%37 = load i32, i32* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %17, i32 %22, i32 %27, i32 %32, i32 %37)
br label %4
39: ; preds = %8
%40 = call i32 (...) @endhostent()
ret i32 0
}

LLVM IR (-O2):
%struct.hostent = type { i8*, i32*, i32* }
@.str = [46 x i8] c"name:%s IP name:%hhu.%hhu.%hhu.%hhu alarm:%s\0A\00"
define i32 @main() {
%1 = tail call i32 @sethostent(i32 1)
%2 = tail call %struct.hostent* (...) @gethostent()
%3 = icmp eq %struct.hostent* %2, null
br i1 %3, label %23, label %4
4: ; preds = %0, %4
%5 = phi %struct.hostent* [ %21, %4 ], [ %2, %0 ]
%6 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 2
%9 = load i32*, i32** %8
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds i32, i32* %9, i64 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %9, i64 3
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 1
%18 = load i32*, i32** %17
%19 = load i32, i32* %18
%20 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %10, i32 %12, i32 %14, i32 %16, i32 %19)
%21 = tail call %struct.hostent* (...) @gethostent()
%22 = icmp eq %struct.hostent* %21, null
br i1 %22, label %23, label %4
23: ; preds = %4, %0
%24 = tail call i32 (...) @endhostent()
ret i32 0
}