#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*/ buff;
typedef int /*<<< orphan*/ __be32;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char, unsigned char);
char *iptoa(__be32 addr) {
  static char buff[256];
  unsigned char *ptr = (unsigned char *)&addr;
  memset(buff, 0, sizeof(buff));
  sprintf(buff, "%d.%d.%d.%d", (ptr[0] & 0377), (ptr[1] & 0377),
          (ptr[2] & 0377), (ptr[3] & 0377));
  return (buff);
}


x86 assembly (clang, -O0):
<iptoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f06(%rip),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x10(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
lea    0x2eb9(%rip),%rdi
lea    0xe72(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %al,%r9d
call   1040 <sprintf@plt>
lea    0x2e98(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iptoa>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%ebp
shr    $0x10,%ebp
mov    %edi,%r15d
shr    $0x18,%r15d
lea    0x2f04(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
movzbl %bl,%edx
movzbl %bh,%ecx
movzbl %bpl,%r8d
lea    0xea4(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%r9d
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@iptoa.buff = internal global [256 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @iptoa(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = bitcast i32* %2 to i8*
store i8* %4, i8** %3
%5 = call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0), i32 0, i32 256)
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = and i32 %9, 255
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = and i32 %15, 255
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = and i32 %21, 255
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = and i32 %27, 255
%29 = trunc i32 %28 to i8
%30 = call i32 @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %11, i8 zeroext %17, i8 zeroext %23, i8 zeroext %29)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0)
}

LLVM IR (-O2):
@iptoa.buff = internal global [256 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @iptoa(i32 %0) {
%2 = lshr i32 %0, 8
%3 = lshr i32 %0, 16
%4 = lshr i32 %0, 24
%5 = tail call i32 @memset(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0), i32 0, i32 256)
%6 = trunc i32 %0 to i8
%7 = trunc i32 %2 to i8
%8 = trunc i32 %3 to i8
%9 = trunc i32 %4 to i8
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %6, i8 zeroext %7, i8 zeroext %8, i8 zeroext %9)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @iptoa.buff, i64 0, i64 0)
}