#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 */
typedef int /*<<< orphan*/ uint16_t;
typedef int /*<<< orphan*/ in_addr_t;
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ *alloc_rdata_init(int /*<<< orphan*/ *, int);
int inet_pton(int /*<<< orphan*/, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ log_msg(int, char *, char const *);
uint16_t *zparser_conv_a(const char *text) {
  in_addr_t address;
  uint16_t *r = NULL;
  if (inet_pton(AF_INET, text, &address) != 1) {
    log_msg(1, "invalid IPV4 address '%s'", text);
  } else {
    r = alloc_rdata_init(&address, sizeof(address));
  }
  return r;
}


x86 assembly (clang, -O0):
<zparser_conv_a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <inet_pton@plt>
cmp    $0x1,%eax
je     117d <zparser_conv_a+0x4d>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe8d(%rip),%rsi
call   1050 <log_msg@plt>
jmp    118f <zparser_conv_a+0x5f>
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1030 <alloc_rdata_init@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zparser_conv_a>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <inet_pton@plt>
cmp    $0x1,%eax
jne    1164 <zparser_conv_a+0x34>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1030 <alloc_rdata_init@plt>
jmp    117a <zparser_conv_a+0x4a>
lea    0xe95(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1050 <log_msg@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@.str = [26 x i8] c"invalid IPV4 address '%s'\00"
define i32* @zparser_conv_a(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %4
%5 = load i32, i32* @AF_INET
%6 = load i8*, i8** %2
%7 = call i32 @inet_pton(i32 %5, i8* %6, i32* %3)
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @log_msg(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %14
12: ; preds = %1
%13 = call i32* @alloc_rdata_init(i32* %3, i32 4)
store i32* %13, i32** %4
br label %14
14: ; preds = %12, %9
%15 = load i32*, i32** %4
ret i32* %15
}

LLVM IR (-O2):
@AF_INET = global i32 0
@.str = [26 x i8] c"invalid IPV4 address '%s'\00"
define i32* @zparser_conv_a(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @AF_INET
%5 = call i32 @inet_pton(i32 %4, i8* %0, i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @log_msg(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
9: ; preds = %1
%10 = call i32* @alloc_rdata_init(i32* %2, i32 4)
br label %11
11: ; preds = %9, %7
%12 = phi i32* [ null, %7 ], [ %10, %9 ]
ret i32* %12
}