#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ SendData(int /*<<< orphan*/);
int /*<<< orphan*/ SetColumnAddress(int);
int /*<<< orphan*/ SetPageAddress(int);
void WriteBufferToDisplay(uint8_t *buffer) {
  uint8_t i, j;
  for (i = 0; i < 0x08; i++) {
    SetPageAddress(i);
    SetColumnAddress(0x00);
    for (j = 0; j < 0x80; j++) {
      SendData(*buffer++);
    }
  }
}


x86 assembly (clang, -O0):
<WriteBufferToDisplay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11a7 <WriteBufferToDisplay+0x77>
mov    -0xc(%rbp),%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x80,-0x10(%rbp)
jge    1194 <WriteBufferToDisplay+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%edi
call   1050 <SendData@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <WriteBufferToDisplay+0x33>
jmp    1199 <WriteBufferToDisplay+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <WriteBufferToDisplay+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteBufferToDisplay>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    1150 <WriteBufferToDisplay+0x20>
mov    $0x1,%edi
call   1040 <SetPageAddress@plt>
xor    %r14d,%r14d
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx,%r14,1),%edi
call   1050 <SendData@plt>
add    $0x4,%r14
cmp    $0x200,%r14d
jne    1180 <WriteBufferToDisplay+0x50>
mov    $0x2,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
add    %r14,%rbx
mov    $0x80,%ebp
nop
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    11b0 <WriteBufferToDisplay+0x80>
mov    $0x3,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    11e0 <WriteBufferToDisplay+0xb0>
mov    $0x4,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    1210 <WriteBufferToDisplay+0xe0>
mov    $0x5,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    1240 <WriteBufferToDisplay+0x110>
mov    $0x6,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    1270 <WriteBufferToDisplay+0x140>
mov    $0x7,%edi
call   1040 <SetPageAddress@plt>
xor    %edi,%edi
call   1030 <SetColumnAddress@plt>
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
add    $0x4,%rbx
call   1050 <SendData@plt>
add    $0xffffffff,%ebp
jne    12a0 <WriteBufferToDisplay+0x170>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @WriteBufferToDisplay(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @SetPageAddress(i32 %9)
%11 = call i32 @SetColumnAddress(i32 0)
store i32 0, i32* %4
br label %12
12: ; preds = %20, %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 128
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32*, i32** %2
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %2
%18 = load i32, i32* %16
%19 = call i32 @SendData(i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %12
23: ; preds = %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %5
27: ; preds = %5
ret void
}

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