#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 */
scalar_t__ malloc(int);
char square_to_file(int);
char square_to_rank(int);
char *ft_to_coord_move(int from, int to, char promote_in) {
  char *s = (char *)malloc(7);
  s[0] = square_to_file(from);
  s[1] = square_to_rank(from);
  s[2] = square_to_file(to);
  s[3] = square_to_rank(to);
  s[4] = '\0';
  if (promote_in) {
    s[4] = '=';
    s[5] = promote_in;
    s[6] = '\0';
  }
  return s;
}


x86 assembly (clang, -O0):
<ft_to_coord_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    $0x7,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <square_to_file@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edi
call   1030 <square_to_rank@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%edi
call   1040 <square_to_file@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%edi
call   1030 <square_to_rank@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x4(%rax)
cmpb   $0x0,-0x9(%rbp)
je     11c0 <ft_to_coord_move+0x90>
mov    -0x18(%rbp),%rax
movb   $0x3d,0x4(%rax)
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x6(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_to_coord_move>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0x7,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <square_to_file@plt>
mov    %al,(%rbx)
mov    %ebp,%edi
call   1030 <square_to_rank@plt>
mov    %al,0x1(%rbx)
mov    %r15d,%edi
call   1040 <square_to_file@plt>
mov    %al,0x2(%rbx)
mov    %r15d,%edi
call   1030 <square_to_rank@plt>
mov    %al,0x3(%rbx)
movb   $0x0,0x4(%rbx)
test   %r14b,%r14b
je     118a <ft_to_coord_move+0x5a>
movb   $0x3d,0x4(%rbx)
mov    %r14b,0x5(%rbx)
movb   $0x0,0x6(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @ft_to_coord_move(i32 %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%8 = call i64 @malloc(i32 7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %7
%10 = load i32, i32* %4
%11 = call signext i8 @square_to_file(i32 %10)
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
%14 = load i32, i32* %4
%15 = call signext i8 @square_to_rank(i32 %14)
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %15, i8* %17
%18 = load i32, i32* %5
%19 = call signext i8 @square_to_file(i32 %18)
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8 %19, i8* %21
%22 = load i32, i32* %5
%23 = call signext i8 @square_to_rank(i32 %22)
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i64 3
store i8 %23, i8* %25
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 4
store i8 0, i8* %27
%28 = load i8, i8* %6
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %3
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 4
store i8 61, i8* %32
%33 = load i8, i8* %6
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 5
store i8 %33, i8* %35
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 6
store i8 0, i8* %37
br label %38
38: ; preds = %30, %3
%39 = load i8*, i8** %7
ret i8* %39
}

LLVM IR (-O2):
define i8* @ft_to_coord_move(i32 %0, i32 %1, i8 signext %2) {
%4 = tail call i64 @malloc(i32 7)
%5 = inttoptr i64 %4 to i8*
%6 = tail call signext i8 @square_to_file(i32 %0)
store i8 %6, i8* %5
%7 = tail call signext i8 @square_to_rank(i32 %0)
%8 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %7, i8* %8
%9 = tail call signext i8 @square_to_file(i32 %1)
%10 = getelementptr inbounds i8, i8* %5, i64 2
store i8 %9, i8* %10
%11 = tail call signext i8 @square_to_rank(i32 %1)
%12 = getelementptr inbounds i8, i8* %5, i64 3
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %5, i64 4
store i8 0, i8* %13
%14 = icmp eq i8 %2, 0
br i1 %14, label %18, label %15
15: ; preds = %3
store i8 61, i8* %13
%16 = getelementptr inbounds i8, i8* %5, i64 5
store i8 %2, i8* %16
%17 = getelementptr inbounds i8, i8* %5, i64 6
store i8 0, i8* %17
br label %18
18: ; preds = %15, %3
ret i8* %5
}