#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 /*<<< orphan*/ uint8_t;
typedef int int8_t;

/* Variables and functions */
int /*<<< orphan*/ hd44780_extif_data_set(int /*<<< orphan*/);
int /*<<< orphan*/ hd44780_extif_pin_rw(int /*<<< orphan*/);
int /*<<< orphan*/ hd44780_extif_wait_1us(int);
scalar_t__ hd44780_is_busy();
int /*<<< orphan*/ hd44780_ll_enable_pulse();
int /*<<< orphan*/ hd44780_ll_select_register(int /*<<< orphan*/);
int8_t hd44780_ll_register_write(uint8_t data, uint8_t is_data_reg) {
  if (hd44780_is_busy()) {
    return (-1);
  }
  hd44780_ll_select_register(is_data_reg);
  hd44780_extif_pin_rw(0);
  hd44780_extif_wait_1us(1);
  hd44780_extif_data_set(data);
  hd44780_ll_enable_pulse();
  return (0);
}


x86 assembly (clang, -O0):
<hd44780_ll_register_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <hd44780_is_busy@plt>
cmp    $0x0,%rax
je     118b <hd44780_ll_register_write+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <hd44780_ll_register_write+0x5a>
mov    -0xc(%rbp),%edi
call   1030 <hd44780_ll_select_register@plt>
xor    %edi,%edi
call   1080 <hd44780_extif_pin_rw@plt>
mov    $0x1,%edi
call   1060 <hd44780_extif_wait_1us@plt>
mov    -0x8(%rbp),%edi
call   1070 <hd44780_extif_data_set@plt>
mov    $0x0,%al
call   1050 <hd44780_ll_enable_pulse@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hd44780_ll_register_write>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <hd44780_is_busy@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11a3 <hd44780_ll_register_write+0x43>
mov    %ebp,%edi
call   1030 <hd44780_ll_select_register@plt>
xor    %edi,%edi
call   1080 <hd44780_extif_pin_rw@plt>
mov    $0x1,%edi
call   1060 <hd44780_extif_wait_1us@plt>
mov    %ebx,%edi
call   1070 <hd44780_extif_data_set@plt>
xor    %eax,%eax
call   1050 <hd44780_ll_enable_pulse@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hd44780_ll_register_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = call i64 (...) @hd44780_is_busy()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %17
9: ; preds = %2
%10 = load i32, i32* %5
%11 = call i32 @hd44780_ll_select_register(i32 %10)
%12 = call i32 @hd44780_extif_pin_rw(i32 0)
%13 = call i32 @hd44780_extif_wait_1us(i32 1)
%14 = load i32, i32* %4
%15 = call i32 @hd44780_extif_data_set(i32 %14)
%16 = call i32 (...) @hd44780_ll_enable_pulse()
store i32 0, i32* %3
br label %17
17: ; preds = %9, %8
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @hd44780_ll_register_write(i32 %0, i32 %1) {
%3 = tail call i64 (...) @hd44780_is_busy()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = tail call i32 @hd44780_ll_select_register(i32 %1)
%7 = tail call i32 @hd44780_extif_pin_rw(i32 0)
%8 = tail call i32 @hd44780_extif_wait_1us(i32 1)
%9 = tail call i32 @hd44780_extif_data_set(i32 %0)
%10 = tail call i32 (...) @hd44780_ll_enable_pulse()
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ 0, %5 ], [ -1, %2 ]
ret i32 %12
}