#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*/ send_data(int, char *, int);
int /*<<< orphan*/ send_pingpong(int, char *);
int send(int fd, int size) {
  char buf[64];
  int i;
  for (i = 0; i < 64; i++)
    buf[i] = i;
  if (size) {
    buf[0] = size;
    send_data(fd, buf, size);
  } else {
    send_pingpong(fd, buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x40,-0x54(%rbp)
jge    115a <send+0x3a>
mov    -0x54(%rbp),%eax
mov    %al,%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1135 <send+0x15>
cmpl   $0x0,-0x8(%rbp)
je     117e <send+0x5e>
mov    -0x8(%rbp),%eax
mov    %al,-0x50(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <send_data@plt>
jmp    118a <send+0x6a>
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
call   1040 <send_pingpong@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send>:
sub    $0x48,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
test   %esi,%esi
je     1166 <send+0x46>
mov    %esi,%edx
mov    %dl,(%rsp)
mov    %rsp,%rsi
call   1030 <send_data@plt>
jmp    116e <send+0x4e>
mov    %rsp,%rsi
call   1040 <send_pingpong@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
define i32 @send(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %16, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 64
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %6
%12 = trunc i32 %11 to i8
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 %14
store i8 %12, i8* %15
br label %16
16: ; preds = %10
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %7
19: ; preds = %7
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32, i32* %4
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
store i8 %24, i8* %25
%26 = load i32, i32* %3
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %4
%29 = call i32 @send_data(i32 %26, i8* %27, i32 %28)
br label %34
30: ; preds = %19
%31 = load i32, i32* %3
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%33 = call i32 @send_pingpong(i32 %31, i8* %32)
br label %34
34: ; preds = %30, %22
ret i32 0
}

LLVM IR (-O2):
define i32 @send(i32 %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = bitcast [64 x i8]* %3 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %5
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 16
%7 = bitcast i8* %6 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %7
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 32
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %9
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 48
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %11
%12 = icmp eq i32 %1, 0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = trunc i32 %1 to i8
store i8 %14, i8* %4
%15 = call i32 @send_data(i32 %0, i8* %4, i32 %1)
br label %18
16: ; preds = %2
%17 = call i32 @send_pingpong(i32 %0, i8* %4)
br label %18
18: ; preds = %16, %13
ret i32 0
}