#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*/ GPIOPinWrite(int, int, int);
int /*<<< orphan*/ LCD_set_pos(int /*<<< orphan*/, int /*<<< orphan*/);
void LCD_draw_frame_buffer(int start_row, int start_column,
                           unsigned char *frame_buffer, int column_max) {
  int i, column, row;
  int row_max = (start_row + 6) * column_max;
  LCD_set_pos(0, 0);
  GPIOPinWrite(0x40004000, 0x00000001, 0x00);
  GPIOPinWrite(0x40004000, 0x00000010, 0xff);
  for (row = start_row * column_max; row < row_max; row += column_max) {
    for (column = start_column; column < start_column + 84; column++) {
      for (i = 0; i < 8; i++) {
        GPIOPinWrite(0x40004000, 0x00000008, 0x00);
        if ((*(frame_buffer + row + column)) & 0x80 >> i)
          GPIOPinWrite(0x40004000, 0x00000004, 0xff);
        else
          GPIOPinWrite(0x40004000, 0x00000004, 0x00);
        GPIOPinWrite(0x40004000, 0x00000008, 0xff);
      }
    }
  }
  GPIOPinWrite(0x40004000, 0x00000001, 0xff);
}


x86 assembly (clang, -O0):
<LCD_draw_frame_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6,%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1040 <LCD_set_pos@plt>
mov    $0x40004000,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x4(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    125b <LCD_draw_frame_buffer+0x13b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x54,%ecx
cmp    %ecx,%eax
jge    1248 <LCD_draw_frame_buffer+0x128>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1235 <LCD_draw_frame_buffer+0x115>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%ecx
mov    $0x80,%edx
sar    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1202 <LCD_draw_frame_buffer+0xe2>
mov    $0x40004000,%edi
mov    $0x4,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
jmp    1213 <LCD_draw_frame_buffer+0xf3>
mov    $0x40004000,%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <LCD_draw_frame_buffer+0x84>
jmp    123a <LCD_draw_frame_buffer+0x11a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118c <LCD_draw_frame_buffer+0x6c>
jmp    124d <LCD_draw_frame_buffer+0x12d>
mov    -0x14(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    117a <LCD_draw_frame_buffer+0x5a>
mov    $0x40004000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCD_draw_frame_buffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%r12d
lea    0x6(%r12),%r13d
imul   %ecx,%r13d
xor    %ebp,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1040 <LCD_set_pos@plt>
mov    $0x40004000,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x10,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
imul   %r15d,%r12d
cmp    %r13d,%r12d
jge    13ee <LCD_draw_frame_buffer+0x2ce>
movslq %r14d,%rcx
movslq %r12d,%r12
movslq %r15d,%r15
movslq %r13d,%rax
mov    %rax,0x8(%rsp)
lea    0x53(%rcx),%eax
movslq %eax,%r13
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x10(%rsp)
add    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
cmpb   $0x0,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmovns %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x40,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x20,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x10,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x8,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x4,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x2,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1030 <GPIOPinWrite@plt>
testb  $0x1,0x1(%rbx,%r14,1)
mov    $0xff,%edx
cmove  %ebp,%edx
mov    $0x40004000,%edi
mov    $0x4,%esi
call   1030 <GPIOPinWrite@plt>
mov    $0x40004000,%edi
mov    $0x8,%esi
mov    $0xff,%edx
call   1030 <GPIOPinWrite@plt>
add    $0x1,%r14
cmp    %r13,%r14
jl     11c0 <LCD_draw_frame_buffer+0xa0>
add    %r15,%r12
add    %r15,%rbx
cmp    0x8(%rsp),%r12
jl     11b0 <LCD_draw_frame_buffer+0x90>
mov    $0x40004000,%edi
mov    $0x1,%esi
mov    $0xff,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <GPIOPinWrite@plt>

LLVM IR (-O0):
define void @LCD_draw_frame_buffer(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 6
%15 = load i32, i32* %8
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %12
%17 = call i32 @LCD_set_pos(i32 0, i32 0)
%18 = call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 0)
%19 = call i32 @GPIOPinWrite(i32 1073758208, i32 16, i32 255)
%20 = load i32, i32* %5
%21 = load i32, i32* %8
%22 = mul nsw i32 %20, %21
store i32 %22, i32* %11
br label %23
23: ; preds = %67, %4
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %71
27: ; preds = %23
%28 = load i32, i32* %6
store i32 %28, i32* %10
br label %29
29: ; preds = %63, %27
%30 = load i32, i32* %10
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 84
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %66
34: ; preds = %29
store i32 0, i32* %9
br label %35
35: ; preds = %59, %34
%36 = load i32, i32* %9
%37 = icmp slt i32 %36, 8
br i1 %37, label %38, label %62
38: ; preds = %35
%39 = call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%40 = load i8*, i8** %7
%41 = load i32, i32* %11
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = load i32, i32* %9
%50 = ashr i32 128, %49
%51 = and i32 %48, %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %38
%54 = call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 255)
br label %57
55: ; preds = %38
%56 = call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 0)
br label %57
57: ; preds = %55, %53
%58 = call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
br label %59
59: ; preds = %57
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %35
62: ; preds = %35
br label %63
63: ; preds = %62
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
br label %29
66: ; preds = %29
br label %67
67: ; preds = %66
%68 = load i32, i32* %8
%69 = load i32, i32* %11
%70 = add nsw i32 %69, %68
store i32 %70, i32* %11
br label %23
71: ; preds = %23
%72 = call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 255)
ret void
}

