#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 */

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char, char, char, char);
char *ntoa(unsigned long ip) {
  static char buff[18];
  char *p;
  p = (char *)&ip;
  sprintf(buff, "%d.%d.%d.%d", (p[0] & 255), (p[1] & 255), (p[2] & 255),
          (p[3] & 255));
  return (buff);
}


x86 assembly (clang, -O0):
<ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
and    $0xff,%eax
lea    0x2edb(%rip),%rdi
lea    0xe94(%rip),%rsi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %al,%r9d
call   1030 <sprintf@plt>
lea    0x2eba(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ntoa>:
push   %rbx
mov    %edi,%eax
shr    $0x8,%eax
mov    %edi,%esi
shr    $0x10,%esi
mov    %edi,%r9d
sar    $0x18,%r9d
movsbl %dil,%edx
movsbl %al,%ecx
movsbl %sil,%r8d
lea    0x2f0c(%rip),%rbx
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

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