#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 /*<<< orphan*/ u_char;

/* Variables and functions */
char *get_buf();
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/ const);
char *print_ip_addr(const u_char *addr) {
  int i;
  char *point = get_buf();
  char *current = point;
  for (i = 0; i < 4; i++)
    point += sprintf(point, i == (4 - 1) ? "%u" : "%u.", addr[i]);
  return current;
}


x86 assembly (clang, -O0):
<print_ip_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <get_buf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    119a <print_ip_addr+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xea5(%rip),%rsi
lea    0xe9b(%rip),%rax
cmp    $0x3,%ecx
cmove  %rax,%rsi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <print_ip_addr+0x26>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ip_addr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
xor    %eax,%eax
call   1040 <get_buf@plt>
mov    %rax,%r14
mov    (%r12),%edx
lea    0xec2(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
movslq %eax,%rbx
add    %r14,%rbx
mov    0x4(%r12),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
movslq %eax,%r13
add    %rbx,%r13
mov    0x8(%r12),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <sprintf@plt>
movslq %eax,%rdi
add    %r13,%rdi
mov    0xc(%r12),%edx
lea    0xe76(%rip),%rsi
call   1030 <sprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [4 x i8] c"%u.\00"
define i8* @print_ip_addr(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %2
%6 = call i8* (...) @get_buf()
store i8* %6, i8** %4
%7 = load i8*, i8** %4
store i8* %7, i8** %5
store i32 0, i32* %3
br label %8
8: ; preds = %26, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 3
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @sprintf(i8* %12, i8* %16, i32 %21)
%23 = load i8*, i8** %4
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %4
br label %26
26: ; preds = %11
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %8
29: ; preds = %8
%30 = load i8*, i8** %5
ret i8* %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [4 x i8] c"%u.\00"
define i8* @print_ip_addr(i32* nocapture %0) {
%2 = tail call i8* (...) @get_buf()
%3 = load i32, i32* %0
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %2, i64 %5
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = getelementptr inbounds i32, i32* %0, i64 2
%13 = load i32, i32* %12
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = getelementptr inbounds i32, i32* %0, i64 3
%18 = load i32, i32* %17
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i8* %2
}