#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*/ expectCHKSUM(int);
int /*<<< orphan*/ expectETX(int);
int /*<<< orphan*/ expectPacketType(int, int);
int /*<<< orphan*/ expectSTX(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sendETX(int);
int /*<<< orphan*/ sendSTX(int);
int /*<<< orphan*/ sendchecksum(int);
int /*<<< orphan*/ senddata(int, unsigned int);
void writeflash(int fd, unsigned int *membuffer, int startaddress, int words) {
  int i;
  if (words < 4) {
    printf("[less than eight bytes for flash op, filling up with 0xFF]\n");
    for (i = words; i < 4; i++)
      membuffer[i] = 0xFFFF;
    words = 4;
  }
  if (words % 4 != 0) {
    printf("[not multiple of 8, filling memory with 0xFF]\n");
    for (i = words; i < words - (words % 4) + 4; i++)
      membuffer[i] = 0xFFFF;
    words = words - (words % 4) + 4;
  }
  printf("SENDing: Write Flash: ");
  sendSTX(fd);
  sendSTX(fd);
  senddata(fd, 0x02);
  senddata(fd, words / 4);
  senddata(fd, startaddress & 0x0000FF);
  senddata(fd, (startaddress >> 8) & 0x0000FF);
  senddata(fd, (startaddress >> 16) & 0x0000FF);
  for (i = 0; i < words; i++) {
    senddata(fd, membuffer[i] & 0x0FF);
    senddata(fd, membuffer[i] >> 8);
  }
  sendchecksum(fd);
  sendETX(fd);
  printf("RECEIVING: ");
  expectSTX(fd);
  expectSTX(fd);
  expectPacketType(fd, 0x02);
  expectCHKSUM(fd);
  expectETX(fd);
  printf("[OK => Acknowledged Write Flash Program Memory]\n");
}


x86 assembly (clang, -O0):
<writeflash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    11ef <writeflash+0x5f>
lea    0xe4a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11e8 <writeflash+0x58>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0xffff,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c1 <writeflash+0x31>
movl   $0x4,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1272 <writeflash+0xe2>
lea    0xe32(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x18(%rbp),%eax
mov    $0x4,%esi
cltd
idiv   %esi
mov    -0x20(%rbp),%eax
sub    %edx,%ecx
add    $0x4,%ecx
cmp    %ecx,%eax
jge    1256 <writeflash+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0xffff,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1215 <writeflash+0x85>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
sub    %edx,%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
lea    0xdf2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <sendSTX@plt>
mov    -0x4(%rbp),%edi
call   1050 <sendSTX@plt>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <senddata@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1040 <senddata@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
and    $0xff,%esi
call   1040 <senddata@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
sar    $0x8,%esi
and    $0xff,%esi
call   1040 <senddata@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
sar    $0x10,%esi
and    $0xff,%esi
call   1040 <senddata@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1339 <writeflash+0x1a9>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
and    $0xff,%esi
call   1040 <senddata@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
shr    $0x8,%esi
call   1040 <senddata@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f0 <writeflash+0x160>
mov    -0x4(%rbp),%edi
call   1030 <sendchecksum@plt>
mov    -0x4(%rbp),%edi
call   10a0 <sendETX@plt>
lea    0xd32(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
call   10b0 <expectSTX@plt>
mov    -0x4(%rbp),%edi
call   10b0 <expectSTX@plt>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1080 <expectPacketType@plt>
mov    -0x4(%rbp),%edi
call   1090 <expectCHKSUM@plt>
mov    -0x4(%rbp),%edi
call   1070 <expectETX@plt>
lea    0xd05(%rip),%rdi
call   1060 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeflash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%r12
mov    %edi,%r15d
cmp    $0x3,%ecx
jg     1204 <writeflash+0x64>
lea    0xed2(%rip),%rdi
call   1050 <puts@plt>
movslq %r14d,%rax
mov    $0x3,%ecx
sub    %r14d,%ecx
cmp    $0x7,%ecx
jb     1310 <writeflash+0x170>
add    $0x1,%rcx
mov    %rcx,%r8
and    $0xfffffffffffffff8,%r8
lea    -0x8(%r8),%rdx
mov    %rdx,%rdi
shr    $0x3,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0x18,%rdx
jae    126d <writeflash+0xcd>
xor    %edx,%edx
jmp    12c2 <writeflash+0x122>
test   $0x3,%r14b
je     13d4 <writeflash+0x234>
lea    0xe4e(%rip),%rdi
call   1050 <puts@plt>
lea    0x4(%r14),%r10d
and    $0xfffffffc,%r10d
cmp    %r14d,%r10d
jle    13d1 <writeflash+0x231>
mov    %r14d,%ecx
movslq %r10d,%rdx
mov    %rdx,%r9
sub    %rcx,%r9
cmp    $0x8,%r9
jb     13c0 <writeflash+0x220>
mov    %r9,%r8
and    $0xfffffffffffffff8,%r8
lea    -0x8(%r8),%rax
mov    %rax,%rdi
shr    $0x3,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0x18,%rax
jae    132c <writeflash+0x18c>
xor    %eax,%eax
jmp    1382 <writeflash+0x1e2>
and    $0xfffffffffffffffc,%rdi
lea    (%r12,%rax,4),%rbp
add    $0x70,%rbp
xor    %edx,%edx
movaps 0xd7e(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups %xmm0,-0x70(%rbp,%rdx,4)
movups %xmm0,-0x60(%rbp,%rdx,4)
movups %xmm0,-0x50(%rbp,%rdx,4)
movups %xmm0,-0x40(%rbp,%rdx,4)
movups %xmm0,-0x30(%rbp,%rdx,4)
movups %xmm0,-0x20(%rbp,%rdx,4)
movups %xmm0,-0x10(%rbp,%rdx,4)
movups %xmm0,0x0(%rbp,%rdx,4)
add    $0x20,%rdx
add    $0xfffffffffffffffc,%rdi
jne    1290 <writeflash+0xf0>
test   %rsi,%rsi
je     12f2 <writeflash+0x152>
add    %rax,%rdx
lea    (%r12,%rdx,4),%rdx
add    $0x10,%rdx
shl    $0x5,%rsi
xor    %edi,%edi
movaps 0xd21(%rip),%xmm0
nop
movups %xmm0,-0x10(%rdx,%rdi,1)
movups %xmm0,(%rdx,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rsi
jne    12e0 <writeflash+0x140>
mov    $0x4,%r14d
cmp    %r8,%rcx
je     13d4 <writeflash+0x234>
add    %r8,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0xffff,(%r12,%rax,4)
add    $0x1,%rax
cmp    $0x4,%eax
jne    1310 <writeflash+0x170>
mov    $0x4,%r14d
jmp    13d4 <writeflash+0x234>
and    $0xfffffffffffffffc,%rdi
lea    (%r12,%rcx,4),%rbp
add    $0x70,%rbp
xor    %eax,%eax
movaps 0xcbf(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x70(%rbp,%rax,4)
movups %xmm0,-0x60(%rbp,%rax,4)
movups %xmm0,-0x50(%rbp,%rax,4)
movups %xmm0,-0x40(%rbp,%rax,4)
movups %xmm0,-0x30(%rbp,%rax,4)
movups %xmm0,-0x20(%rbp,%rax,4)
movups %xmm0,-0x10(%rbp,%rax,4)
movups %xmm0,0x0(%rbp,%rax,4)
add    $0x20,%rax
add    $0xfffffffffffffffc,%rdi
jne    1350 <writeflash+0x1b0>
test   %rsi,%rsi
je     13b2 <writeflash+0x212>
add    %rcx,%rax
lea    (%r12,%rax,4),%rax
add    $0x10,%rax
shl    $0x5,%rsi
xor    %edi,%edi
movaps 0xc61(%rip),%xmm0
nop
movups %xmm0,-0x10(%rax,%rdi,1)
movups %xmm0,(%rax,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rsi
jne    13a0 <writeflash+0x200>
cmp    %r8,%r9
je     13d1 <writeflash+0x231>
add    %r8,%rcx
nopw   0x0(%rax,%rax,1)
movl   $0xffff,(%r12,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    13c0 <writeflash+0x220>
mov    %r10d,%r14d
lea    0xc35(%rip),%rdi
call   1070 <printf@plt>
mov    %r15d,%edi
call   1060 <sendSTX@plt>
mov    %r15d,%edi
call   1060 <sendSTX@plt>
mov    %r15d,%edi
mov    $0x2,%esi
call   1040 <senddata@plt>
lea    0x3(%r14),%esi
test   %r14d,%r14d
cmovns %r14d,%esi
sar    $0x2,%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
movzbl %bl,%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
movzbl %bh,%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
shr    $0x10,%ebx
movzbl %bl,%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
test   %r14d,%r14d
jle    1475 <writeflash+0x2d5>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,4),%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
mov    (%r12,%rbx,4),%esi
shr    $0x8,%esi
mov    %r15d,%edi
call   1040 <senddata@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1450 <writeflash+0x2b0>
mov    %r15d,%edi
call   1030 <sendchecksum@plt>
mov    %r15d,%edi
call   10b0 <sendETX@plt>
lea    0xb9b(%rip),%rdi
call   1070 <printf@plt>
mov    %r15d,%edi
call   10c0 <expectSTX@plt>
mov    %r15d,%edi
call   10c0 <expectSTX@plt>
mov    %r15d,%edi
mov    $0x2,%esi
call   1090 <expectPacketType@plt>
mov    %r15d,%edi
call   10a0 <expectCHKSUM@plt>
mov    %r15d,%edi
call   1080 <expectETX@plt>
lea    0xb6e(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [60 x i8] c"[less than eight bytes for flash op, filling up with 0xFF]\0A\00"
@.str.1 = [47 x i8] c"[not multiple of 8, filling memory with 0xFF]\0A\00"
@.str.2 = [23 x i8] c"SENDing: Write Flash: \00"
@.str.3 = [12 x i8] c"RECEIVING: \00"
@.str.4 = [49 x i8] c"[OK => Acknowledged Write Flash Program Memory]\0A\00"
define void @writeflash(i32 %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %27
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %8
store i32 %14, i32* %9
br label %15
15: ; preds = %23, %12
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32*, i32** %6
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 65535, i32* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %15
26: ; preds = %15
store i32 4, i32* %8
br label %27
27: ; preds = %26, %4
%28 = load i32, i32* %8
%29 = srem i32 %28, 4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %56
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* %8
store i32 %33, i32* %9
br label %34
34: ; preds = %47, %31
%35 = load i32, i32* %9
%36 = load i32, i32* %8
%37 = load i32, i32* %8
%38 = srem i32 %37, 4
%39 = sub nsw i32 %36, %38
%40 = add nsw i32 %39, 4
%41 = icmp slt i32 %35, %40
br i1 %41, label %42, label %50
42: ; preds = %34
%43 = load i32*, i32** %6
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 65535, i32* %46
br label %47
47: ; preds = %42
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %34
50: ; preds = %34
%51 = load i32, i32* %8
%52 = load i32, i32* %8
%53 = srem i32 %52, 4
%54 = sub nsw i32 %51, %53
%55 = add nsw i32 %54, 4
store i32 %55, i32* %8
br label %56
56: ; preds = %50, %27
%57 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* %5
%59 = call i32 @sendSTX(i32 %58)
%60 = load i32, i32* %5
%61 = call i32 @sendSTX(i32 %60)
%62 = load i32, i32* %5
%63 = call i32 @senddata(i32 %62, i32 2)
%64 = load i32, i32* %5
%65 = load i32, i32* %8
%66 = sdiv i32 %65, 4
%67 = call i32 @senddata(i32 %64, i32 %66)
%68 = load i32, i32* %5
%69 = load i32, i32* %7
%70 = and i32 %69, 255
%71 = call i32 @senddata(i32 %68, i32 %70)
%72 = load i32, i32* %5
%73 = load i32, i32* %7
%74 = ashr i32 %73, 8
%75 = and i32 %74, 255
%76 = call i32 @senddata(i32 %72, i32 %75)
%77 = load i32, i32* %5
%78 = load i32, i32* %7
%79 = ashr i32 %78, 16
%80 = and i32 %79, 255
%81 = call i32 @senddata(i32 %77, i32 %80)
store i32 0, i32* %9
br label %82
82: ; preds = %103, %56
%83 = load i32, i32* %9
%84 = load i32, i32* %8
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %106
86: ; preds = %82
%87 = load i32, i32* %5
%88 = load i32*, i32** %6
%89 = load i32, i32* %9
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
%92 = load i32, i32* %91
%93 = and i32 %92, 255
%94 = call i32 @senddata(i32 %87, i32 %93)
%95 = load i32, i32* %5
%96 = load i32*, i32** %6
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %96, i64 %98
%100 = load i32, i32* %99
%101 = lshr i32 %100, 8
%102 = call i32 @senddata(i32 %95, i32 %101)
br label %103
103: ; preds = %86
%104 = load i32, i32* %9
%105 = add nsw i32 %104, 1
store i32 %105, i32* %9
br label %82
106: ; preds = %82
%107 = load i32, i32* %5
%108 = call i32 @sendchecksum(i32 %107)
%109 = load i32, i32* %5
%110 = call i32 @sendETX(i32 %109)
%111 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%112 = load i32, i32* %5
%113 = call i32 @expectSTX(i32 %112)
%114 = load i32, i32* %5
%115 = call i32 @expectSTX(i32 %114)
%116 = load i32, i32* %5
%117 = call i32 @expectPacketType(i32 %116, i32 2)
%118 = load i32, i32* %5
%119 = call i32 @expectCHKSUM(i32 %118)
%120 = load i32, i32* %5
%121 = call i32 @expectETX(i32 %120)
%122 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [23 x i8] c"SENDing: Write Flash: \00"
@.str.3 = [12 x i8] c"RECEIVING: \00"
@str = [48 x i8] c"[OK => Acknowledged Write Flash Program Memory]\00"
@str.5 = [46 x i8] c"[not multiple of 8, filling memory with 0xFF]\00"
@str.6 = [59 x i8] c"[less than eight bytes for flash op, filling up with 0xFF]\00"
define void @writeflash(i32 %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %3, 4
br i1 %5, label %6, label %76
6: ; preds = %4
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.6, i64 0, i64 0))
%8 = sext i32 %3 to i64
%9 = sub i32 3, %3
%10 = zext i32 %9 to i64
%11 = add nuw nsw i64 %10, 1
%12 = icmp ult i32 %9, 7
br i1 %12, label %68, label %13
13: ; preds = %6
%14 = and i64 %11, 8589934584
%15 = add nsw i64 %14, %8
%16 = add nsw i64 %14, -8
%17 = lshr exact i64 %16, 3
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 3
%20 = icmp ult i64 %16, 24
br i1 %20, label %52, label %21
21: ; preds = %13
%22 = and i64 %18, 4611686018427387900
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %49, %23 ]
%25 = phi i64 [ 0, %21 ], [ %50, %23 ]
%26 = add i64 %24, %8
%27 = getelementptr inbounds i32, i32* %1, i64 %26
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %28
%29 = getelementptr inbounds i32, i32* %27, i64 4
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %30
%31 = or i64 %24, 8
%32 = add i64 %31, %8
%33 = getelementptr inbounds i32, i32* %1, i64 %32
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %33, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %36
%37 = or i64 %24, 16
%38 = add i64 %37, %8
%39 = getelementptr inbounds i32, i32* %1, i64 %38
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %40
%41 = getelementptr inbounds i32, i32* %39, i64 4
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %42
%43 = or i64 %24, 24
%44 = add i64 %43, %8
%45 = getelementptr inbounds i32, i32* %1, i64 %44
%46 = bitcast i32* %45 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %46
%47 = getelementptr inbounds i32, i32* %45, i64 4
%48 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %48
%49 = add nuw i64 %24, 32
%50 = add i64 %25, 4
%51 = icmp eq i64 %50, %22
br i1 %51, label %52, label %23
52: ; preds = %23, %13
%53 = phi i64 [ 0, %13 ], [ %49, %23 ]
%54 = icmp eq i64 %19, 0
br i1 %54, label %66, label %55
55: ; preds = %52, %55
%56 = phi i64 [ %63, %55 ], [ %53, %52 ]
%57 = phi i64 [ %64, %55 ], [ 0, %52 ]
%58 = add i64 %56, %8
%59 = getelementptr inbounds i32, i32* %1, i64 %58
%60 = bitcast i32* %59 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %60
%61 = getelementptr inbounds i32, i32* %59, i64 4
%62 = bitcast i32* %61 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %62
%63 = add nuw i64 %56, 8
%64 = add i64 %57, 1
%65 = icmp eq i64 %64, %19
br i1 %65, label %66, label %55
66: ; preds = %55, %52
%67 = icmp eq i64 %11, %14
br i1 %67, label %151, label %68
68: ; preds = %6, %66
%69 = phi i64 [ %8, %6 ], [ %15, %66 ]
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ %73, %70 ], [ %69, %68 ]
%72 = getelementptr inbounds i32, i32* %1, i64 %71
store i32 65535, i32* %72
%73 = add nsw i64 %71, 1
%74 = trunc i64 %73 to i32
%75 = icmp eq i32 %74, 4
br i1 %75, label %151, label %70
76: ; preds = %4
%77 = and i32 %3, 3
%78 = icmp eq i32 %77, 0
br i1 %78, label %151, label %79
79: ; preds = %76
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.5, i64 0, i64 0))
%81 = add nuw i32 %3, 4
%82 = and i32 %81, -4
%83 = icmp sgt i32 %82, %3
br i1 %83, label %84, label %151
84: ; preds = %79
%85 = zext i32 %3 to i64
%86 = sext i32 %82 to i64
%87 = sub nsw i64 %86, %85
%88 = icmp ult i64 %87, 8
br i1 %88, label %144, label %89
89: ; preds = %84
%90 = and i64 %87, -8
%91 = add nsw i64 %90, %85
%92 = add nsw i64 %90, -8
%93 = lshr exact i64 %92, 3
%94 = add nuw nsw i64 %93, 1
%95 = and i64 %94, 3
%96 = icmp ult i64 %92, 24
br i1 %96, label %128, label %97
97: ; preds = %89
%98 = and i64 %94, 4611686018427387900
br label %99
99: ; preds = %99, %97
%100 = phi i64 [ 0, %97 ], [ %125, %99 ]
%101 = phi i64 [ 0, %97 ], [ %126, %99 ]
%102 = add i64 %100, %85
%103 = getelementptr inbounds i32, i32* %1, i64 %102
%104 = bitcast i32* %103 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %104
%105 = getelementptr inbounds i32, i32* %103, i64 4
%106 = bitcast i32* %105 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %106
%107 = or i64 %100, 8
%108 = add i64 %107, %85
%109 = getelementptr inbounds i32, i32* %1, i64 %108
%110 = bitcast i32* %109 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %110
%111 = getelementptr inbounds i32, i32* %109, i64 4
%112 = bitcast i32* %111 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %112
%113 = or i64 %100, 16
%114 = add i64 %113, %85
%115 = getelementptr inbounds i32, i32* %1, i64 %114
%116 = bitcast i32* %115 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %116
%117 = getelementptr inbounds i32, i32* %115, i64 4
%118 = bitcast i32* %117 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %118
%119 = or i64 %100, 24
%120 = add i64 %119, %85
%121 = getelementptr inbounds i32, i32* %1, i64 %120
%122 = bitcast i32* %121 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %122
%123 = getelementptr inbounds i32, i32* %121, i64 4
%124 = bitcast i32* %123 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %124
%125 = add nuw i64 %100, 32
%126 = add i64 %101, 4
%127 = icmp eq i64 %126, %98
br i1 %127, label %128, label %99
128: ; preds = %99, %89
%129 = phi i64 [ 0, %89 ], [ %125, %99 ]
%130 = icmp eq i64 %95, 0
br i1 %130, label %142, label %131
131: ; preds = %128, %131
%132 = phi i64 [ %139, %131 ], [ %129, %128 ]
%133 = phi i64 [ %140, %131 ], [ 0, %128 ]
%134 = add i64 %132, %85
%135 = getelementptr inbounds i32, i32* %1, i64 %134
%136 = bitcast i32* %135 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %136
%137 = getelementptr inbounds i32, i32* %135, i64 4
%138 = bitcast i32* %137 to <4 x i32>*
store <4 x i32> <i32 65535, i32 65535, i32 65535, i32 65535>, <4 x i32>* %138
%139 = add nuw i64 %132, 8
%140 = add i64 %133, 1
%141 = icmp eq i64 %140, %95
br i1 %141, label %142, label %131
142: ; preds = %131, %128
%143 = icmp eq i64 %87, %90
br i1 %143, label %151, label %144
144: ; preds = %84, %142
%145 = phi i64 [ %85, %84 ], [ %91, %142 ]
br label %146
146: ; preds = %144, %146
%147 = phi i64 [ %149, %146 ], [ %145, %144 ]
%148 = getelementptr inbounds i32, i32* %1, i64 %147
store i32 65535, i32* %148
%149 = add nuw nsw i64 %147, 1
%150 = icmp eq i64 %149, %86
br i1 %150, label %151, label %146
151: ; preds = %146, %70, %142, %66, %79, %76
%152 = phi i32 [ %3, %76 ], [ %82, %79 ], [ 4, %66 ], [ %82, %142 ], [ 4, %70 ], [ %82, %146 ]
%153 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%154 = tail call i32 @sendSTX(i32 %0)
%155 = tail call i32 @sendSTX(i32 %0)
%156 = tail call i32 @senddata(i32 %0, i32 2)
%157 = sdiv i32 %152, 4
%158 = tail call i32 @senddata(i32 %0, i32 %157)
%159 = and i32 %2, 255
%160 = tail call i32 @senddata(i32 %0, i32 %159)
%161 = lshr i32 %2, 8
%162 = and i32 %161, 255
%163 = tail call i32 @senddata(i32 %0, i32 %162)
%164 = lshr i32 %2, 16
%165 = and i32 %164, 255
%166 = tail call i32 @senddata(i32 %0, i32 %165)
%167 = icmp sgt i32 %152, 0
br i1 %167, label %168, label %181
168: ; preds = %151
%169 = zext i32 %152 to i64
br label %170
170: ; preds = %168, %170
%171 = phi i64 [ 0, %168 ], [ %179, %170 ]
%172 = getelementptr inbounds i32, i32* %1, i64 %171
%173 = load i32, i32* %172
%174 = and i32 %173, 255
%175 = tail call i32 @senddata(i32 %0, i32 %174)
%176 = load i32, i32* %172
%177 = lshr i32 %176, 8
%178 = tail call i32 @senddata(i32 %0, i32 %177)
%179 = add nuw nsw i64 %171, 1
%180 = icmp eq i64 %179, %169
br i1 %180, label %181, label %170
181: ; preds = %170, %151
%182 = tail call i32 @sendchecksum(i32 %0)
%183 = tail call i32 @sendETX(i32 %0)
%184 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%185 = tail call i32 @expectSTX(i32 %0)
%186 = tail call i32 @expectSTX(i32 %0)
%187 = tail call i32 @expectPacketType(i32 %0, i32 2)
%188 = tail call i32 @expectCHKSUM(i32 %0)
%189 = tail call i32 @expectETX(i32 %0)
%190 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
ret void
}