#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;
int INET6_ADDRSTRLEN;
scalar_t__ inet_pton(int /*<<< orphan*/, char *, struct in6_addr *);
int rat_lib_6addr_ok(struct in6_addr *addr) {
  char buf[INET6_ADDRSTRLEN];
  if (!addr)
    goto exit_err;
  if (inet_pton(AF_INET6, buf, addr) == 0)
    return 1;
exit_err:
  return 0;
}


x86 assembly (clang, -O0):
<rat_lib_6addr_ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ec5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <rat_lib_6addr_ok+0x48>
jmp    1190 <rat_lib_6addr_ok+0x80>
mov    -0x30(%rbp),%rsi
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
call   1030 <inet_pton@plt>
cmp    $0x0,%rax
jne    118b <rat_lib_6addr_ok+0x7b>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    119e <rat_lib_6addr_ok+0x8e>
jmp    1190 <rat_lib_6addr_ok+0x80>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rat_lib_6addr_ok>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ecd(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rsi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rsi
mov    %rsi,%rsp
test   %rdi,%rdi
je     1149 <rat_lib_6addr_ok+0x39>
mov    %rdi,%rdx
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
call   1030 <inet_pton@plt>
test   %rax,%rax
je     114d <rat_lib_6addr_ok+0x3d>
xor    %eax,%eax
jmp    1152 <rat_lib_6addr_ok+0x42>
mov    $0x1,%eax
mov    %rbp,%rsp
pop    %rbp
ret

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

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