#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 u_char;
struct in_addr {
  int dummy;
};
typedef int /*<<< orphan*/ b;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *ipaddr_string(struct in_addr *ina) {
  static char b[24];
  u_char *p;
  p = (u_char *)ina;
  snprintf(b, sizeof(b), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
  return (b);
}


x86 assembly (clang, -O0):
<ipaddr_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
lea    0x2ef8(%rip),%rdi
mov    $0x18,%esi
lea    0xeac(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2edd(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipaddr_string>:
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%ecx
mov    0x4(%rdi),%r8d
mov    0x8(%rdi),%r9d
mov    0xc(%rdi),%eax
mov    %eax,(%rsp)
lea    0x2f14(%rip),%rbx
lea    0xecd(%rip),%rdx
mov    %rbx,%rdi
mov    $0x18,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@ipaddr_string.b = internal global [24 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @ipaddr_string(%struct.in_addr* %0) {
%2 = alloca %struct.in_addr*
%3 = alloca i32*
store %struct.in_addr* %0, %struct.in_addr** %2
%4 = load %struct.in_addr*, %struct.in_addr** %2
%5 = bitcast %struct.in_addr* %4 to i32*
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 2
%14 = load i32, i32* %13
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 3
%17 = load i32, i32* %16
%18 = call i32 @snprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @ipaddr_string.b, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14, i32 %17)
ret i8* getelementptr inbounds ([24 x i8], [24 x i8]* @ipaddr_string.b, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@ipaddr_string.b = internal global [24 x i8] zeroinitializer
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @ipaddr_string(%struct.in_addr* nocapture %0) {
%2 = getelementptr %struct.in_addr, %struct.in_addr* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %0, i64 1, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %0, i64 2, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %0, i64 3, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @snprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @ipaddr_string.b, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5, i32 %7, i32 %9)
ret i8* getelementptr inbounds ([24 x i8], [24 x i8]* @ipaddr_string.b, i64 0, i64 0)
}