#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*/ memcpy(int *, int const *, int const);
int write(int const, int *, int const);
int _oled_dat(const int fd, const uint8_t *dat, const uint8_t len) {
  if (len > 255)
    return -1;
  uint8_t buf[256] = {0x40};
  memcpy(buf + 1, dat, len);
  return write(fd, buf, 1 + len);
}


x86 assembly (clang, -O0):
<_oled_dat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jle    115e <_oled_dat+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <_oled_dat+0x7a>
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x40,-0x420(%rbp)
lea    -0x420(%rbp),%rdi
add    $0x4,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_oled_dat>:
mov    $0xffffffff,%eax
cmp    $0xff,%edx
jg     1197 <_oled_dat+0x67>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsp,%r15
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x40,(%rsp)
lea    0x4(%rsp),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
add    $0x1,%ebx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_oled_dat(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [256 x i32]
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = icmp sgt i32 %9, 255
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 -1, i32* %4
br label %26
12: ; preds = %3
%13 = bitcast [256 x i32]* %8 to i8*
%14 = bitcast i8* %13 to <{ i32, [255 x i32] }>*
%15 = getelementptr inbounds <{ i32, [255 x i32] }>, <{ i32, [255 x i32] }>* %14, i32 0, i32 0
store i32 64, i32* %15
%16 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32*, i32** %6
%19 = load i32, i32* %7
%20 = call i32 @memcpy(i32* %17, i32* %18, i32 %19)
%21 = load i32, i32* %5
%22 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%23 = load i32, i32* %7
%24 = add nsw i32 1, %23
%25 = call i32 @write(i32 %21, i32* %22, i32 %24)
store i32 %25, i32* %4
br label %26
26: ; preds = %12, %11
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
define i32 @_oled_dat(i32 %0, i32* %1, i32 %2) {
%4 = alloca [256 x i32]
%5 = icmp sgt i32 %2, 255
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = bitcast [256 x i32]* %4 to i8*
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
store i32 64, i32* %8
%9 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 1
%10 = call i32 @memcpy(i32* %9, i32* %1, i32 %2)
%11 = add nsw i32 %2, 1
%12 = call i32 @write(i32 %0, i32* %8, i32 %11)
br label %13
13: ; preds = %3, %6
%14 = phi i32 [ %12, %6 ], [ -1, %3 ]
ret i32 %14
}