#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 connection_pool {
  int dummy;
};
struct connection {
  int dummy;
};

/* Variables and functions */
int dispatch_client(struct connection_pool *, struct connection *);
scalar_t__ dispatch_server(struct connection_pool *, struct connection *);
void dispatch(struct connection_pool *server, struct connection *client) {
  for (;;) {
    int n = dispatch_client(server, client);
    n += dispatch_server(server, client);
    if (n == 0)
      return;
  }
}


x86 assembly (clang, -O0):
<dispatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <dispatch_client@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <dispatch_server@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    116a <dispatch+0x4a>
add    $0x20,%rsp
pop    %rbp
ret
jmp    1130 <dispatch+0x10>

x86 assembly (clang, -O2):
<dispatch>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <dispatch_client@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <dispatch_server@plt>
add    %ebp,%eax
jne    1130 <dispatch+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.connection_pool = type { i32 }
%struct.connection = type { i32 }
define void @dispatch(%struct.connection_pool* %0, %struct.connection* %1) {
%3 = alloca %struct.connection_pool*
%4 = alloca %struct.connection*
%5 = alloca i32
store %struct.connection_pool* %0, %struct.connection_pool** %3
store %struct.connection* %1, %struct.connection** %4
br label %6
6: ; preds = %20, %2
%7 = load %struct.connection_pool*, %struct.connection_pool** %3
%8 = load %struct.connection*, %struct.connection** %4
%9 = call i32 @dispatch_client(%struct.connection_pool* %7, %struct.connection* %8)
store i32 %9, i32* %5
%10 = load %struct.connection_pool*, %struct.connection_pool** %3
%11 = load %struct.connection*, %struct.connection** %4
%12 = call i64 @dispatch_server(%struct.connection_pool* %10, %struct.connection* %11)
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %6
ret void
20: ; preds = %6
br label %6
}

LLVM IR (-O2):
%struct.connection_pool = type { i32 }
%struct.connection = type { i32 }
define void @dispatch(%struct.connection_pool* %0, %struct.connection* %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @dispatch_client(%struct.connection_pool* %0, %struct.connection* %1)
%5 = tail call i64 @dispatch_server(%struct.connection_pool* %0, %struct.connection* %1)
%6 = trunc i64 %5 to i32
%7 = sub i32 0, %6
%8 = icmp eq i32 %4, %7
br i1 %8, label %9, label %3
9: ; preds = %3
ret void
}