#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 uint8_t;
typedef scalar_t__ uint32_t;
typedef int uint16_t;
struct can_frame {
  int can_id;
  int can_dlc;
  int *data;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_status(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int /*<<< orphan*/ set_blocksize(int, int, int);
int /*<<< orphan*/ set_checksum(int, int, int);
int /*<<< orphan*/ set_startaddress(int, int, scalar_t__);
int /*<<< orphan*/ start_programming(int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ verify(int, int);
int write(int, struct can_frame *, int);
void write_block(int s, uint8_t module_id, uint32_t offset, uint32_t blksz,
                 uint8_t *buf, uint32_t alternating_xor_flip) {
  struct can_frame frame;
  int i, j;
  uint8_t status;
  uint16_t csum;
  for (i = 0, csum = 0; i < 512; i++)
    csum = (csum + *(buf + i)) & 0xFFFFU;
  printf("writing non empty block at offset 0x%X with csum 0x%04X\n",
         (unsigned int)offset, (unsigned int)csum);
  set_startaddress(s, module_id, offset);
  status = get_status(s, module_id, NULL);
  if ((status & (1 << 0)) != ((1 << 0))) {
    fprintf(stderr, "flash1 - wrong status %02X!\n", status);
    exit(1);
  }
  set_blocksize(s, module_id, 512);
  status = get_status(s, module_id, NULL);
  if ((status & ((1 << 0) | (1 << 2))) != ((1 << 0) | (1 << 2))) {
    fprintf(stderr, "flash2 - wrong status %02X!\n", status);
    exit(1);
  }
  frame.can_id = 0x7E7;
  frame.can_dlc = 8;
  for (i = 0; i < 512; i += 8) {
    for (j = 0; j < 8; j++)
      frame.data[j] = *(buf + i + j);
    if ((i & 8) && (alternating_xor_flip)) {
      for (j = 0; j < 8; j++)
        frame.data[j] ^= 0xFF;
    }
    if (write(s, &frame, sizeof(struct can_frame)) !=
        sizeof(struct can_frame)) {
      perror("write");
      exit(1);
    }
  }
  status = get_status(s, module_id, NULL);
  if ((status & ((1 << 0) | (1 << 2))) != ((1 << 0) | (1 << 2))) {
    fprintf(stderr, "flash3 - wrong status %02X!\n", status);
    exit(1);
  }
  set_checksum(s, module_id, csum);
  status = get_status(s, module_id, NULL);
  if (status != ((1 << 6) | (1 << 0) | (1 << 2) | (1 << 1))) {
    fprintf(stderr, "flash4 - wrong status %02X!\n", status);
    fprintf(
        stderr,
        "Please check CAN netdevice tx-queue-len to avoid block data loss.\n");
    exit(1);
  }
  start_programming(s, module_id);
  status = get_status(s, module_id, NULL);
  if (status != ((1 << 6))) {
    fprintf(stderr, "flash5 - wrong status %02X!\n", status);
    exit(1);
  }
  verify(s, module_id);
  status = get_status(s, module_id, NULL);
  if (status != ((1 << 6) | (1 << 7))) {
    fprintf(stderr, "flash6 - wrong status %02X!\n", status);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<write_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x48(%rbp)
cmpl   $0x200,-0x3c(%rbp)
jge    120d <write_block+0x5d>
mov    -0x48(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
and    $0xffff,%eax
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11dc <write_block+0x2c>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x48(%rbp),%edx
lea    0xde3(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   10a0 <set_startaddress@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     1276 <write_block+0xc6>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x200,%edx
call   1050 <set_blocksize@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
and    $0x5,%eax
cmp    $0x5,%eax
je     12cb <write_block+0x11b>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x7e7,-0x38(%rbp)
movl   $0x8,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x200,-0x3c(%rbp)
jge    13c5 <write_block+0x215>
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jge    132d <write_block+0x17d>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12f4 <write_block+0x144>
mov    -0x3c(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     137f <write_block+0x1cf>
cmpq   $0x0,-0x28(%rbp)
je     137f <write_block+0x1cf>
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jge    137a <write_block+0x1ca>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
xor    $0xff,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    134e <write_block+0x19e>
jmp    137f <write_block+0x1cf>
mov    -0x4(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1040 <write@plt>
cltq
cmp    $0x10,%rax
je     13b2 <write_block+0x202>
lea    0xcd0(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    13b7 <write_block+0x207>
mov    -0x3c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x3c(%rbp)
jmp    12e0 <write_block+0x130>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
and    $0x5,%eax
cmp    $0x5,%eax
je     140a <write_block+0x25a>
mov    0x2bf3(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xc80(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x48(%rbp),%edx
call   10d0 <set_checksum@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x47,-0x44(%rbp)
je     146f <write_block+0x2bf>
mov    0x2ba5(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1080 <start_programming@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x40,-0x44(%rbp)
je     14ba <write_block+0x30a>
mov    0x2b43(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xc4d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <verify@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <get_status@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xc0,-0x44(%rbp)
je     1508 <write_block+0x358>
mov    0x2af5(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
lea    0xc1c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_block>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
xor    %edx,%edx
add    (%r8,%rax,4),%edx
add    0x4(%r8,%rax,4),%edx
add    0x8(%r8,%rax,4),%edx
add    0xc(%r8,%rax,4),%edx
movzwl %dx,%edx
add    $0x4,%rax
cmp    $0x200,%rax
jne    1170 <write_block+0x10>
lea    0xe67(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1070 <set_startaddress@plt>
mov    %ebp,%edi
mov    %r14d,%esi
xor    %edx,%edx
call   1030 <get_status@plt>
test   $0x1,%al
jne    11cf <write_block+0x6f>
mov    0x2e1c(%rip),%rcx
mov    (%rcx),%edi
lea    0xe6c(%rip),%rsi
jmp    11fa <write_block+0x9a>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x200,%edx
call   1040 <set_blocksize@plt>
mov    %ebp,%edi
mov    %r14d,%esi
xor    %edx,%edx
call   1030 <get_status@plt>
mov    0x2def(%rip),%rcx
mov    (%rcx),%edi
lea    0xe5c(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.can_frame = type { i32, i32, i32* }
@.str = [57 x i8] c"writing non empty block at offset 0x%X with csum 0x%04X\0A\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"flash1 - wrong status %02X!\0A\00"
@.str.2 = [29 x i8] c"flash2 - wrong status %02X!\0A\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [29 x i8] c"flash3 - wrong status %02X!\0A\00"
@.str.5 = [29 x i8] c"flash4 - wrong status %02X!\0A\00"
@.str.6 = [67 x i8] c"Please check CAN netdevice tx-queue-len to avoid block data loss.\0A\00"
@.str.7 = [29 x i8] c"flash5 - wrong status %02X!\0A\00"
@.str.8 = [29 x i8] c"flash6 - wrong status %02X!\0A\00"
define void @write_block(i32 %0, i32 %1, i64 %2, i64 %3, i32* %4, i64 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i64
%13 = alloca %struct.can_frame
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i32* %4, i32** %11
store i64 %5, i64* %12
store i32 0, i32* %14
store i32 0, i32* %17
br label %18
18: ; preds = %30, %6
%19 = load i32, i32* %14
%20 = icmp slt i32 %19, 512
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %17
%23 = load i32*, i32** %11
%24 = load i32, i32* %14
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %22, %27
%29 = and i32 %28, 65535
store i32 %29, i32* %17
br label %30
30: ; preds = %21
%31 = load i32, i32* %14
%32 = add nsw i32 %31, 1
store i32 %32, i32* %14
br label %18
33: ; preds = %18
%34 = load i64, i64* %9
%35 = trunc i64 %34 to i32
%36 = load i32, i32* %17
%37 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i64, i64* %9
%41 = call i32 @set_startaddress(i32 %38, i32 %39, i64 %40)
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = call i32 @get_status(i32 %42, i32 %43, i32* null)
store i32 %44, i32* %16
%45 = load i32, i32* %16
%46 = and i32 %45, 1
%47 = icmp ne i32 %46, 1
br i1 %47, label %48, label %53
48: ; preds = %33
%49 = load i32, i32* @stderr
%50 = load i32, i32* %16
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %33
%54 = load i32, i32* %7
%55 = load i32, i32* %8
%56 = call i32 @set_blocksize(i32 %54, i32 %55, i32 512)
%57 = load i32, i32* %7
%58 = load i32, i32* %8
%59 = call i32 @get_status(i32 %57, i32 %58, i32* null)
store i32 %59, i32* %16
%60 = load i32, i32* %16
%61 = and i32 %60, 5
%62 = icmp ne i32 %61, 5
br i1 %62, label %63, label %68
63: ; preds = %53
%64 = load i32, i32* @stderr
%65 = load i32, i32* %16
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %65)
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %53
%69 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %13, i32 0, i32 0
store i32 2023, i32* %69
%70 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %13, i32 0, i32 1
store i32 8, i32* %70
store i32 0, i32* %14
br label %71
71: ; preds = %127, %68
%72 = load i32, i32* %14
%73 = icmp slt i32 %72, 512
br i1 %73, label %74, label %130
74: ; preds = %71
store i32 0, i32* %15
br label %75
75: ; preds = %92, %74
%76 = load i32, i32* %15
%77 = icmp slt i32 %76, 8
br i1 %77, label %78, label %95
78: ; preds = %75
%79 = load i32*, i32** %11
%80 = load i32, i32* %14
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %79, i64 %81
%83 = load i32, i32* %15
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %82, i64 %84
%86 = load i32, i32* %85
%87 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %13, i32 0, i32 2
%88 = load i32*, i32** %87
%89 = load i32, i32* %15
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
store i32 %86, i32* %91
br label %92
92: ; preds = %78
%93 = load i32, i32* %15
%94 = add nsw i32 %93, 1
store i32 %94, i32* %15
br label %75
95: ; preds = %75
%96 = load i32, i32* %14
%97 = and i32 %96, 8
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %118
99: ; preds = %95
%100 = load i64, i64* %12
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %118
102: ; preds = %99
store i32 0, i32* %15
br label %103
103: ; preds = %114, %102
%104 = load i32, i32* %15
%105 = icmp slt i32 %104, 8
br i1 %105, label %106, label %117
106: ; preds = %103
%107 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %13, i32 0, i32 2
%108 = load i32*, i32** %107
%109 = load i32, i32* %15
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %108, i64 %110
%112 = load i32, i32* %111
%113 = xor i32 %112, 255
store i32 %113, i32* %111
br label %114
114: ; preds = %106
%115 = load i32, i32* %15
%116 = add nsw i32 %115, 1
store i32 %116, i32* %15
br label %103
117: ; preds = %103
br label %118
118: ; preds = %117, %99, %95
%119 = load i32, i32* %7
%120 = call i32 @write(i32 %119, %struct.can_frame* %13, i32 16)
%121 = sext i32 %120 to i64
%122 = icmp ne i64 %121, 16
br i1 %122, label %123, label %126
123: ; preds = %118
%124 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %118
br label %127
127: ; preds = %126
%128 = load i32, i32* %14
%129 = add nsw i32 %128, 8
store i32 %129, i32* %14
br label %71
130: ; preds = %71
%131 = load i32, i32* %7
%132 = load i32, i32* %8
%133 = call i32 @get_status(i32 %131, i32 %132, i32* null)
store i32 %133, i32* %16
%134 = load i32, i32* %16
%135 = and i32 %134, 5
%136 = icmp ne i32 %135, 5
br i1 %136, label %137, label %142
137: ; preds = %130
%138 = load i32, i32* @stderr
%139 = load i32, i32* %16
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %139)
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %130
%143 = load i32, i32* %7
%144 = load i32, i32* %8
%145 = load i32, i32* %17
%146 = call i32 @set_checksum(i32 %143, i32 %144, i32 %145)
%147 = load i32, i32* %7
%148 = load i32, i32* %8
%149 = call i32 @get_status(i32 %147, i32 %148, i32* null)
store i32 %149, i32* %16
%150 = load i32, i32* %16
%151 = icmp ne i32 %150, 71
br i1 %151, label %152, label %159
152: ; preds = %142
%153 = load i32, i32* @stderr
%154 = load i32, i32* %16
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %154)
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0))
%158 = call i32 @exit(i32 1)
unreachable
159: ; preds = %142
%160 = load i32, i32* %7
%161 = load i32, i32* %8
%162 = call i32 @start_programming(i32 %160, i32 %161)
%163 = load i32, i32* %7
%164 = load i32, i32* %8
%165 = call i32 @get_status(i32 %163, i32 %164, i32* null)
store i32 %165, i32* %16
%166 = load i32, i32* %16
%167 = icmp ne i32 %166, 64
br i1 %167, label %168, label %173
168: ; preds = %159
%169 = load i32, i32* @stderr
%170 = load i32, i32* %16
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %169, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %170)
%172 = call i32 @exit(i32 1)
unreachable
173: ; preds = %159
%174 = load i32, i32* %7
%175 = load i32, i32* %8
%176 = call i32 @verify(i32 %174, i32 %175)
%177 = load i32, i32* %7
%178 = load i32, i32* %8
%179 = call i32 @get_status(i32 %177, i32 %178, i32* null)
store i32 %179, i32* %16
%180 = load i32, i32* %16
%181 = icmp ne i32 %180, 192
br i1 %181, label %182, label %187
182: ; preds = %173
%183 = load i32, i32* @stderr
%184 = load i32, i32* %16
%185 = call i32 (i32, i8*, ...) @fprintf(i32 %183, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %184)
%186 = call i32 @exit(i32 1)
unreachable
187: ; preds = %173
ret void
}

LLVM IR (-O2):
@.str = [57 x i8] c"writing non empty block at offset 0x%X with csum 0x%04X\0A\00"
@stderr = global i32 0
@.str.1 = [29 x i8] c"flash1 - wrong status %02X!\0A\00"
@.str.2 = [29 x i8] c"flash2 - wrong status %02X!\0A\00"
define void @write_block(i32 %0, i32 %1, i64 %2, i64 %3, i32* nocapture %4, i64 %5) {
br label %7
7: ; preds = %7, %6
%8 = phi i64 [ 0, %6 ], [ %26, %7 ]
%9 = phi i32 [ 0, %6 ], [ %25, %7 ]
%10 = getelementptr inbounds i32, i32* %4, i64 %8
%11 = load i32, i32* %10
%12 = add nsw i32 %11, %9
%13 = or i64 %8, 1
%14 = getelementptr inbounds i32, i32* %4, i64 %13
%15 = load i32, i32* %14
%16 = add i32 %15, %12
%17 = or i64 %8, 2
%18 = getelementptr inbounds i32, i32* %4, i64 %17
%19 = load i32, i32* %18
%20 = add i32 %19, %16
%21 = or i64 %8, 3
%22 = getelementptr inbounds i32, i32* %4, i64 %21
%23 = load i32, i32* %22
%24 = add i32 %23, %20
%25 = and i32 %24, 65535
%26 = add nuw nsw i64 %8, 4
%27 = icmp eq i64 %26, 512
br i1 %27, label %28, label %7
28: ; preds = %7
%29 = trunc i64 %2 to i32
%30 = tail call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %25)
%31 = tail call i32 @set_startaddress(i32 %0, i32 %1, i64 %2)
%32 = tail call i32 @get_status(i32 %0, i32 %1, i32* null)
%33 = and i32 %32, 1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %28
%40 = tail call i32 @set_blocksize(i32 %0, i32 %1, i32 512)
%41 = tail call i32 @get_status(i32 %0, i32 %1, i32* null)
%42 = and i32 %41, 5
%43 = icmp ne i32 %42, 5
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%46 = tail call i32 @exit(i32 1)
unreachable
}