#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 *, unsigned char, unsigned char,
                           unsigned char, unsigned char);
char *inet_ntoa(int ina) {
  static char buf[4 * sizeof "123"];
  unsigned char *ucp = (unsigned char *)&ina;
  sprintf(buf, "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff, ucp[2] & 0xff,
          ucp[3] & 0xff);
  return buf;
}


x86 assembly (clang, -O0):
<inet_ntoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
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    0x2edc(%rip),%rdi
lea    0xe95(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %al,%r9d
call   1030 <sprintf@plt>
lea    0x2ebb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_ntoa>:
push   %rbx
mov    %edi,%ecx
mov    %edi,%esi
shr    $0x10,%esi
mov    %edi,%eax
shr    $0x18,%eax
movzbl %cl,%edx
movzbl %ch,%ecx
movzbl %sil,%r8d
lea    0x2f12(%rip),%rbx
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%r9d
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@inet_ntoa.buf = internal global [16 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @inet_ntoa(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 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext 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 = zext 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 = zext 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 = zext i8 %25 to i32
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @inet_ntoa.buf, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %10, i8 zeroext %16, i8 zeroext %22, i8 zeroext %28)
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @inet_ntoa.buf, i64 0, i64 0)
}

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