#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 in_addr {
  int /*<<< orphan*/ s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INET_ADDRSTRLEN;
char *inet_ntop(int /*<<< orphan*/, struct in_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 *inet2str(const uint8_t *addr, size_t len, struct mem_pool *pool) {
  do {
    if (!(len == 4))
      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",
                      29, "len == 4", "Inet address of size %zu\n", len);
  } while (0);
  struct in_addr addr_str;
  do {
    if (!(sizeof addr_str == 4))
      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",
                      31, "sizeof addr_str == 4",
                      "Wrong size of struct in_addr (%zu)\n", sizeof addr_str);
  } while (0);
  memcpy(&addr_str.s_addr, addr, len);
  const char *result =
      inet_ntop(AF_INET, &addr_str, mem_pool_alloc(pool, INET_ADDRSTRLEN),
                INET_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",
                      35, "result", "Couldn't convert address %s to string\n",
                      mem_pool_hex(pool, addr, len));
  } while (0);
  return result;
}


x86 assembly (clang, -O0):
<inet2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x4,-0x10(%rbp)
je     1195 <inet2str+0x45>
mov    -0x10(%rbp),%rax
mov    %eax,%r8d
lea    0xe83(%rip),%rdi
mov    $0x1d,%esi
lea    0xf0b(%rip),%rdx
lea    0xf0d(%rip),%rcx
call   1060 <sanity_internal@plt>
jmp    119a <inet2str+0x4a>
jmp    119f <inet2str+0x4f>
jmp    11a4 <inet2str+0x54>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <memcpy@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
call   1050 <mem_pool_alloc@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%edx
mov    0x2df9(%rip),%rax
mov    (%rax),%ecx
lea    -0x20(%rbp),%rsi
call   1030 <inet_ntop@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122c <inet2str+0xdc>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <mem_pool_hex@plt>
mov    %eax,%r8d
lea    0xdec(%rip),%rdi
mov    $0x23,%esi
lea    0xe97(%rip),%rdx
lea    0xe97(%rip),%rcx
call   1060 <sanity_internal@plt>
jmp    1231 <inet2str+0xe1>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet2str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
cmp    $0x4,%rsi
je     118c <inet2str+0x3c>
lea    0xe8f(%rip),%rdi
lea    0xf1c(%rip),%rdx
lea    0xf1e(%rip),%rcx
mov    $0x1d,%esi
mov    %r12d,%r8d
call   1060 <sanity_internal@plt>
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <memcpy@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%ebp
mov    0x2e2b(%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    11fd <inet2str+0xad>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <mem_pool_hex@plt>
lea    0xe1e(%rip),%rdi
lea    0xece(%rip),%rdx
lea    0xece(%rip),%rcx
mov    $0x23,%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.in_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 = [9 x i8] c"len == 4\00"
@.str.2 = [26 x i8] c"Inet address of size %zu\0A\00"
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@.str.3 = [7 x i8] c"result\00"
@.str.4 = [39 x i8] c"Couldn't convert address %s to string\0A\00"
define i8* @inet2str(i32* %0, i64 %1, %struct.mem_pool* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca %struct.mem_pool*
%7 = alloca %struct.in_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, 4
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 29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 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
br label %19
19: ; preds = %18
%20 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%21 = load i32*, i32** %4
%22 = load i64, i64* %5
%23 = call i32 @memcpy(i32* %20, i32* %21, i64 %22)
%24 = load i32, i32* @AF_INET
%25 = load %struct.mem_pool*, %struct.mem_pool** %6
%26 = load i32, i32* @INET_ADDRSTRLEN
%27 = call i32 @mem_pool_alloc(%struct.mem_pool* %25, i32 %26)
%28 = load i32, i32* @INET_ADDRSTRLEN
%29 = call i8* @inet_ntop(i32 %24, %struct.in_addr* %7, i32 %27, i32 %28)
store i8* %29, i8** %8
br label %30
30: ; preds = %19
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load %struct.mem_pool*, %struct.mem_pool** %6
%35 = load i32*, i32** %4
%36 = load i64, i64* %5
%37 = call i32 @mem_pool_hex(%struct.mem_pool* %34, i32* %35, i64 %36)
%38 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33, %30
br label %40
40: ; preds = %39
%41 = load i8*, i8** %8
ret i8* %41
}

LLVM IR (-O2):
%struct.mem_pool = type { i32 }
%struct.in_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 = [9 x i8] c"len == 4\00"
@.str.2 = [26 x i8] c"Inet address of size %zu\0A\00"
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@.str.3 = [7 x i8] c"result\00"
@.str.4 = [39 x i8] c"Couldn't convert address %s to string\0A\00"
define i8* @inet2str(i32* %0, i64 %1, %struct.mem_pool* %2) {
%4 = alloca %struct.in_addr
%5 = icmp eq i64 %1, 4
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 29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %3, %6
%10 = bitcast %struct.in_addr* %4 to i8*
%11 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
%12 = call i32 @memcpy(i32* %11, i32* %0, i64 %1)
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @INET_ADDRSTRLEN
%15 = call i32 @mem_pool_alloc(%struct.mem_pool* %2, i32 %14)
%16 = load i32, i32* @INET_ADDRSTRLEN
%17 = call i8* @inet_ntop(i32 %13, %struct.in_addr* %4, i32 %15, i32 %16)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %9
%20 = call i32 @mem_pool_hex(%struct.mem_pool* %2, i32* %0, i64 %1)
%21 = call i32 @sanity_internal(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %9
ret i8* %17
}