#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 */
unsigned char keys_read_row(unsigned char);
int /*<<< orphan*/ lcd_goto(unsigned char, unsigned char);
int /*<<< orphan*/ lcd_putc(char);
void debug_key_matrix() {
  unsigned char row;
  unsigned char columns;
  for (;;) {
    for (row = 0; row <= 13; ++row) {
      lcd_goto((row / 4) * 10, row % 4);
      columns = keys_read_row(row);
      lcd_putc(columns & 0x80 ? '1' : '0');
      lcd_putc(columns & 0x40 ? '1' : '0');
      lcd_putc(columns & 0x20 ? '1' : '0');
      lcd_putc(columns & 0x10 ? '1' : '0');
      lcd_putc(columns & 0x08 ? '1' : '0');
      lcd_putc(columns & 0x04 ? '1' : '0');
      lcd_putc(columns & 0x02 ? '1' : '0');
      lcd_putc(columns & 0x01 ? '1' : '0');
    }
  }
}


x86 assembly (clang, -O0):
<debug_key_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0xd,%eax
jg     1287 <debug_key_matrix+0x157>
movzbl -0x1(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
imul   $0xa,%eax,%eax
mov    %al,%cl
movzbl -0x1(%rbp),%eax
mov    $0x4,%esi
cltd
idiv   %esi
mov    %dl,%al
movzbl %cl,%edi
movzbl %al,%esi
call   1030 <lcd_goto@plt>
movzbl -0x1(%rbp),%edi
call   1040 <keys_read_row@plt>
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%edx
and    $0x80,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x40,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x20,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x10,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x8,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x4,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x2,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
movzbl -0x2(%rbp),%edx
and    $0x1,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1050 <lcd_putc@plt>
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    113c <debug_key_matrix+0xc>
jmp    1138 <debug_key_matrix+0x8>

x86 assembly (clang, -O2):
<debug_key_matrix>:
push   %rbp
push   %rbx
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
shr    $0x2,%al
movzbl %al,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
and    $0x3,%cl
movzbl %al,%edi
movzbl %cl,%esi
call   1030 <lcd_goto@plt>
movzbl %bl,%ebx
mov    %ebx,%edi
call   1040 <keys_read_row@plt>
movzbl %al,%ebp
mov    %ebp,%eax
and    $0xffffff80,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
mov    %ebp,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1050 <lcd_putc@plt>
and    $0x1,%bpl
or     $0x30,%bpl
movzbl %bpl,%edi
call   1050 <lcd_putc@plt>
add    $0x1,%bl
cmp    $0xe,%bl
jne    1150 <debug_key_matrix+0x20>
jmp    1140 <debug_key_matrix+0x10>

LLVM IR (-O0):
define void @debug_key_matrix() {
%1 = alloca i8
%2 = alloca i8
br label %3
3: ; preds = %88, %0
store i8 0, i8* %1
br label %4
4: ; preds = %85, %3
%5 = load i8, i8* %1
%6 = zext i8 %5 to i32
%7 = icmp sle i32 %6, 13
br i1 %7, label %8, label %88
8: ; preds = %4
%9 = load i8, i8* %1
%10 = zext i8 %9 to i32
%11 = sdiv i32 %10, 4
%12 = mul nsw i32 %11, 10
%13 = trunc i32 %12 to i8
%14 = load i8, i8* %1
%15 = zext i8 %14 to i32
%16 = srem i32 %15, 4
%17 = trunc i32 %16 to i8
%18 = call i32 @lcd_goto(i8 zeroext %13, i8 zeroext %17)
%19 = load i8, i8* %1
%20 = call zeroext i8 @keys_read_row(i8 zeroext %19)
store i8 %20, i8* %2
%21 = load i8, i8* %2
%22 = zext i8 %21 to i32
%23 = and i32 %22, 128
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 49, i32 48
%27 = trunc i32 %26 to i8
%28 = call i32 @lcd_putc(i8 signext %27)
%29 = load i8, i8* %2
%30 = zext i8 %29 to i32
%31 = and i32 %30, 64
%32 = icmp ne i32 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i32 49, i32 48
%35 = trunc i32 %34 to i8
%36 = call i32 @lcd_putc(i8 signext %35)
%37 = load i8, i8* %2
%38 = zext i8 %37 to i32
%39 = and i32 %38, 32
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 49, i32 48
%43 = trunc i32 %42 to i8
%44 = call i32 @lcd_putc(i8 signext %43)
%45 = load i8, i8* %2
%46 = zext i8 %45 to i32
%47 = and i32 %46, 16
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 49, i32 48
%51 = trunc i32 %50 to i8
%52 = call i32 @lcd_putc(i8 signext %51)
%53 = load i8, i8* %2
%54 = zext i8 %53 to i32
%55 = and i32 %54, 8
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 49, i32 48
%59 = trunc i32 %58 to i8
%60 = call i32 @lcd_putc(i8 signext %59)
%61 = load i8, i8* %2
%62 = zext i8 %61 to i32
%63 = and i32 %62, 4
%64 = icmp ne i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i32 49, i32 48
%67 = trunc i32 %66 to i8
%68 = call i32 @lcd_putc(i8 signext %67)
%69 = load i8, i8* %2
%70 = zext i8 %69 to i32
%71 = and i32 %70, 2
%72 = icmp ne i32 %71, 0
%73 = zext i1 %72 to i64
%74 = select i1 %72, i32 49, i32 48
%75 = trunc i32 %74 to i8
%76 = call i32 @lcd_putc(i8 signext %75)
%77 = load i8, i8* %2
%78 = zext i8 %77 to i32
%79 = and i32 %78, 1
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i64
%82 = select i1 %80, i32 49, i32 48
%83 = trunc i32 %82 to i8
%84 = call i32 @lcd_putc(i8 signext %83)
br label %85
85: ; preds = %8
%86 = load i8, i8* %1
%87 = add i8 %86, 1
store i8 %87, i8* %1
br label %4
88: ; preds = %4
br label %3
}

LLVM IR (-O2):
define void @debug_key_matrix() {
br label %1
1: ; preds = %2, %0
br label %2
2: ; preds = %1, %2
%3 = phi i8 [ 0, %1 ], [ %41, %2 ]
%4 = lshr i8 %3, 2
%5 = mul nuw nsw i8 %4, 10
%6 = and i8 %3, 3
%7 = tail call i32 @lcd_goto(i8 zeroext %5, i8 zeroext %6)
%8 = tail call zeroext i8 @keys_read_row(i8 zeroext %3)
%9 = zext i8 %8 to i32
%10 = and i32 %9, 128
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8 48, i8 49
%13 = tail call i32 @lcd_putc(i8 signext %12)
%14 = and i32 %9, 64
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 48, i8 49
%17 = tail call i32 @lcd_putc(i8 signext %16)
%18 = and i32 %9, 32
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8 48, i8 49
%21 = tail call i32 @lcd_putc(i8 signext %20)
%22 = and i32 %9, 16
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8 48, i8 49
%25 = tail call i32 @lcd_putc(i8 signext %24)
%26 = and i32 %9, 8
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8 48, i8 49
%29 = tail call i32 @lcd_putc(i8 signext %28)
%30 = and i32 %9, 4
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i8 48, i8 49
%33 = tail call i32 @lcd_putc(i8 signext %32)
%34 = and i32 %9, 2
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8 48, i8 49
%37 = tail call i32 @lcd_putc(i8 signext %36)
%38 = and i8 %8, 1
%39 = or i8 %38, 48
%40 = tail call i32 @lcd_putc(i8 signext %39)
%41 = add nuw nsw i8 %3, 1
%42 = icmp eq i8 %41, 14
br i1 %42, label %1, label %2
}