#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;
struct mem_pool {
  int dummy;
};
struct in6_addr {
  int /*<<< orphan*/ s6_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ INET6_ADDRSTRLEN;
char *inet_ntop(int /*<<< orphan*/, struct in6_addr *, int /*<<< orphan*/,
                int /*<<< orphan*/);
int /*<<< orphan*/ mem_pool_alloc(struct mem_pool *, int /*<<< orphan*/);
int mem_pool_hex(struct mem_pool *, int /*<<< orphan*/ const *, size_t);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                          size_t);
int /*<<< orphan*/ sanity_internal(char *, int, char *, char *, int);
const char *inet62str(const uint8_t *addr, size_t len, struct mem_pool *pool) {
  do {
    if (!(len == 16))
      sanity_internal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/CZ-NIC/ucollect/refs/"
                      "heads/master/src/plugins/fwup/type.c",
                      40, "len == 16", "Inet6 address of size %zu\n", len);
  } while (0);
  struct in6_addr addr_str;
  do {
    if (!(sizeof addr_str == 16))
      sanity_internal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/CZ-NIC/ucollect/refs/"
                      "heads/master/src/plugins/fwup/type.c",
                      42, "sizeof addr_str == 16",
                      "Wrong size of struct in6_addr (%zu)\n", sizeof addr_str);
  } while (0);
  memcpy(&addr_str.s6_addr, addr, len);
  const char *result =
      inet_ntop(AF_INET6, &addr_str, mem_pool_alloc(pool, INET6_ADDRSTRLEN),
                INET6_ADDRSTRLEN);
  do {
    if (!(result))
      sanity_internal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/CZ-NIC/ucollect/refs/"
                      "heads/master/src/plugins/fwup/type.c",
                      46, "result", "Couldn't convert address %s to string\n",
                      mem_pool_hex(pool, addr, len));
  } while (0);
  return result;
}


