#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*/ buf;
typedef scalar_t__ a;

/* Variables and functions */
int /*<<< orphan*/ evutil_snprintf(char *, int, char *, int, int, int, int);
unsigned long ntohl(unsigned long);
const char *debug_ntoa(unsigned long address) {
  static char buf[32];
  unsigned long a = ntohl(address);
  evutil_snprintf(
      buf, sizeof(buf), "%d.%d.%d.%d", (int)(unsigned char)((a >> 24) & 0xff),
      (int)(unsigned char)((a >> 16) & 0xff),
      (int)(unsigned char)((a >> 8) & 0xff), (int)(unsigned char)((a)&0xff));
  return buf;
}


x86 assembly (clang, -O0):
<debug_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ntohl@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
movzbl %al,%ecx
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
movzbl %al,%r8d
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
movzbl %al,%r9d
mov    -0x10(%rbp),%rax
and    $0xff,%rax
movzbl %al,%eax
lea    0x2ebe(%rip),%rdi
mov    $0x20,%esi
lea    0xe72(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <evutil_snprintf@plt>
lea    0x2ea3(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_ntoa>:
push   %rbp
push   %rbx
push   %rax
call   1040 <ntohl@plt>
mov    %eax,%edx
movzbl %ah,%ebp
movzbl %al,%esi
mov    %eax,%ecx
shr    $0x18,%ecx
shr    $0x10,%edx
movzbl %dl,%r8d
mov    %esi,(%rsp)
lea    0x2efa(%rip),%rbx
lea    0xeb3(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %ebp,%r9d
call   1030 <evutil_snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@debug_ntoa.buf = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @debug_ntoa(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i64 @ntohl(i64 %4)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = lshr i64 %6, 24
%8 = and i64 %7, 255
%9 = trunc i64 %8 to i8
%10 = zext i8 %9 to i32
%11 = load i64, i64* %3
%12 = lshr i64 %11, 16
%13 = and i64 %12, 255
%14 = trunc i64 %13 to i8
%15 = zext i8 %14 to i32
%16 = load i64, i64* %3
%17 = lshr i64 %16, 8
%18 = and i64 %17, 255
%19 = trunc i64 %18 to i8
%20 = zext i8 %19 to i32
%21 = load i64, i64* %3
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i8
%24 = zext i8 %23 to i32
%25 = call i32 @evutil_snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @debug_ntoa.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %15, i32 %20, i32 %24)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @debug_ntoa.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@debug_ntoa.buf = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @debug_ntoa(i64 %0) {
%2 = tail call i64 @ntohl(i64 %0)
%3 = trunc i64 %2 to i32
%4 = lshr i32 %3, 24
%5 = lshr i32 %3, 16
%6 = and i32 %5, 255
%7 = lshr i32 %3, 8
%8 = and i32 %7, 255
%9 = and i32 %3, 255
%10 = tail call i32 @evutil_snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @debug_ntoa.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8, i32 %9)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @debug_ntoa.buf, i64 0, i64 0)
}