#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 netbench_result {
  int dummy;
};
struct linked_list {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ linked_list_add(struct linked_list *, int /*<<< orphan*/);
struct linked_list *linked_list_init();
int /*<<< orphan*/ linked_list_res_value_init(struct netbench_result *);
unsigned int netbench_comm_list_recv(int);
struct netbench_result *netbench_result_recv(int);
struct linked_list *netbench_list_result_recv(struct linked_list *results,
                                              int rank) {
  struct linked_list *ret;
  struct netbench_result *res;
  unsigned int size;
  if (results)
    ret = results;
  else
    ret = linked_list_init();
  size = netbench_comm_list_recv(rank);
  if (!size)
    return ret;
  while (size--) {
    res = netbench_result_recv(rank);
    linked_list_add(ret, linked_list_res_value_init(res));
  }
  return ret;
}


x86 assembly (clang, -O0):
<netbench_list_result_recv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1177 <netbench_list_result_recv+0x27>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1182 <netbench_list_result_recv+0x32>
mov    $0x0,%al
call   1060 <linked_list_init@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <netbench_comm_list_recv@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11a4 <netbench_list_result_recv+0x54>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <netbench_list_result_recv+0xa2>
jmp    11a9 <netbench_list_result_recv+0x59>
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x2c(%rbp)
cmp    $0x0,%eax
je     11ea <netbench_list_result_recv+0x9a>
mov    -0x14(%rbp),%edi
call   1030 <netbench_result_recv@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <linked_list_res_value_init@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1050 <linked_list_add@plt>
jmp    11a9 <netbench_list_result_recv+0x59>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netbench_list_result_recv>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1169 <netbench_list_result_recv+0x19>
xor    %eax,%eax
call   1060 <linked_list_init@plt>
mov    %rax,%rbx
mov    %r14d,%edi
call   1040 <netbench_comm_list_recv@plt>
test   %eax,%eax
je     119f <netbench_list_result_recv+0x4f>
mov    %eax,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
call   1030 <netbench_result_recv@plt>
mov    %rax,%rdi
call   1070 <linked_list_res_value_init@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <linked_list_add@plt>
add    $0xffffffff,%ebp
jne    1180 <netbench_list_result_recv+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.linked_list = type { i32 }
%struct.netbench_result = type { i32 }
define %struct.linked_list* @netbench_list_result_recv(%struct.linked_list* %0, i32 %1) {
%3 = alloca %struct.linked_list*
%4 = alloca %struct.linked_list*
%5 = alloca i32
%6 = alloca %struct.linked_list*
%7 = alloca %struct.netbench_result*
%8 = alloca i32
store %struct.linked_list* %0, %struct.linked_list** %4
store i32 %1, i32* %5
%9 = load %struct.linked_list*, %struct.linked_list** %4
%10 = icmp ne %struct.linked_list* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load %struct.linked_list*, %struct.linked_list** %4
store %struct.linked_list* %12, %struct.linked_list** %6
br label %15
13: ; preds = %2
%14 = call %struct.linked_list* (...) @linked_list_init()
store %struct.linked_list* %14, %struct.linked_list** %6
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %5
%17 = call i32 @netbench_comm_list_recv(i32 %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = load %struct.linked_list*, %struct.linked_list** %6
store %struct.linked_list* %21, %struct.linked_list** %3
br label %36
22: ; preds = %15
br label %23
23: ; preds = %27, %22
%24 = load i32, i32* %8
%25 = add i32 %24, -1
store i32 %25, i32* %8
%26 = icmp ne i32 %24, 0
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* %5
%29 = call %struct.netbench_result* @netbench_result_recv(i32 %28)
store %struct.netbench_result* %29, %struct.netbench_result** %7
%30 = load %struct.linked_list*, %struct.linked_list** %6
%31 = load %struct.netbench_result*, %struct.netbench_result** %7
%32 = call i32 @linked_list_res_value_init(%struct.netbench_result* %31)
%33 = call i32 @linked_list_add(%struct.linked_list* %30, i32 %32)
br label %23
34: ; preds = %23
%35 = load %struct.linked_list*, %struct.linked_list** %6
store %struct.linked_list* %35, %struct.linked_list** %3
br label %36
36: ; preds = %34, %20
%37 = load %struct.linked_list*, %struct.linked_list** %3
ret %struct.linked_list* %37
}

LLVM IR (-O2):
%struct.linked_list = type { i32 }
%struct.netbench_result = type { i32 }
define %struct.linked_list* @netbench_list_result_recv(%struct.linked_list* %0, i32 %1) {
%3 = icmp eq %struct.linked_list* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call %struct.linked_list* (...) @linked_list_init()
br label %6
6: ; preds = %2, %4
%7 = phi %struct.linked_list* [ %5, %4 ], [ %0, %2 ]
%8 = tail call i32 @netbench_comm_list_recv(i32 %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %6, %10
%11 = phi i32 [ %12, %10 ], [ %8, %6 ]
%12 = add i32 %11, -1
%13 = tail call %struct.netbench_result* @netbench_result_recv(i32 %1)
%14 = tail call i32 @linked_list_res_value_init(%struct.netbench_result* %13)
%15 = tail call i32 @linked_list_add(%struct.linked_list* %7, i32 %14)
%16 = icmp eq i32 %12, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %6
ret %struct.linked_list* %7
}