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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ destroy_network_nodes();
int /*<<< orphan*/ free(char *);
char *get_address(int);
int get_port(int);
int /*<<< orphan*/ init_network_nodes(int /*<<< orphan*/, int, char const **);
int my_id();
scalar_t__ strcmp(char *, char *);
void test_nodes() {
  const char *test_nodes[] = {"memyselfi:129", "zebra:321", "apple:123",
                              "intheory:876"};
  init_network_nodes(0, 4, test_nodes);
  assert(my_id() == 2);
  assert(get_port(0) == 123);
  assert(get_port(1) == 876);
  assert(get_port(2) == 129);
  assert(get_port(3) == 321);
  char *got = get_address(0);
  assert(strcmp(got, "apple") == 0);
  free(got);
  got = get_address(1);
  assert(strcmp(got, "intheory") == 0);
  free(got);
  got = get_address(2);
  assert(strcmp(got, "memyselfi") == 0);
  free(got);
  got = get_address(3);
  assert(strcmp(got, "zebra") == 0);
  free(got);
  destroy_network_nodes();
}


x86 assembly (clang, -O0):
<test_nodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2c71(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c6e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c6b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c68(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x20(%rbp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   10a0 <init_network_nodes@plt>
mov    $0x0,%al
call   1060 <my_id@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %edi,%edi
call   1050 <get_port@plt>
cmp    $0x7b,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x1,%edi
call   1050 <get_port@plt>
cmp    $0x36c,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x2,%edi
call   1050 <get_port@plt>
cmp    $0x81,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    $0x3,%edi
call   1050 <get_port@plt>
cmp    $0x141,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
xor    %edi,%edi
call   1030 <get_address@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdd3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    $0x1,%edi
call   1030 <get_address@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    $0x2,%edi
call   1030 <get_address@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd72(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    $0x3,%edi
call   1030 <get_address@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd44(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    $0x0,%al
call   1090 <destroy_network_nodes@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_nodes>:
push   %rbx
sub    $0x20,%rsp
movaps 0x2c84(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c68(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   10a0 <init_network_nodes@plt>
xor    %eax,%eax
call   1060 <my_id@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1080 <assert@plt>
xor    %edi,%edi
call   1050 <get_port@plt>
xor    %edi,%edi
cmp    $0x7b,%eax
sete   %dil
call   1080 <assert@plt>
mov    $0x1,%edi
call   1050 <get_port@plt>
xor    %edi,%edi
cmp    $0x36c,%eax
sete   %dil
call   1080 <assert@plt>
mov    $0x2,%edi
call   1050 <get_port@plt>
xor    %edi,%edi
cmp    $0x81,%eax
sete   %dil
call   1080 <assert@plt>
mov    $0x3,%edi
call   1050 <get_port@plt>
xor    %edi,%edi
cmp    $0x141,%eax
sete   %dil
call   1080 <assert@plt>
xor    %edi,%edi
call   1030 <get_address@plt>
mov    %rax,%rbx
lea    0xdfb(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    $0x1,%edi
call   1030 <get_address@plt>
mov    %rax,%rbx
lea    0xdcf(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    $0x2,%edi
call   1030 <get_address@plt>
mov    %rax,%rbx
lea    0xda6(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    $0x3,%edi
call   1030 <get_address@plt>
mov    %rax,%rbx
lea    0xd7e(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
call   1090 <destroy_network_nodes@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"memyselfi:129\00"
@.str.1 = [10 x i8] c"zebra:321\00"
@.str.2 = [10 x i8] c"apple:123\00"
@.str.3 = [13 x i8] c"intheory:876\00"
@__const.test_nodes.test_nodes = [4 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [6 x i8] c"apple\00"
@.str.5 = [9 x i8] c"intheory\00"
@.str.6 = [10 x i8] c"memyselfi\00"
@.str.7 = [6 x i8] c"zebra\00"
define void @test_nodes() {
%1 = alloca [4 x i8*]
%2 = alloca i8*
%3 = bitcast [4 x i8*]* %1 to i8*
%4 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%5 = call i32 @init_network_nodes(i32 0, i32 4, i8** %4)
%6 = call i32 (...) @my_id()
%7 = icmp eq i32 %6, 2
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @get_port(i32 0)
%11 = icmp eq i32 %10, 123
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @get_port(i32 1)
%15 = icmp eq i32 %14, 876
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @get_port(i32 2)
%19 = icmp eq i32 %18, 129
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @get_port(i32 3)
%23 = icmp eq i32 %22, 321
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i8* @get_address(i32 0)
store i8* %26, i8** %2
%27 = load i8*, i8** %2
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i8*, i8** %2
%33 = call i32 @free(i8* %32)
%34 = call i8* @get_address(i32 1)
store i8* %34, i8** %2
%35 = load i8*, i8** %2
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i8*, i8** %2
%41 = call i32 @free(i8* %40)
%42 = call i8* @get_address(i32 2)
store i8* %42, i8** %2
%43 = load i8*, i8** %2
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i8*, i8** %2
%49 = call i32 @free(i8* %48)
%50 = call i8* @get_address(i32 3)
store i8* %50, i8** %2
%51 = load i8*, i8** %2
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = load i8*, i8** %2
%57 = call i32 @free(i8* %56)
%58 = call i32 (...) @destroy_network_nodes()
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"memyselfi:129\00"
@.str.1 = [10 x i8] c"zebra:321\00"
@.str.2 = [10 x i8] c"apple:123\00"
@.str.3 = [13 x i8] c"intheory:876\00"
@__const.test_nodes.test_nodes = [4 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [6 x i8] c"apple\00"
@.str.5 = [9 x i8] c"intheory\00"
@.str.6 = [10 x i8] c"memyselfi\00"
@.str.7 = [6 x i8] c"zebra\00"
define void @test_nodes() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%4 = call i32 @init_network_nodes(i32 0, i32 4, i8** %3)
%5 = call i32 (...) @my_id()
%6 = icmp eq i32 %5, 2
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @get_port(i32 0)
%10 = icmp eq i32 %9, 123
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @get_port(i32 1)
%14 = icmp eq i32 %13, 876
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @get_port(i32 2)
%18 = icmp eq i32 %17, 129
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @get_port(i32 3)
%22 = icmp eq i32 %21, 321
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i8* @get_address(i32 0)
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @free(i8* %25)
%31 = call i8* @get_address(i32 1)
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = call i32 @free(i8* %31)
%37 = call i8* @get_address(i32 2)
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @free(i8* %37)
%43 = call i8* @get_address(i32 3)
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @free(i8* %43)
%49 = call i32 (...) @destroy_network_nodes()
ret void
}