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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void addr_print(char *msg, uint8_t *pos, size_t count) {
  printf("%s", msg);
  while (count--) {
    printf(" %u.%u.%u.%u", pos[0], pos[1], pos[2], pos[3]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<addr_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     117e <addr_print+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r8d
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <addr_print+0x26>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr_print>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     116f <addr_print+0x4f>
lea    0xebb(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r14),%esi
mov    0x4(%r14),%edx
mov    0x8(%r14),%ecx
mov    0xc(%r14),%r8d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    1150 <addr_print+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c" %u.%u.%u.%u\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @addr_print(i8* %0, i32* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %13, %3
%10 = load i64, i64* %6
%11 = add i64 %10, -1
store i64 %11, i64* %6
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32, i32* %18
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = load i32, i32* %21
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %19, i32 %22, i32 %25)
br label %9
27: ; preds = %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [13 x i8] c" %u.%u.%u.%u\00"
define void @addr_print(i8* %0, i32* nocapture %1, i64 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp eq i64 %2, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = getelementptr inbounds i32, i32* %1, i64 2
%9 = getelementptr inbounds i32, i32* %1, i64 3
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ %2, %6 ], [ %12, %10 ]
%12 = add i64 %11, -1
%13 = load i32, i32* %1
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %16)
%18 = icmp eq i64 %12, 0
br i1 %18, label %19, label %10
19: ; preds = %10, %3
%20 = tail call i32 @putchar(i32 10)
ret void
}