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

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, unsigned int,
                           unsigned int, unsigned int);
void addr_to_string(struct in_addr *addr, char *str) {
  unsigned char *bytes;
  bytes = (unsigned char *)addr;
  sprintf(str, "%u.%u.%u.%u", (unsigned)bytes[0], (unsigned)bytes[1],
          (unsigned)bytes[2], (unsigned)bytes[3]);
}


x86 assembly (clang, -O0):
<addr_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movzbl (%rax),%edx
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%ecx
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%r8d
mov    -0x18(%rbp),%rax
movzbl 0x3(%rax),%r9d
lea    0xeac(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr_to_string>:
mov    %rsi,%rax
movzbl (%rdi),%edx
movzbl 0x1(%rdi),%ecx
movzbl 0x2(%rdi),%r8d
movzbl 0x3(%rdi),%r9d
lea    0xed5(%rip),%rsi
mov    %rax,%rdi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define void @addr_to_string(%struct.in_addr* %0, i8* %1) {
%3 = alloca %struct.in_addr*
%4 = alloca i8*
%5 = alloca i8*
store %struct.in_addr* %0, %struct.in_addr** %3
store i8* %1, i8** %4
%6 = load %struct.in_addr*, %struct.in_addr** %3
%7 = bitcast %struct.in_addr* %6 to i8*
store i8* %7, i8** %5
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 2
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %16, i32 %20, i32 %24)
ret void
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define void @addr_to_string(%struct.in_addr* nocapture %0, i8* nocapture writeonly %1) {
%3 = bitcast %struct.in_addr* %0 to i8*
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds i8, i8* %3, i64 2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = getelementptr inbounds i8, i8* %3, i64 3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %11, i32 %14)
ret void
}