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

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
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_aaaa(const char *text) {
  uint8_t address[(128 / 8)];
  uint16_t *r = NULL;
  if (inet_pton(AF_INET6, text, address) != 1) {
    log_msg(1, "invalid IPV6 address '%s'", text);
  } else {
    r = alloc_rdata_init(address, sizeof(address));
  }
  return r;
}


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

x86 assembly (clang, -O2):
<zparser_conv_aaaa>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1040 <inet_pton@plt>
cmp    $0x1,%eax
jne    1160 <zparser_conv_aaaa+0x30>
mov    %rsp,%rdi
mov    $0x40,%esi
call   1030 <alloc_rdata_init@plt>
jmp    1176 <zparser_conv_aaaa+0x46>
lea    0xe99(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1050 <log_msg@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

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