void sender(dum) void *dum;
{
  char buf[16];
  int ret;
  int i;
  th_sleep(1);
  for (i = 0; i < 100; i++) {
  again:
    ret = msg_send(7277, buf, 16);
    if (ret == -2) {
      th_sleep(1);
      goto again;
    }
  }
}


x86 assembly (clang, -O0):
<sender>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <th_sleep@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x64,-0x28(%rbp)
jge    1194 <sender+0x74>
jmp    114e <sender+0x2e>
lea    -0x20(%rbp),%rsi
mov    $0x1c6d,%edi
mov    $0x10,%edx
mov    $0x0,%al
call   1040 <msg_send@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xfffffffe,-0x24(%rbp)
jne    1181 <sender+0x61>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <th_sleep@plt>
jmp    114e <sender+0x2e>
jmp    1186 <sender+0x66>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113f <sender+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sender>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <th_sleep@plt>
mov    %rsp,%rbx
xor    %ebp,%ebp
jmp    114c <sender+0x2c>
nopl   0x0(%rax)
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <th_sleep@plt>
mov    $0x1c6d,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
xor    %eax,%eax
call   1040 <msg_send@plt>
cmp    $0xfffffffe,%eax
je     1140 <sender+0x20>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    114c <sender+0x2c>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @sender(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 (i32, ...) bitcast (i32 (...)* @th_sleep to i32 (i32, ...)*)(i32 1)
store i32 0, i32* %5
br label %7
7: ; preds = %19, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %22
10: ; preds = %7
br label %11
11: ; preds = %16, %10
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%13 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @msg_send to i32 (i32, i8*, i32, ...)*)(i32 7277, i8* %12, i32 16)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -2
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i32, ...) bitcast (i32 (...)* @th_sleep to i32 (i32, ...)*)(i32 1)
br label %11
18: ; preds = %11
br label %19
19: ; preds = %18
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %7
22: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @sender(i8* nocapture readnone %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @th_sleep to i32 (i32, ...)*)(i32 1)
br label %5
5: ; preds = %1, %13
%6 = phi i32 [ 0, %1 ], [ %14, %13 ]
%7 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @msg_send to i32 (i32, i8*, i32, ...)*)(i32 7277, i8* %3, i32 16)
%8 = icmp eq i32 %7, -2
br i1 %8, label %9, label %13
9: ; preds = %5, %9
%10 = call i32 (i32, ...) bitcast (i32 (...)* @th_sleep to i32 (i32, ...)*)(i32 1)
%11 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @msg_send to i32 (i32, i8*, i32, ...)*)(i32 7277, i8* %3, i32 16)
%12 = icmp eq i32 %11, -2
br i1 %12, label %9, label %13
13: ; preds = %9, %5
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %5
16: ; preds = %13
ret void
}