#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*/ printf(char *);
int xs_close(int);
int xs_init();
int xs_send(int, char *, int, int /*<<< orphan*/);
int xs_socket(int);
int xs_term();
int main() {
  int rc;
  int s;
  printf("basic test running...\n");
  rc = xs_init();
  assert(rc == 0);
  s = xs_socket(9);
  assert(s >= 0);
  while (1) {
    rc = xs_send(s, "ABC", 3, 0);
    assert(rc == 3);
  }
  rc = xs_close(s);
  assert(rc == 0);
  rc = xs_term();
  assert(rc == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <xs_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x9,%edi
call   1070 <xs_socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%edi
lea    0xe69(%rip),%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1030 <xs_send@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
sete   %al
and    $0x1,%al
mov    %al,-0xd(%rbp)
movzbl %al,%edi
call   1050 <assert@plt>
jmp    11a4 <main+0x54>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <xs_init@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x9,%edi
call   1070 <xs_socket@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1050 <assert@plt>
lea    0xe6d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1040 <xs_send@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
jmp    11a0 <main+0x50>

LLVM IR (-O0):
@.str = [23 x i8] c"basic test running...\0A\00"
@.str.1 = [4 x i8] c"ABC\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @xs_init()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @xs_socket(i32 9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
br label %15
15: ; preds = %0, %15
%16 = load i32, i32* %3
%17 = call i32 @xs_send(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 0)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 3
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
br label %15
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"ABC\00"
@str = [22 x i8] c"basic test running...\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @xs_init()
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @xs_socket(i32 9)
%7 = xor i32 %6, -1
%8 = lshr i32 %7, 31
%9 = tail call i32 @assert(i32 %8)
br label %10
10: ; preds = %10, %0
%11 = tail call i32 @xs_send(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 0)
%12 = icmp eq i32 %11, 3
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
br label %10
}