#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 sockaddr {
  scalar_t__ *sa_data;
};
struct addrinfo {
  struct sockaddr *ai_addr;
  struct addrinfo *ai_next;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ getaddrinfo(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                       struct addrinfo **);
int /*<<< orphan*/ printf(char *, ...);
void multi_dns_seq(size_t n, char **names, struct addrinfo **infos) {
  size_t i;
  for (i = 0; i < n; ++i) {
    struct addrinfo *p;
    assert(0 == getaddrinfo(names[i], NULL, NULL, &infos[i]));
    for (p = infos[i]; p != NULL; p = p->ai_next) {
      struct sockaddr *addr = p->ai_addr;
      size_t j, ds = sizeof(addr->sa_data) / sizeof(addr->sa_data[0]);
      for (j = 0; j < ds; ++j) {
        unsigned int x = (unsigned char)addr->sa_data[j];
        printf(" %u", x);
      }
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<multi_dns_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1246 <multi_dns_seq+0x116>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1050 <getaddrinfo@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1230 <multi_dns_seq+0x100>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movq   $0x1,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    1211 <multi_dns_seq+0xe1>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movzbl %al,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11cc <multi_dns_seq+0x9c>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <multi_dns_seq+0x76>
jmp    1235 <multi_dns_seq+0x105>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <multi_dns_seq+0x1c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_dns_seq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11d9 <multi_dns_seq+0x99>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9c(%rip),%r13
xor    %ebx,%ebx
jmp    1179 <multi_dns_seq+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r15,%rbx
je     11d9 <multi_dns_seq+0x99>
mov    (%r14,%rbx,8),%rdi
lea    (%r12,%rbx,8),%rcx
xor    %esi,%esi
xor    %edx,%edx
call   1060 <getaddrinfo@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    (%r12,%rbx,8),%rbp
test   %rbp,%rbp
je     1170 <multi_dns_seq+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%rax
mov    (%rax),%rax
movzbl (%rax),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rbp),%rbp
test   %rbp,%rbp
jne    11b0 <multi_dns_seq+0x70>
jmp    1170 <multi_dns_seq+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { %struct.sockaddr*, %struct.addrinfo* }
%struct.sockaddr = type { i64* }
@.str = [4 x i8] c" %u\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @multi_dns_seq(i64 %0, i8** %1, %struct.addrinfo** %2) {
%4 = alloca i64
%5 = alloca i8**
%6 = alloca %struct.addrinfo**
%7 = alloca i64
%8 = alloca %struct.addrinfo*
%9 = alloca %struct.sockaddr*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
store i64 %0, i64* %4
store i8** %1, i8*** %5
store %struct.addrinfo** %2, %struct.addrinfo*** %6
store i64 0, i64* %7
br label %13
13: ; preds = %65, %3
%14 = load i64, i64* %7
%15 = load i64, i64* %4
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %68
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i64, i64* %7
%20 = getelementptr inbounds i8*, i8** %18, i64 %19
%21 = load i8*, i8** %20
%22 = load %struct.addrinfo**, %struct.addrinfo*** %6
%23 = load i64, i64* %7
%24 = getelementptr inbounds %struct.addrinfo*, %struct.addrinfo** %22, i64 %23
%25 = call i64 @getaddrinfo(i8* %21, i32* null, i32* null, %struct.addrinfo** %24)
%26 = icmp eq i64 0, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load %struct.addrinfo**, %struct.addrinfo*** %6
%30 = load i64, i64* %7
%31 = getelementptr inbounds %struct.addrinfo*, %struct.addrinfo** %29, i64 %30
%32 = load %struct.addrinfo*, %struct.addrinfo** %31
store %struct.addrinfo* %32, %struct.addrinfo** %8
br label %33
33: ; preds = %60, %17
%34 = load %struct.addrinfo*, %struct.addrinfo** %8
%35 = icmp ne %struct.addrinfo* %34, null
br i1 %35, label %36, label %64
36: ; preds = %33
%37 = load %struct.addrinfo*, %struct.addrinfo** %8
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i32 0, i32 0
%39 = load %struct.sockaddr*, %struct.sockaddr** %38
store %struct.sockaddr* %39, %struct.sockaddr** %9
store i64 1, i64* %11
store i64 0, i64* %10
br label %40
40: ; preds = %55, %36
%41 = load i64, i64* %10
%42 = load i64, i64* %11
%43 = icmp ult i64 %41, %42
br i1 %43, label %44, label %58
44: ; preds = %40
%45 = load %struct.sockaddr*, %struct.sockaddr** %9
%46 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %45, i32 0, i32 0
%47 = load i64*, i64** %46
%48 = load i64, i64* %10
%49 = getelementptr inbounds i64, i64* %47, i64 %48
%50 = load i64, i64* %49
%51 = trunc i64 %50 to i8
%52 = zext i8 %51 to i32
store i32 %52, i32* %12
%53 = load i32, i32* %12
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %44
%56 = load i64, i64* %10
%57 = add i64 %56, 1
store i64 %57, i64* %10
br label %40
58: ; preds = %40
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load %struct.addrinfo*, %struct.addrinfo** %8
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 1
%63 = load %struct.addrinfo*, %struct.addrinfo** %62
store %struct.addrinfo* %63, %struct.addrinfo** %8
br label %33
64: ; preds = %33
br label %65
65: ; preds = %64
%66 = load i64, i64* %7
%67 = add i64 %66, 1
store i64 %67, i64* %7
br label %13
68: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.sockaddr*, %struct.addrinfo* }
%struct.sockaddr = type { i64* }
@.str = [4 x i8] c" %u\00"
define void @multi_dns_seq(i64 %0, i8** nocapture %1, %struct.addrinfo** %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %33, label %5
5: ; preds = %3, %30
%6 = phi i64 [ %31, %30 ], [ 0, %3 ]
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = load i8*, i8** %7
%9 = getelementptr inbounds %struct.addrinfo*, %struct.addrinfo** %2, i64 %6
%10 = tail call i64 @getaddrinfo(i8* %8, i32* null, i32* null, %struct.addrinfo** %9)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = load %struct.addrinfo*, %struct.addrinfo** %9
%15 = icmp eq %struct.addrinfo* %14, null
br i1 %15, label %30, label %16
16: ; preds = %5, %16
%17 = phi %struct.addrinfo* [ %28, %16 ], [ %14, %5 ]
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %17, i64 0, i32 0
%19 = load %struct.sockaddr*, %struct.sockaddr** %18
%20 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %19, i64 0, i32 0
%21 = load i64*, i64** %20
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = and i32 %23, 255
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = tail call i32 @putchar(i32 10)
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %17, i64 0, i32 1
%28 = load %struct.addrinfo*, %struct.addrinfo** %27
%29 = icmp eq %struct.addrinfo* %28, null
br i1 %29, label %30, label %16
30: ; preds = %16, %5
%31 = add nuw i64 %6, 1
%32 = icmp eq i64 %31, %0
br i1 %32, label %33, label %5
33: ; preds = %30, %3
ret void
}