#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 *, int);
void drv_MI_defchar(const int ascii, const unsigned char *matrix) {
  int i;
  char cmd[10] = "\376x";
  if (ascii < 8) {
    cmd[1] = (char)(64 + ascii * 8);
    for (i = 0; i < 8; i++) {
      cmd[i + 2] = matrix[i] & 0x1f;
    };
    drv_generic_serial_write(cmd, 10);
  }
}


x86 assembly (clang, -O0):
<drv_MI_defchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x1e(%rbp)
mov    0xed7(%rip),%ax
mov    %ax,-0x16(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1195 <drv_MI_defchar+0x85>
mov    -0x4(%rbp),%eax
shl    $0x3,%eax
add    $0x40,%eax
mov    %al,-0x1d(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1187 <drv_MI_defchar+0x77>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x1f,%eax
mov    %al,%cl
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x1e(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <drv_MI_defchar+0x42>
lea    -0x1e(%rbp),%rdi
mov    $0xa,%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_MI_defchar>:
sub    $0x18,%rsp
movb   $0xfe,0xe(%rsp)
cmp    $0x7,%edi
jg     1181 <drv_MI_defchar+0x71>
shl    $0x3,%dil
add    $0x40,%dil
mov    %dil,0xf(%rsp)
mov    (%rsi),%al
and    $0x1f,%al
mov    %al,0x10(%rsp)
mov    0x1(%rsi),%al
and    $0x1f,%al
mov    %al,0x11(%rsp)
mov    0x2(%rsi),%al
and    $0x1f,%al
mov    %al,0x12(%rsp)
mov    0x3(%rsi),%al
and    $0x1f,%al
mov    %al,0x13(%rsp)
mov    0x4(%rsi),%al
and    $0x1f,%al
mov    %al,0x14(%rsp)
mov    0x5(%rsi),%al
and    $0x1f,%al
mov    %al,0x15(%rsp)
mov    0x6(%rsi),%al
and    $0x1f,%al
mov    %al,0x16(%rsp)
mov    0x7(%rsi),%al
and    $0x1f,%al
mov    %al,0x17(%rsp)
lea    0xe(%rsp),%rdi
mov    $0xa,%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define void @drv_MI_defchar(i32 %0, i8* nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 -2, i8* %4
%5 = icmp slt i32 %0, 8
br i1 %5, label %6, label %43
6: ; preds = %2
%7 = trunc i32 %0 to i8
%8 = shl i8 %7, 3
%9 = add i8 %8, 64
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %10
%11 = load i8, i8* %1
%12 = and i8 %11, 31
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %1, i64 1
%15 = load i8, i8* %14
%16 = and i8 %15, 31
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
store i8 %16, i8* %17
%18 = getelementptr inbounds i8, i8* %1, i64 2
%19 = load i8, i8* %18
%20 = and i8 %19, 31
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
store i8 %20, i8* %21
%22 = getelementptr inbounds i8, i8* %1, i64 3
%23 = load i8, i8* %22
%24 = and i8 %23, 31
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
store i8 %24, i8* %25
%26 = getelementptr inbounds i8, i8* %1, i64 4
%27 = load i8, i8* %26
%28 = and i8 %27, 31
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 6
store i8 %28, i8* %29
%30 = getelementptr inbounds i8, i8* %1, i64 5
%31 = load i8, i8* %30
%32 = and i8 %31, 31
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 7
store i8 %32, i8* %33
%34 = getelementptr inbounds i8, i8* %1, i64 6
%35 = load i8, i8* %34
%36 = and i8 %35, 31
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
store i8 %36, i8* %37
%38 = getelementptr inbounds i8, i8* %1, i64 7
%39 = load i8, i8* %38
%40 = and i8 %39, 31
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 9
store i8 %40, i8* %41
%42 = call i32 @drv_generic_serial_write(i8* %4, i32 10)
br label %43
43: ; preds = %6, %2
ret void
}