#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ mvwaddstr(int /*<<< orphan*/ *, char, char, char *);
void clear_brick(WINDOW *win, char mtx_brick[4][4], char y, char x) {
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (mtx_brick[i][j]) {
        if (y + i >= 0) {
          mvwaddstr(win, y + i + 1, x + j * 2 + 1, "  ");
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<clear_brick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    11d5 <clear_brick+0xc5>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11c2 <clear_brick+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11af <clear_brick+0x9f>
movsbl -0x11(%rbp),%eax
add    -0x18(%rbp),%eax
cmp    $0x0,%eax
jl     11aa <clear_brick+0x9a>
mov    -0x8(%rbp),%rdi
movsbl -0x11(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %al,%dl
movsbl -0x12(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
add    $0x1,%eax
lea    0xe61(%rip),%rcx
movsbl %dl,%esi
movsbl %al,%edx
call   1030 <mvwaddstr@plt>
jmp    11af <clear_brick+0x9f>
jmp    11b4 <clear_brick+0xa4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <clear_brick+0x32>
jmp    11c7 <clear_brick+0xb7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <clear_brick+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_brick>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x1(%rcx),%eax
movslq %edx,%rsi
mov    %rsi,0x20(%rsp)
lea    0x3(%rcx),%esi
lea    0x5(%rcx),%edi
add    $0x7,%cl
add    $0x1,%edx
movzbl %dl,%edx
mov    %rdx,0x18(%rsp)
xor    %r15d,%r15d
movsbl %cl,%ecx
mov    %ecx,0x14(%rsp)
lea    0xeac(%rip),%rbp
movsbl %dil,%ecx
mov    %ecx,0x10(%rsp)
movsbl %sil,%ecx
mov    %ecx,0xc(%rsp)
movsbl %al,%eax
mov    %eax,0x8(%rsp)
jmp    117e <clear_brick+0x6e>
nopl   (%rax)
add    $0x1,%r15
cmp    $0x4,%r15
je     121c <clear_brick+0x10c>
mov    0x20(%rsp),%rax
lea    (%rax,%r15,1),%r13
mov    0x18(%rsp),%rax
lea    (%rax,%r15,1),%r12
cmpb   $0x0,(%rbx,%r15,4)
je     11af <clear_brick+0x9f>
test   %r13,%r13
js     11af <clear_brick+0x9f>
movsbl %r12b,%esi
mov    %r14,%rdi
mov    0x8(%rsp),%edx
mov    %rbp,%rcx
call   1030 <mvwaddstr@plt>
cmpb   $0x0,0x1(%rbx,%r15,4)
je     11cf <clear_brick+0xbf>
test   %r13,%r13
js     11cf <clear_brick+0xbf>
movsbl %r12b,%esi
mov    %r14,%rdi
mov    0xc(%rsp),%edx
mov    %rbp,%rcx
call   1030 <mvwaddstr@plt>
cmpb   $0x0,0x2(%rbx,%r15,4)
je     11ef <clear_brick+0xdf>
test   %r13,%r13
js     11ef <clear_brick+0xdf>
movsbl %r12b,%esi
mov    %r14,%rdi
mov    0x10(%rsp),%edx
mov    %rbp,%rcx
call   1030 <mvwaddstr@plt>
cmpb   $0x0,0x3(%rbx,%r15,4)
je     1170 <clear_brick+0x60>
test   %r13,%r13
js     1170 <clear_brick+0x60>
movsbl %r12b,%esi
mov    %r14,%rdi
mov    0x14(%rsp),%edx
mov    %rbp,%rcx
call   1030 <mvwaddstr@plt>
jmp    1170 <clear_brick+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \00"
define void @clear_brick(i32* %0, [4 x i8]* %1, i8 signext %2, i8 signext %3) {
%5 = alloca i32*
%6 = alloca [4 x i8]*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store [4 x i8]* %1, [4 x i8]** %6
store i8 %2, i8* %7
store i8 %3, i8* %8
store i32 0, i32* %9
br label %11
11: ; preds = %56, %4
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %59
14: ; preds = %11
store i32 0, i32* %10
br label %15
15: ; preds = %52, %14
%16 = load i32, i32* %10
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %55
18: ; preds = %15
%19 = load [4 x i8]*, [4 x i8]** %6
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 %21
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %22, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %51
28: ; preds = %18
%29 = load i8, i8* %7
%30 = sext i8 %29 to i32
%31 = load i32, i32* %9
%32 = add nsw i32 %30, %31
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %50
34: ; preds = %28
%35 = load i32*, i32** %5
%36 = load i8, i8* %7
%37 = sext i8 %36 to i32
%38 = load i32, i32* %9
%39 = add nsw i32 %37, %38
%40 = add nsw i32 %39, 1
%41 = trunc i32 %40 to i8
%42 = load i8, i8* %8
%43 = sext i8 %42 to i32
%44 = load i32, i32* %10
%45 = mul nsw i32 %44, 2
%46 = add nsw i32 %43, %45
%47 = add nsw i32 %46, 1
%48 = trunc i32 %47 to i8
%49 = call i32 @mvwaddstr(i32* %35, i8 signext %41, i8 signext %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %50
50: ; preds = %34, %28
br label %51
51: ; preds = %50, %18
br label %52
52: ; preds = %51
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %15
55: ; preds = %15
br label %56
56: ; preds = %55
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %11
59: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" \00"
define void @clear_brick(i32* %0, [4 x i8]* nocapture %1, i8 signext %2, i8 signext %3) {
%5 = add i8 %3, 1
%6 = sext i8 %2 to i64
%7 = add i8 %3, 3
%8 = add i8 %3, 5
%9 = add i8 %3, 7
br label %10
10: ; preds = %4, %43
%11 = phi i64 [ 0, %4 ], [ %44, %43 ]
%12 = add nsw i64 %11, %6
%13 = icmp slt i64 %12, 0
%14 = trunc i64 %12 to i8
%15 = add i8 %14, 1
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 %11, i64 0
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = select i1 %18, i1 true, i1 %13
br i1 %19, label %22, label %20
20: ; preds = %10
%21 = tail call i32 @mvwaddstr(i32* %0, i8 signext %15, i8 signext %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %10, %20
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 %11, i64 1
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
%26 = select i1 %25, i1 true, i1 %13
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = tail call i32 @mvwaddstr(i32* %0, i8 signext %15, i8 signext %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 %11, i64 2
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
%33 = select i1 %32, i1 true, i1 %13
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = tail call i32 @mvwaddstr(i32* %0, i8 signext %15, i8 signext %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 %11, i64 3
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
%40 = select i1 %39, i1 true, i1 %13
br i1 %40, label %43, label %41
41: ; preds = %36
%42 = tail call i32 @mvwaddstr(i32* %0, i8 signext %15, i8 signext %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
%44 = add nuw nsw i64 %11, 1
%45 = icmp eq i64 %44, 4
br i1 %45, label %46, label %10
46: ; preds = %43
ret void
}