x86 assembly (clang, -O0):
<inet62str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x10,-0x10(%rbp)
je     1195 <inet62str+0x45>
mov    -0x10(%rbp),%rax
mov    %eax,%r8d
lea    0xe83(%rip),%rdi
mov    $0x28,%esi
lea    0xf0b(%rip),%rdx
lea    0xf0e(%rip),%rcx
call   1060 <sanity_internal@plt>
jmp    119a <inet62str+0x4a>
jmp    119f <inet62str+0x4f>
lea    0xe5a(%rip),%rdi
mov    $0x2a,%esi
lea    0xf07(%rip),%rdx
lea    0xf16(%rip),%rcx
mov    $0x4,%r8d
call   1060 <sanity_internal@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <memcpy@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
call   1050 <mem_pool_alloc@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%edx
mov    0x2de9(%rip),%rax
mov    (%rax),%ecx
lea    -0x20(%rbp),%rsi
call   1030 <inet_ntop@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    124c <inet62str+0xfc>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <mem_pool_hex@plt>
mov    %eax,%r8d
lea    0xdcc(%rip),%rdi
mov    $0x2e,%esi
lea    0xeb4(%rip),%rdx
lea    0xeb4(%rip),%rcx
call   1060 <sanity_internal@plt>
jmp    1251 <inet62str+0x101>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet62str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
cmp    $0x10,%rsi
je     118c <inet62str+0x3c>
lea    0xe8f(%rip),%rdi
lea    0xf1c(%rip),%rdx
lea    0xf1f(%rip),%rcx
mov    $0x28,%esi
mov    %r12d,%r8d
call   1060 <sanity_internal@plt>
lea    0xe6d(%rip),%rdi
lea    0xf1f(%rip),%rdx
lea    0xf2e(%rip),%rcx
mov    $0x2a,%esi
mov    $0x4,%r8d
call   1060 <sanity_internal@plt>
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <memcpy@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%ebp
mov    0x2e16(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
call   1050 <mem_pool_alloc@plt>
mov    (%rbx),%ecx
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <inet_ntop@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1222 <inet62str+0xd2>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <mem_pool_hex@plt>
lea    0xdf9(%rip),%rdi
lea    0xee6(%rip),%rdx
lea    0xee6(%rip),%rcx
mov    $0x2e,%esi
mov    %eax,%r8d
call   1060 <sanity_internal@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mem_pool = type { i32 }
%struct.in6_addr = type { i32 }
@.str = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CZ-NIC/ucollect/refs/heads/master/src/plugins/fwup/type.c\00"
@.str.1 = [10 x i8] c"len == 16\00"
@.str.2 = [27 x i8] c"Inet6 address of size %zu\0A\00"
@.str.3 = [22 x i8] c"sizeof addr_str == 16\00"
@.str.4 = [37 x i8] c"Wrong size of struct in6_addr (%zu)\0A\00"
@AF_INET6 = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@.str.5 = [7 x i8] c"result\00"
@.str.6 = [39 x i8] c"Couldn't convert address %s to string\0A\00"
define i8* @inet62str(i32* %0, i64 %1, %struct.mem_pool* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca %struct.mem_pool*
%7 = alloca %struct.in6_addr
%8 = alloca i8*
store i32* %0, i32** %4
store i64 %1, i64* %5
store %struct.mem_pool* %2, %struct.mem_pool** %6
br label %9
9: ; preds = %3
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 16
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = load i64, i64* %5
%14 = trunc i64 %13 to i32
%15 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %9
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 4)
br label %20
20: ; preds = %18
%21 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %7, i32 0, i32 0
%22 = load i32*, i32** %4
%23 = load i64, i64* %5
%24 = call i32 @memcpy(i32* %21, i32* %22, i64 %23)
%25 = load i32, i32* @AF_INET6
%26 = load %struct.mem_pool*, %struct.mem_pool** %6
%27 = load i32, i32* @INET6_ADDRSTRLEN
%28 = call i32 @mem_pool_alloc(%struct.mem_pool* %26, i32 %27)
%29 = load i32, i32* @INET6_ADDRSTRLEN
%30 = call i8* @inet_ntop(i32 %25, %struct.in6_addr* %7, i32 %28, i32 %29)
store i8* %30, i8** %8
br label %31
31: ; preds = %20
%32 = load i8*, i8** %8
%33 = icmp ne i8* %32, null
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = load %struct.mem_pool*, %struct.mem_pool** %6
%36 = load i32*, i32** %4
%37 = load i64, i64* %5
%38 = call i32 @mem_pool_hex(%struct.mem_pool* %35, i32* %36, i64 %37)
%39 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34, %31
br label %41
41: ; preds = %40
%42 = load i8*, i8** %8
ret i8* %42
}

LLVM IR (-O2):
%struct.mem_pool = type { i32 }
%struct.in6_addr = type { i32 }
@.str = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CZ-NIC/ucollect/refs/heads/master/src/plugins/fwup/type.c\00"
@.str.1 = [10 x i8] c"len == 16\00"
@.str.2 = [27 x i8] c"Inet6 address of size %zu\0A\00"
@.str.3 = [22 x i8] c"sizeof addr_str == 16\00"
@.str.4 = [37 x i8] c"Wrong size of struct in6_addr (%zu)\0A\00"
@AF_INET6 = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@.str.5 = [7 x i8] c"result\00"
@.str.6 = [39 x i8] c"Couldn't convert address %s to string\0A\00"
define i8* @inet62str(i32* %0, i64 %1, %struct.mem_pool* %2) {
%4 = alloca %struct.in6_addr
%5 = icmp eq i64 %1, 16
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = trunc i64 %1 to i32
%8 = tail call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %3, %6
%10 = bitcast %struct.in6_addr* %4 to i8*
%11 = tail call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 4)
%12 = getelementptr inbounds %struct.in6_addr, %struct.in6_addr* %4, i64 0, i32 0
%13 = call i32 @memcpy(i32* %12, i32* %0, i64 %1)
%14 = load i32, i32* @AF_INET6
%15 = load i32, i32* @INET6_ADDRSTRLEN
%16 = call i32 @mem_pool_alloc(%struct.mem_pool* %2, i32 %15)
%17 = load i32, i32* @INET6_ADDRSTRLEN
%18 = call i8* @inet_ntop(i32 %14, %struct.in6_addr* %4, i32 %16, i32 %17)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %9
%21 = call i32 @mem_pool_hex(%struct.mem_pool* %2, i32* %0, i64 %1)
%22 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %9
ret i8* %18
}