#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_CW_send(char *, int);
void drv_CW12232_defchar(const int ascii, const unsigned char *buffer) {
  int i, j;
  char cmd[10] = "\376Nn123456\375";
  cmd[2] = (char)ascii;
  for (i = 0; i < 6; i++) {
    cmd[3 + i] = 0;
    for (j = 0; j < 8; j++) {
      if (buffer[j] & (1 << (5 - i))) {
        cmd[3 + i] |= (1 << j);
      }
    }
  }
  drv_CW_send(cmd, 10);
}


x86 assembly (clang, -O0):
<drv_CW12232_defchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xed7(%rip),%ax
mov    %ax,-0x1a(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11d5 <drv_CW12232_defchar+0xc5>
mov    -0x14(%rbp),%eax
add    $0x3,%eax
cltq
movb   $0x0,-0x22(%rbp,%rax,1)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11c2 <drv_CW12232_defchar+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    $0x5,%ecx
sub    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11af <drv_CW12232_defchar+0x9f>
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x14(%rbp),%eax
add    $0x3,%eax
cltq
movsbl -0x22(%rbp,%rax,1),%ecx
or     %edx,%ecx
mov    %cl,-0x22(%rbp,%rax,1)
jmp    11b4 <drv_CW12232_defchar+0xa4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1160 <drv_CW12232_defchar+0x50>
jmp    11c7 <drv_CW12232_defchar+0xb7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <drv_CW12232_defchar+0x32>
lea    -0x22(%rbp),%rdi
mov    $0xa,%esi
call   1030 <drv_CW_send@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_CW12232_defchar>:
sub    $0x28,%rsp
movabs $0x35343332316e4efe,%rax
33 34 35
mov    %rax,(%rsp)
movw   $0xfd36,0x8(%rsp)
mov    %dil,0x2(%rsp)
movzbl 0x1(%rsi),%edx
movzbl 0x2(%rsi),%edi
movzbl 0x3(%rsi),%eax
movzbl 0x4(%rsi),%r10d
movzbl 0x5(%rsi),%ecx
movzbl 0x6(%rsi),%r9d
movzbl 0x7(%rsi),%r8d
movd   %r8d,%xmm0
pshufd $0x0,%xmm0,%xmm9
movd   %r9d,%xmm0
pshufd $0x0,%xmm0,%xmm11
movd   %ecx,%xmm0
pshufd $0x0,%xmm0,%xmm6
movd   %r10d,%xmm0
pshufd $0x0,%xmm0,%xmm7
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm4
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm2
movd   %edx,%xmm0
pshufd $0x0,%xmm0,%xmm0
movzbl (%rsi),%esi
movd   %esi,%xmm1
pshufd $0x0,%xmm1,%xmm5
movdqa 0xe5b(%rip),%xmm1
movdqa %xmm5,%xmm3
pand   %xmm1,%xmm3
movdqa 0xe5a(%rip),%xmm8
pand   %xmm8,%xmm5
pxor   %xmm12,%xmm12
pcmpgtd %xmm12,%xmm5
pcmpeqd %xmm1,%xmm3
packssdw %xmm5,%xmm3
packsswb %xmm3,%xmm3
movdqa 0xe46(%rip),%xmm10
pand   %xmm3,%xmm10
movdqa %xmm0,%xmm5
pand   %xmm1,%xmm5
pand   %xmm8,%xmm0
pcmpeqd %xmm12,%xmm0
pcmpeqd %xmm12,%xmm5
packssdw %xmm0,%xmm5
packsswb %xmm5,%xmm5
movdqa 0xe2a(%rip),%xmm0
psubb  %xmm3,%xmm0
movdqa %xmm10,%xmm3
pand   %xmm5,%xmm3
pandn  %xmm0,%xmm5
por    %xmm3,%xmm5
movdqa %xmm2,%xmm0
pand   %xmm1,%xmm0
pand   %xmm8,%xmm2
pcmpeqd %xmm12,%xmm2
pcmpeqd %xmm12,%xmm0
packssdw %xmm2,%xmm0
packsswb %xmm0,%xmm0
movdqa 0xdfe(%rip),%xmm2
por    %xmm5,%xmm2
pand   %xmm0,%xmm5
pandn  %xmm2,%xmm0
por    %xmm5,%xmm0
or     %edi,%edx
movdqa %xmm4,%xmm2
pand   %xmm1,%xmm2
pand   %xmm8,%xmm4
pcmpeqd %xmm12,%xmm4
pcmpeqd %xmm12,%xmm2
packssdw %xmm4,%xmm2
packsswb %xmm2,%xmm2
movdqa 0xdd5(%rip),%xmm3
por    %xmm0,%xmm3
pand   %xmm2,%xmm0
pandn  %xmm3,%xmm2
por    %xmm0,%xmm2
movdqa %xmm7,%xmm0
pand   %xmm1,%xmm0
pand   %xmm8,%xmm7
pcmpeqd %xmm12,%xmm7
pcmpeqd %xmm12,%xmm0
packssdw %xmm7,%xmm0
packsswb %xmm0,%xmm0
movdqa 0xdae(%rip),%xmm3
por    %xmm2,%xmm3
pand   %xmm0,%xmm2
pandn  %xmm3,%xmm0
por    %xmm2,%xmm0
or     %r10d,%eax
or     %edx,%eax
movdqa %xmm6,%xmm2
pand   %xmm1,%xmm2
pand   %xmm8,%xmm6
pcmpeqd %xmm12,%xmm6
pcmpeqd %xmm12,%xmm2
packssdw %xmm6,%xmm2
packsswb %xmm2,%xmm2
movdqa 0xd82(%rip),%xmm3
por    %xmm0,%xmm3
pand   %xmm2,%xmm0
pandn  %xmm3,%xmm2
por    %xmm0,%xmm2
movdqa %xmm11,%xmm4
pand   %xmm1,%xmm4
pand   %xmm8,%xmm11
pcmpeqd %xmm12,%xmm11
pcmpeqd %xmm12,%xmm4
packssdw %xmm11,%xmm4
packsswb %xmm4,%xmm4
movdqa 0xd59(%rip),%xmm0
por    %xmm2,%xmm0
pand   %xmm4,%xmm2
pandn  %xmm0,%xmm4
por    %xmm2,%xmm4
or     %r9d,%ecx
or     %r8d,%ecx
or     %eax,%ecx
movd   %ecx,%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm0
pand   0xd3c(%rip),%xmm0
pcmpeqb %xmm12,%xmm0
pand   %xmm9,%xmm1
pand   %xmm8,%xmm9
pcmpeqd %xmm12,%xmm9
pcmpeqd %xmm12,%xmm1
packssdw %xmm9,%xmm1
packsswb %xmm1,%xmm1
movdqa 0xd22(%rip),%xmm2
por    %xmm4,%xmm2
pand   %xmm1,%xmm4
pandn  %xmm2,%xmm1
por    %xmm4,%xmm1
pand   %xmm0,%xmm10
pandn  %xmm1,%xmm0
por    %xmm10,%xmm0
movdqa %xmm0,0x10(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x3(%rsp)
movzwl 0x14(%rsp),%eax
mov    %ax,0x7(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1030 <drv_CW_send@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.drv_CW12232_defchar.cmd = [10 x i8] c"\FENn123456\FD"
define void @drv_CW12232_defchar(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = bitcast [10 x i8]* %7 to i8*
%9 = load i32, i32* %3
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 2
store i8 %10, i8* %11
store i32 0, i32* %5
br label %12
12: ; preds = %51, %2
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %54
15: ; preds = %12
%16 = load i32, i32* %5
%17 = add nsw i32 3, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 %18
store i8 0, i8* %19
store i32 0, i32* %6
br label %20
20: ; preds = %47, %15
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 8
br i1 %22, label %23, label %50
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i32, i32* %5
%31 = sub nsw i32 5, %30
%32 = shl i32 1, %31
%33 = and i32 %29, %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %46
35: ; preds = %23
%36 = load i32, i32* %6
%37 = shl i32 1, %36
%38 = load i32, i32* %5
%39 = add nsw i32 3, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = or i32 %43, %37
%45 = trunc i32 %44 to i8
store i8 %45, i8* %41
br label %46
46: ; preds = %35, %23
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %20
50: ; preds = %20
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %12
54: ; preds = %12
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%56 = call i32 @drv_CW_send(i8* %55, i32 10)
ret void
}

LLVM IR (-O2):
@__const.drv_CW12232_defchar.cmd = [10 x i8] c"\FENn123456\FD"
define void @drv_CW12232_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
%5 = trunc i32 %0 to i8
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 %5, i8* %6
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 2
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %1, i64 3
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 4
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 5
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %1, i64 6
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 7
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = insertelement <8 x i32> poison, i32 %21, i64 0
%23 = shufflevector <8 x i32> %22, <8 x i32> poison, <8 x i32> zeroinitializer
%24 = zext i8 %18 to i32
%25 = insertelement <8 x i32> poison, i32 %24, i64 0
%26 = shufflevector <8 x i32> %25, <8 x i32> poison, <8 x i32> zeroinitializer
%27 = zext i8 %16 to i32
%28 = insertelement <8 x i32> poison, i32 %27, i64 0
%29 = shufflevector <8 x i32> %28, <8 x i32> poison, <8 x i32> zeroinitializer
%30 = zext i8 %14 to i32
%31 = insertelement <8 x i32> poison, i32 %30, i64 0
%32 = shufflevector <8 x i32> %31, <8 x i32> poison, <8 x i32> zeroinitializer
%33 = zext i8 %12 to i32
%34 = insertelement <8 x i32> poison, i32 %33, i64 0
%35 = shufflevector <8 x i32> %34, <8 x i32> poison, <8 x i32> zeroinitializer
%36 = zext i8 %10 to i32
%37 = insertelement <8 x i32> poison, i32 %36, i64 0
%38 = shufflevector <8 x i32> %37, <8 x i32> poison, <8 x i32> zeroinitializer
%39 = zext i8 %8 to i32
%40 = insertelement <8 x i32> poison, i32 %39, i64 0
%41 = shufflevector <8 x i32> %40, <8 x i32> poison, <8 x i32> zeroinitializer
%42 = load i8, i8* %1
%43 = zext i8 %42 to i32
%44 = insertelement <8 x i32> poison, i32 %43, i64 0
%45 = shufflevector <8 x i32> %44, <8 x i32> poison, <8 x i32> zeroinitializer
%46 = and <8 x i32> %45, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%47 = icmp ne <8 x i32> %46, zeroinitializer
%48 = zext <8 x i1> %47 to <8 x i8>
%49 = and <8 x i32> %41, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%50 = icmp eq <8 x i32> %49, zeroinitializer
%51 = or <8 x i8> %48, <i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2>
%52 = select <8 x i1> %50, <8 x i8> %48, <8 x i8> %51
%53 = and <8 x i32> %38, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%54 = icmp eq <8 x i32> %53, zeroinitializer
%55 = or <8 x i8> %52, <i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4>
%56 = select <8 x i1> %54, <8 x i8> %52, <8 x i8> %55
%57 = or i8 %8, %10
%58 = and <8 x i32> %35, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%59 = icmp eq <8 x i32> %58, zeroinitializer
%60 = or <8 x i8> %56, <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>
%61 = select <8 x i1> %59, <8 x i8> %56, <8 x i8> %60
%62 = or i8 %12, %57
%63 = and <8 x i32> %32, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%64 = icmp eq <8 x i32> %63, zeroinitializer
%65 = or <8 x i8> %61, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%66 = select <8 x i1> %64, <8 x i8> %61, <8 x i8> %65
%67 = or i8 %14, %62
%68 = and <8 x i32> %29, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%69 = icmp eq <8 x i32> %68, zeroinitializer
%70 = or <8 x i8> %66, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%71 = select <8 x i1> %69, <8 x i8> %66, <8 x i8> %70
%72 = or i8 %16, %67
%73 = and <8 x i32> %26, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%74 = icmp eq <8 x i32> %73, zeroinitializer
%75 = or <8 x i8> %71, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%76 = select <8 x i1> %74, <8 x i8> %71, <8 x i8> %75
%77 = or i8 %18, %72
%78 = or i8 %20, %77
%79 = insertelement <8 x i8> poison, i8 %78, i64 0
%80 = shufflevector <8 x i8> %79, <8 x i8> poison, <8 x i32> zeroinitializer
%81 = and <8 x i8> %80, <i8 32, i8 16, i8 8, i8 4, i8 2, i8 1, i8 poison, i8 poison>
%82 = icmp eq <8 x i8> %81, zeroinitializer
%83 = and <8 x i32> %23, <i32 32, i32 16, i32 8, i32 4, i32 2, i32 1, i32 poison, i32 poison>
%84 = icmp eq <8 x i32> %83, zeroinitializer
%85 = or <8 x i8> %76, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 poison, i8 poison>
%86 = select <8 x i1> %84, <8 x i8> %76, <8 x i8> %85
%87 = select <8 x i1> %82, <8 x i8> %48, <8 x i8> %86
%88 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%89 = extractelement <8 x i8> %87, i64 0
store i8 %89, i8* %88
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 4
%91 = extractelement <8 x i8> %87, i64 1
store i8 %91, i8* %90
%92 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
%93 = extractelement <8 x i8> %87, i64 2
store i8 %93, i8* %92
%94 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 6
%95 = extractelement <8 x i8> %87, i64 3
store i8 %95, i8* %94
%96 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 7
%97 = extractelement <8 x i8> %87, i64 4
store i8 %97, i8* %96
%98 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
%99 = extractelement <8 x i8> %87, i64 5
store i8 %99, i8* %98
%100 = call i32 @drv_CW_send(i8* %4, i32 10)
ret void
}