#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 utsname {
  int /*<<< orphan*/ nodename;
};
struct hostent {
  int h_addrtype;
  char **h_addr_list;
};

/* Variables and functions */
struct hostent *gethostbyname(int /*<<< orphan*/);
scalar_t__ uname(struct utsname *);
char **my_addrs(int *addrtype) {
  struct hostent *hptr;
  struct utsname myname;
  if (uname(&myname) < 0)
    return NULL;
  if ((hptr = gethostbyname(myname.nodename)) == NULL)
    return NULL;
  *addrtype = hptr->h_addrtype;
  return (hptr->h_addr_list);
}


x86 assembly (clang, -O0):
<my_addrs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
jge    114c <my_addrs+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    1187 <my_addrs+0x67>
mov    -0x20(%rbp),%edi
call   1040 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    116f <my_addrs+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    1187 <my_addrs+0x67>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_addrs>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
js     114f <my_addrs+0x2f>
mov    0x8(%rsp),%edi
call   1040 <gethostbyname@plt>
test   %rax,%rax
je     114f <my_addrs+0x2f>
mov    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x8(%rax),%rax
jmp    1151 <my_addrs+0x31>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.hostent = type { i32, i8** }
%struct.utsname = type { i32 }
define i8** @my_addrs(i32* %0) {
%2 = alloca i8**
%3 = alloca i32*
%4 = alloca %struct.hostent*
%5 = alloca %struct.utsname
store i32* %0, i32** %3
%6 = call i64 @uname(%struct.utsname* %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8** null, i8*** %2
br label %23
9: ; preds = %1
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %5, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call %struct.hostent* @gethostbyname(i32 %11)
store %struct.hostent* %12, %struct.hostent** %4
%13 = icmp eq %struct.hostent* %12, null
br i1 %13, label %14, label %15
14: ; preds = %9
store i8** null, i8*** %2
br label %23
15: ; preds = %9
%16 = load %struct.hostent*, %struct.hostent** %4
%17 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32*, i32** %3
store i32 %18, i32* %19
%20 = load %struct.hostent*, %struct.hostent** %4
%21 = getelementptr inbounds %struct.hostent, %struct.hostent* %20, i32 0, i32 1
%22 = load i8**, i8*** %21
store i8** %22, i8*** %2
br label %23
23: ; preds = %15, %14, %8
%24 = load i8**, i8*** %2
ret i8** %24
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
%struct.hostent = type { i32, i8** }
define i8** @my_addrs(i32* nocapture writeonly %0) {
%2 = alloca %struct.utsname
%3 = bitcast %struct.utsname* %2 to i8*
%4 = call i64 @uname(%struct.utsname* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call %struct.hostent* @gethostbyname(i32 %8)
%10 = icmp eq %struct.hostent* %9, null
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i64 0, i32 0
%13 = load i32, i32* %12
store i32 %13, i32* %0
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i64 0, i32 1
%15 = load i8**, i8*** %14
br label %16
16: ; preds = %6, %1, %11
%17 = phi i8** [ %15, %11 ], [ null, %1 ], [ null, %6 ]
ret i8** %17
}