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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ INET_ADDRSTRLEN;
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *inet_ntop(int /*<<< orphan*/, struct in_addr const *,
                              char *const, int /*<<< orphan*/);
int /*<<< orphan*/ log__(int /*<<< orphan*/, char *);
const char *ntoa(const struct in_addr in, char *const buf) {
  if (inet_ntop(AF_INET, &in, buf, INET_ADDRSTRLEN) == NULL)
    do {
      log__(
          LOG_CRIT,
          "FATAL: "
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c"
          ":"
          "403"
          ": "
          "Failed to format IPv4 address: %m\n");
      exit(EXIT_FAILURE);
    } while (0);
  return buf;
}


x86 assembly (clang, -O0):
<ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    0x2e7d(%rip),%rax
mov    (%rax),%ecx
lea    -0x8(%rbp),%rsi
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    1190 <ntoa+0x60>
jmp    116d <ntoa+0x3d>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1040 <log__@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ntoa>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,0x8(%rsp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     1169 <ntoa+0x39>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1040 <log__@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@LOG_CRIT = global i32 0
@.str = [180 x i8] c"FATAL: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:403: Failed to format IPv4 address: %m\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @ntoa(i32 %0, i8* %1) {
%3 = alloca %struct.in_addr
%4 = alloca i8*
%5 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %0, i32* %5
store i8* %1, i8** %4
%6 = load i32, i32* @AF_INET
%7 = load i8*, i8** %4
%8 = load i32, i32* @INET_ADDRSTRLEN
%9 = call i32* @inet_ntop(i32 %6, %struct.in_addr* %3, i8* %7, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %2
br label %12
12: ; preds = %11
%13 = load i32, i32* @LOG_CRIT
%14 = call i32 @log__(i32 %13, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; No predecessors!
br label %18
18: ; preds = %17, %2
%19 = load i8*, i8** %4
ret i8* %19
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@LOG_CRIT = global i32 0
@.str = [180 x i8] c"FATAL: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:403: Failed to format IPv4 address: %m\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @ntoa(i32 %0, i8* returned %1) {
%3 = alloca %struct.in_addr
%4 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
store i32 %0, i32* %4
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @INET_ADDRSTRLEN
%7 = call i32* @inet_ntop(i32 %5, %struct.in_addr* %3, i8* %1, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @LOG_CRIT
%11 = call i32 @log__(i32 %10, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
ret i8* %1
}