#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 in6_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
scalar_t__ inet_pton(int /*<<< orphan*/, char const *, struct in6_addr *);
int rat_lib_6addr_from_str(struct in6_addr *addr, const char *str) {
  if (!addr || !str)
    goto exit_err;
  if (inet_pton(AF_INET6, str, addr) != 0)
    return 0;
exit_err:
  return -1;
}


x86 assembly (clang, -O0):
<rat_lib_6addr_from_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <rat_lib_6addr_from_str+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    113b <rat_lib_6addr_from_str+0x2b>
jmp    116c <rat_lib_6addr_from_str+0x5c>
mov    0x2ea6(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <inet_pton@plt>
cmp    $0x0,%rax
je     1167 <rat_lib_6addr_from_str+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1173 <rat_lib_6addr_from_str+0x63>
jmp    116c <rat_lib_6addr_from_str+0x5c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rat_lib_6addr_from_str>:
test   %rdi,%rdi
je     113c <rat_lib_6addr_from_str+0x2c>
test   %rsi,%rsi
je     113c <rat_lib_6addr_from_str+0x2c>
push   %rax
mov    %rdi,%rdx
mov    0x2ec3(%rip),%rax
mov    (%rax),%edi
call   1030 <inet_pton@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
lea    0x8(%rsp),%rsp
je     113c <rat_lib_6addr_from_str+0x2c>
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
@AF_INET6 = global i32 0
define i32 @rat_lib_6addr_from_str(%struct.in6_addr* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.in6_addr*
%5 = alloca i8*
store %struct.in6_addr* %0, %struct.in6_addr** %4
store i8* %1, i8** %5
%6 = load %struct.in6_addr*, %struct.in6_addr** %4
%7 = icmp ne %struct.in6_addr* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8, %2
br label %20
12: ; preds = %8
%13 = load i32, i32* @AF_INET6
%14 = load i8*, i8** %5
%15 = load %struct.in6_addr*, %struct.in6_addr** %4
%16 = call i64 @inet_pton(i32 %13, i8* %14, %struct.in6_addr* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %3
br label %21
19: ; preds = %12
br label %20
20: ; preds = %19, %11
store i32 -1, i32* %3
br label %21
21: ; preds = %20, %18
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
@AF_INET6 = global i32 0
define i32 @rat_lib_6addr_from_str(%struct.in6_addr* %0, i8* %1) {
%3 = icmp ne %struct.in6_addr* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @AF_INET6
%8 = tail call i64 @inet_pton(i32 %7, i8* %1, %struct.in6_addr* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6, %2
br label %11
11: ; preds = %6, %10
%12 = phi i32 [ -1, %10 ], [ 0, %6 ]
ret i32 %12
}