#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*/ bzero(char *, int);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int setPlayerTurns(int fd1, int fd2, int turn) {
  char buf[80];
  bzero(buf, 80);
  buf[0] = turn + 48;
  send(fd1, buf, 80, 0);
  recv(fd1, buf, 80, 0);
  if (fd1 != fd2) {
    buf[0] = 49 - turn;
    send(fd2, buf, 80, 0);
    recv(fd2, buf, 80, 0);
  }
}


x86 assembly (clang, -O0):
<setPlayerTurns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %al,-0x60(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     11bb <setPlayerTurns+0x8b>
mov    $0x31,%eax
sub    -0x10(%rbp),%eax
mov    %al,-0x60(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0xc(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPlayerTurns>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
lea    0x30(%r14),%eax
mov    %al,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    %r15d,%ebp
je     11af <setPlayerTurns+0x7f>
mov    $0x31,%al
sub    %r14b,%al
mov    %al,(%rsp)
mov    %rsp,%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @setPlayerTurns(i32 %0, i32 %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = call i32 @bzero(i8* %5, i32 80)
%7 = trunc i32 %2 to i8
%8 = add i8 %7, 48
store i8 %8, i8* %5
%9 = call i32 @send(i32 %0, i8* %5, i32 80, i32 0)
%10 = call i32 @recv(i32 %0, i8* %5, i32 80, i32 0)
%11 = icmp eq i32 %0, %1
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = sub i8 49, %7
store i8 %13, i8* %5
%14 = call i32 @send(i32 %1, i8* %5, i32 80, i32 0)
%15 = call i32 @recv(i32 %1, i8* %5, i32 80, i32 0)
br label %16
16: ; preds = %12, %3
ret i32 undef
}