#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 sock {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ co_net__request_heartbeat(struct sock const *, int);
int co_net__wait_for_bootup(struct sock const *, char *, int, int, int);
int co_net_probe(const struct sock *sock, char *nodes_seen, int start, int end,
                 int timeout) {
  for (int i = start; i <= end; ++i)
    if (!nodes_seen[i])
      co_net__request_heartbeat(sock, i);
  return co_net__wait_for_bootup(sock, nodes_seen, start, end, timeout);
}


x86 assembly (clang, -O0):
<co_net_probe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     117d <co_net_probe+0x5d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    116a <co_net_probe+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <co_net__request_heartbeat@plt>
jmp    116f <co_net_probe+0x4f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1140 <co_net_probe+0x20>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1030 <co_net__wait_for_bootup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<co_net_probe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0xc(%rsp)
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
cmp    %ecx,%edx
jle    116b <co_net_probe+0x4b>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    0xc(%rsp),%r8d
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <co_net__wait_for_bootup@plt>
movslq %r13d,%r14
lea    0x1(%r12),%r15d
add    0x10(%rsp),%r14
mov    %r13d,%ebp
jmp    118c <co_net_probe+0x6c>
nopl   (%rax)
add    $0x1,%ebp
add    $0x1,%r14
cmp    %ebp,%r15d
je     1145 <co_net_probe+0x25>
cmpb   $0x0,(%r14)
jne    1180 <co_net_probe+0x60>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <co_net__request_heartbeat@plt>
jmp    1180 <co_net_probe+0x60>

LLVM IR (-O0):
%struct.sock = type { i32 }
define i32 @co_net_probe(%struct.sock* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.sock*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.sock* %0, %struct.sock** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %8
store i32 %12, i32* %11
br label %13
13: ; preds = %29, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %17
%25 = load %struct.sock*, %struct.sock** %6
%26 = load i32, i32* %11
%27 = call i32 @co_net__request_heartbeat(%struct.sock* %25, i32 %26)
br label %28
28: ; preds = %24, %17
br label %29
29: ; preds = %28
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %13
32: ; preds = %13
%33 = load %struct.sock*, %struct.sock** %6
%34 = load i8*, i8** %7
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = call i32 @co_net__wait_for_bootup(%struct.sock* %33, i8* %34, i32 %35, i32 %36, i32 %37)
ret i32 %38
}

LLVM IR (-O2):
%struct.sock = type { i32 }
define i32 @co_net_probe(%struct.sock* %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %2, %3
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = sext i32 %2 to i64
%9 = add i32 %3, 1
br label %12
10: ; preds = %20, %5
%11 = tail call i32 @co_net__wait_for_bootup(%struct.sock* %0, i8* %1, i32 %2, i32 %3, i32 %4)
ret i32 %11
12: ; preds = %7, %20
%13 = phi i64 [ %8, %7 ], [ %21, %20 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = trunc i64 %13 to i32
%19 = tail call i32 @co_net__request_heartbeat(%struct.sock* %0, i32 %18)
br label %20
20: ; preds = %12, %17
%21 = add nsw i64 %13, 1
%22 = trunc i64 %21 to i32
%23 = icmp eq i32 %9, %22
br i1 %23, label %10, label %12
}