#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 node {
  int dummy;
};
struct in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *const);
int /*<<< orphan*/ inet_ntoa(struct in_addr const);
struct node *node_create(char *const);
char *strdup(int /*<<< orphan*/);
struct node *create_address(const struct in_addr address) {
  char *const ip = strdup(inet_ntoa(address));
  if (ip == NULL) {
    return NULL;
  }
  struct node *const node = node_create(ip);
  if (node == NULL) {
    free(ip);
  }
  return node;
}


x86 assembly (clang, -O0):
<create_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1176 <create_address+0x36>
movq   $0x0,-0x8(%rbp)
jmp    119f <create_address+0x5f>
mov    -0x18(%rbp),%rdi
call   1050 <node_create@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1197 <create_address+0x57>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_address>:
push   %rbx
call   1040 <inet_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
test   %rax,%rax
je     116c <create_address+0x2c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <node_create@plt>
test   %rax,%rax
je     1164 <create_address+0x24>
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.node = type { i32 }
define %struct.node* @create_address(i32 %0) {
%2 = tail call i32 @inet_ntoa(i32 %0)
%3 = tail call i8* @strdup(i32 %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = tail call %struct.node* @node_create(i8* %3)
%7 = icmp eq %struct.node* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @free(i8* %3)
br label %10
10: ; preds = %5, %8, %1
%11 = phi %struct.node* [ null, %1 ], [ null, %8 ], [ %6, %5 ]
ret %struct.node* %11
}