LLVM IR (-O2):
define void @LCD_draw_frame_buffer(i32 %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = add nsw i32 %0, 6
%6 = mul nsw i32 %5, %3
%7 = tail call i32 @LCD_set_pos(i32 0, i32 0)
%8 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 0)
%9 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 16, i32 255)
%10 = mul i32 %3, %0
%11 = icmp slt i32 %10, %6
br i1 %11, label %12, label %85
12: ; preds = %4
%13 = sext i32 %1 to i64
%14 = sext i32 %10 to i64
%15 = sext i32 %3 to i64
%16 = sext i32 %6 to i64
%17 = add nsw i32 %1, 83
%18 = sext i32 %17 to i64
br label %19
19: ; preds = %12, %82
%20 = phi i64 [ %14, %12 ], [ %83, %82 ]
%21 = getelementptr inbounds i8, i8* %2, i64 %20
br label %22
22: ; preds = %19, %22
%23 = phi i64 [ %13, %19 ], [ %80, %22 ]
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%26 = load i8, i8* %24
%27 = icmp sgt i8 %26, -1
%28 = select i1 %27, i32 0, i32 255
%29 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %28)
%30 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%31 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%32 = load i8, i8* %24
%33 = and i8 %32, 64
%34 = icmp eq i8 %33, 0
%35 = select i1 %34, i32 0, i32 255
%36 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %35)
%37 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%38 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%39 = load i8, i8* %24
%40 = and i8 %39, 32
%41 = icmp eq i8 %40, 0
%42 = select i1 %41, i32 0, i32 255
%43 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %42)
%44 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%45 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%46 = load i8, i8* %24
%47 = and i8 %46, 16
%48 = icmp eq i8 %47, 0
%49 = select i1 %48, i32 0, i32 255
%50 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %49)
%51 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%52 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%53 = load i8, i8* %24
%54 = and i8 %53, 8
%55 = icmp eq i8 %54, 0
%56 = select i1 %55, i32 0, i32 255
%57 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %56)
%58 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%59 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%60 = load i8, i8* %24
%61 = and i8 %60, 4
%62 = icmp eq i8 %61, 0
%63 = select i1 %62, i32 0, i32 255
%64 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %63)
%65 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%66 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%67 = load i8, i8* %24
%68 = and i8 %67, 2
%69 = icmp eq i8 %68, 0
%70 = select i1 %69, i32 0, i32 255
%71 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %70)
%72 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%73 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 0)
%74 = load i8, i8* %24
%75 = and i8 %74, 1
%76 = icmp eq i8 %75, 0
%77 = select i1 %76, i32 0, i32 255
%78 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 4, i32 %77)
%79 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 8, i32 255)
%80 = add nsw i64 %23, 1
%81 = icmp slt i64 %23, %18
br i1 %81, label %22, label %82
82: ; preds = %22
%83 = add i64 %20, %15
%84 = icmp slt i64 %83, %16
br i1 %84, label %19, label %85
85: ; preds = %82, %4
%86 = tail call i32 @GPIOPinWrite(i32 1073758208, i32 1, i32 255)
ret void
}