#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char, unsigned char,
                            unsigned char, unsigned char);
char *ipaddr_to_str(uint32_t ipaddr) {
  static char temp_ipaddr[32];
  snprintf(temp_ipaddr, 32, "%d.%d.%d.%d", (unsigned char)(ipaddr & 0xff),
           (unsigned char)((ipaddr >> 8) & 0xff),
           (unsigned char)((ipaddr >> 16) & 0xff),
           (unsigned char)((ipaddr >> 24) & 0xff));
  return temp_ipaddr;
}


x86 assembly (clang, -O0):
<ipaddr_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%r9b
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
lea    0x2eed(%rip),%rdi
mov    $0x20,%esi
lea    0xea1(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2ec4(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipaddr_to_str>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
mov    %edi,%edx
shr    $0x10,%edx
mov    %edi,%ecx
shr    $0x18,%ecx
mov    %ecx,(%rsp)
movzbl %al,%ecx
movzbl %ah,%eax
movzbl %dl,%r9d
lea    0x2f0b(%rip),%rbx
lea    0xec4(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %eax,%r8d
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@ipaddr_to_str.temp_ipaddr = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @ipaddr_to_str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 255
%5 = trunc i32 %4 to i8
%6 = load i32, i32* %2
%7 = ashr i32 %6, 8
%8 = and i32 %7, 255
%9 = trunc i32 %8 to i8
%10 = load i32, i32* %2
%11 = ashr i32 %10, 16
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = load i32, i32* %2
%15 = ashr i32 %14, 24
%16 = and i32 %15, 255
%17 = trunc i32 %16 to i8
%18 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipaddr_to_str.temp_ipaddr, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %5, i8 zeroext %9, i8 zeroext %13, i8 zeroext %17)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @ipaddr_to_str.temp_ipaddr, i64 0, i64 0)
}

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