#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*/ CE_High();
int /*<<< orphan*/ CE_Low();
int /*<<< orphan*/ Send_Byte(unsigned char);
int /*<<< orphan*/ Wait_Busy();
void Page_Program(unsigned long Dst, unsigned char *buffer) {
  int i;
  CE_Low();
  Send_Byte(0x02);
  Send_Byte(((Dst & 0xFFFFFF) >> 16));
  Send_Byte(((Dst & 0xFFFF) >> 8));
  Send_Byte(Dst & 0xFF);
  for (i = 0; i < 256; i++) {
    Send_Byte(buffer[i]);
  }
  CE_High();
  Wait_Busy();
}


x86 assembly (clang, -O0):
<Page_Program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <CE_Low@plt>
mov    $0x2,%edi
call   1030 <Send_Byte@plt>
mov    -0x8(%rbp),%rax
and    $0xffffff,%rax
shr    $0x10,%rax
movzbl %al,%edi
call   1030 <Send_Byte@plt>
mov    -0x8(%rbp),%rax
and    $0xffff,%rax
shr    $0x8,%rax
movzbl %al,%edi
call   1030 <Send_Byte@plt>
mov    -0x8(%rbp),%rax
and    $0xff,%rax
movzbl %al,%edi
call   1030 <Send_Byte@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11d2 <Page_Program+0x92>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <Send_Byte@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <Page_Program+0x66>
mov    $0x0,%al
call   1040 <CE_High@plt>
mov    $0x0,%al
call   1050 <Wait_Busy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Page_Program>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <CE_Low@plt>
mov    $0x2,%edi
call   1030 <Send_Byte@plt>
mov    %r15d,%eax
shr    $0x10,%eax
movzbl %al,%edi
call   1030 <Send_Byte@plt>
mov    %r15,%rax
movzbl %ah,%edi
call   1030 <Send_Byte@plt>
movzbl %r15b,%edi
call   1030 <Send_Byte@plt>
movzbl (%r14,%rbx,1),%edi
call   1030 <Send_Byte@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1180 <Page_Program+0x40>
xor    %eax,%eax
call   1040 <CE_High@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <Wait_Busy@plt>

LLVM IR (-O0):
define void @Page_Program(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = call i32 (...) @CE_Low()
%7 = call i32 @Send_Byte(i8 zeroext 2)
%8 = load i64, i64* %3
%9 = and i64 %8, 16777215
%10 = lshr i64 %9, 16
%11 = trunc i64 %10 to i8
%12 = call i32 @Send_Byte(i8 zeroext %11)
%13 = load i64, i64* %3
%14 = and i64 %13, 65535
%15 = lshr i64 %14, 8
%16 = trunc i64 %15 to i8
%17 = call i32 @Send_Byte(i8 zeroext %16)
%18 = load i64, i64* %3
%19 = and i64 %18, 255
%20 = trunc i64 %19 to i8
%21 = call i32 @Send_Byte(i8 zeroext %20)
store i32 0, i32* %5
br label %22
22: ; preds = %32, %2
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 256
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @Send_Byte(i8 zeroext %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %22
35: ; preds = %22
%36 = call i32 (...) @CE_High()
%37 = call i32 (...) @Wait_Busy()
ret void
}

LLVM IR (-O2):
define void @Page_Program(i64 %0, i8* nocapture %1) {
%3 = tail call i32 (...) @CE_Low()
%4 = tail call i32 @Send_Byte(i8 zeroext 2)
%5 = lshr i64 %0, 16
%6 = trunc i64 %5 to i8
%7 = tail call i32 @Send_Byte(i8 zeroext %6)
%8 = lshr i64 %0, 8
%9 = trunc i64 %8 to i8
%10 = tail call i32 @Send_Byte(i8 zeroext %9)
%11 = trunc i64 %0 to i8
%12 = tail call i32 @Send_Byte(i8 zeroext %11)
br label %13
13: ; preds = %2, %13
%14 = phi i64 [ 0, %2 ], [ %18, %13 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = tail call i32 @Send_Byte(i8 zeroext %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, 256
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = tail call i32 (...) @CE_High()
%22 = tail call i32 (...) @Wait_Busy()
ret void
}