#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*/ drv_generic_serial_write(char const *, int const);
void drv_MI_write(const int row, const int col, const char *data,
                  const int len) {
  char cmd[2] = "\376x";
  int ddbase = 128;
  if (row & 1) {
    ddbase += 64;
  }
  if (row & 2) {
    ddbase += 20;
  }
  cmd[1] = (char)(ddbase + col);
  drv_generic_serial_write(cmd, 2);
  drv_generic_serial_write(data, len);
}


x86 assembly (clang, -O0):
<drv_MI_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    0xed4(%rip),%ax
mov    %ax,-0x16(%rbp)
movl   $0x80,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     114f <drv_MI_write+0x3f>
mov    -0x1c(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1167 <drv_MI_write+0x57>
mov    -0x1c(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %al,-0x15(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_MI_write>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %edi,%eax
shl    $0x6,%eax
test   $0x2,%dil
mov    $0x80,%ecx
mov    $0x94,%edx
cmove  %ecx,%edx
movw   $0x78fe,0x6(%rsp)
or     %eax,%edx
add    %esi,%edx
mov    %dl,0x7(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.drv_MI_write.cmd = [2 x i8] c"\FEx"
define void @drv_MI_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [2 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = bitcast [2 x i8]* %9 to i8*
store i32 128, i32* %10
%12 = load i32, i32* %5
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i32, i32* %10
%17 = add nsw i32 %16, 64
store i32 %17, i32* %10
br label %18
18: ; preds = %15, %4
%19 = load i32, i32* %5
%20 = and i32 %19, 2
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %10
%24 = add nsw i32 %23, 20
store i32 %24, i32* %10
br label %25
25: ; preds = %22, %18
%26 = load i32, i32* %10
%27 = load i32, i32* %6
%28 = add nsw i32 %26, %27
%29 = trunc i32 %28 to i8
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 1
store i8 %29, i8* %30
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%32 = call i32 @drv_generic_serial_write(i8* %31, i32 2)
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = call i32 @drv_generic_serial_write(i8* %33, i32 %34)
ret void
}

LLVM IR (-O2):
define void @drv_MI_write(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i16
%6 = bitcast i16* %5 to i8*
store i16 30974, i16* %5
%7 = and i32 %0, 1
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 128, i32 192
%10 = and i32 %0, 2
%11 = icmp eq i32 %10, 0
%12 = or i32 %9, 20
%13 = select i1 %11, i32 %9, i32 %12
%14 = bitcast i16* %5 to [2 x i8]*
%15 = add nsw i32 %13, %1
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
store i8 %16, i8* %17
%18 = call i32 @drv_generic_serial_write(i8* %6, i32 2)
%19 = call i32 @drv_generic_serial_write(i8* %2, i32 %3)
ret void
}