#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(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void sendboard(int sock, char *bufout, char *board, int size) {
  int i;
  strcpy(bufout, "b");
  for (i = 0; i <= (size * size); i += size)
    strncat(bufout, board + i, size);
  send(sock, bufout, strlen(bufout), 0);
}


x86 assembly (clang, -O0):
<sendboard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jg     11a4 <sendboard+0x64>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1060 <strncat@plt>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    116d <sendboard+0x2d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendboard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %rdx,%r12
mov    %rsi,%r15
mov    %edi,%r14d
lea    0xea2(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
movslq %r13d,%rbx
imul   %r13d,%r13d
xor    %ebp,%ebp
nop
lea    (%r12,%rbp,1),%rsi
mov    %r15,%rdi
mov    %ebx,%edx
call   1060 <strncat@plt>
add    %rbx,%rbp
cmp    %r13,%rbp
jle    1170 <sendboard+0x30>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <send@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"b\00"
define void @sendboard(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %6
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %12
12: ; preds = %26, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = load i32, i32* %8
%16 = mul nsw i32 %14, %15
%17 = icmp sle i32 %13, %16
br i1 %17, label %18, label %30
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i32, i32* %8
%25 = call i32 @strncat(i8* %19, i8* %23, i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = add nsw i32 %28, %27
store i32 %29, i32* %9
br label %12
30: ; preds = %12
%31 = load i32, i32* %5
%32 = load i8*, i8** %6
%33 = load i8*, i8** %6
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @send(i32 %31, i8* %32, i32 %34, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"b\00"
define void @sendboard(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = mul nsw i32 %3, %3
%7 = sext i32 %3 to i64
%8 = zext i32 %6 to i64
br label %9
9: ; preds = %4, %9
%10 = phi i64 [ 0, %4 ], [ %13, %9 ]
%11 = getelementptr inbounds i8, i8* %2, i64 %10
%12 = tail call i32 @strncat(i8* %1, i8* %11, i32 %3)
%13 = add i64 %10, %7
%14 = icmp sgt i64 %13, %8
br i1 %14, label %15, label %9
15: ; preds = %9
%16 = tail call i32 @strlen(i8* %1)
%17 = tail call i32 @send(i32 %0, i8* %1, i32 %16, i32 0)
ret void
}