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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ ntohl(int);
char *show_ip(int /*<<< orphan*/);
void print_addr_pairs(FILE *f, int *data, int n) {
  int i;
  for (i = 0; i < n; i++) {
    fprintf(f, " (%s, %s)", show_ip(ntohl(data[2 * i])),
            show_ip(ntohl(data[2 * i + 1])));
  }
}


x86 assembly (clang, -O0):
<print_addr_pairs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c2 <print_addr_pairs+0x92>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
call   1040 <show_ip@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
call   1040 <show_ip@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    %rax,%rcx
lea    0xe51(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <print_addr_pairs+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_addr_pairs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    119e <print_addr_pairs+0x6e>
mov    %rsi,%r12
mov    %rdi,%r14
mov    %edx,%r13d
xor    %ebp,%ebp
lea    0xeaf(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
call   1040 <show_ip@plt>
mov    %rax,%rbx
mov    0x4(%r12,%rbp,8),%edi
call   1050 <ntohl@plt>
mov    %eax,%edi
call   1040 <show_ip@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1160 <print_addr_pairs+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c" (%s, %s)\00"
define void @print_addr_pairs(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %20, %7 ]
%9 = shl nuw nsw i64 %8, 1
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @ntohl(i32 %11)
%13 = tail call i8* @show_ip(i32 %12)
%14 = or i64 %9, 1
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 @ntohl(i32 %16)
%18 = tail call i8* @show_ip(i32 %17)
%19 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %18)
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %7, %3
ret void
}