#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*/ draw_row(char, char *, char *, int, int);
void draw_piece(char c, int x, int y, char oldpiece[7][7], char piece[7][7]) {
  for (int py = 0; py < 7; py++) {
    draw_row(c, oldpiece[py], piece[py], x, y + py);
  }
}


x86 assembly (clang, -O0):
<draw_piece>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x7,-0x24(%rbp)
jge    117f <draw_piece+0x6f>
mov    -0x1(%rbp),%al
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rsi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
add    -0x24(%rbp),%r8d
movsbl %al,%edi
call   1030 <draw_row@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <draw_piece+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_piece>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %rcx,%rbp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1030 <draw_row@plt>
lea    0x7(%rbp),%rsi
lea    0x7(%rbx),%rdx
lea    0x1(%r14),%r8d
mov    %r12d,%edi
mov    %r15d,%ecx
call   1030 <draw_row@plt>
lea    0xe(%rbp),%rsi
lea    0xe(%rbx),%rdx
lea    0x2(%r14),%r8d
mov    %r12d,%edi
mov    %r15d,%ecx
call   1030 <draw_row@plt>
lea    0x15(%rbp),%rsi
lea    0x15(%rbx),%rdx
lea    0x3(%r14),%r8d
mov    %r12d,%edi
mov    %r15d,%ecx
call   1030 <draw_row@plt>
lea    0x1c(%rbp),%rsi
lea    0x1c(%rbx),%rdx
lea    0x4(%r14),%r8d
mov    %r12d,%edi
mov    %r15d,%ecx
call   1030 <draw_row@plt>
lea    0x23(%rbp),%rsi
lea    0x23(%rbx),%rdx
lea    0x5(%r14),%r8d
mov    %r12d,%edi
mov    %r15d,%ecx
call   1030 <draw_row@plt>
add    $0x2a,%rbp
add    $0x2a,%rbx
add    $0x6,%r14d
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <draw_row@plt>

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

LLVM IR (-O2):
define void @draw_piece(i8 signext %0, i32 %1, i32 %2, [7 x i8]* %3, [7 x i8]* %4) {
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @draw_row(i8 signext %0, i8* %6, i8* %7, i32 %1, i32 %2)
%9 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 1, i64 0
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 1, i64 0
%11 = add i32 %2, 1
%12 = tail call i32 @draw_row(i8 signext %0, i8* %9, i8* %10, i32 %1, i32 %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 2, i64 0
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 2, i64 0
%15 = add i32 %2, 2
%16 = tail call i32 @draw_row(i8 signext %0, i8* %13, i8* %14, i32 %1, i32 %15)
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 3, i64 0
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 3, i64 0
%19 = add i32 %2, 3
%20 = tail call i32 @draw_row(i8 signext %0, i8* %17, i8* %18, i32 %1, i32 %19)
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 4, i64 0
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 4, i64 0
%23 = add i32 %2, 4
%24 = tail call i32 @draw_row(i8 signext %0, i8* %21, i8* %22, i32 %1, i32 %23)
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 5, i64 0
%26 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 5, i64 0
%27 = add i32 %2, 5
%28 = tail call i32 @draw_row(i8 signext %0, i8* %25, i8* %26, i32 %1, i32 %27)
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 6, i64 0
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 6, i64 0
%31 = add i32 %2, 6
%32 = tail call i32 @draw_row(i8 signext %0, i8* %29, i8* %30, i32 %1, i32 %31)
ret void
}