#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 O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dehexify(unsigned char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ manchester_encode(unsigned char *, unsigned char *, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ writeAm(int, int, int);
int main(int argc, char **argv) {
  int nsecsPerBit = 1013210;
  if (argc < 3) {
    fprintf(stderr, "usage, %s <hex string code> <rpitx rfa file>\n", argv[0]);
    return -1;
  }
  char *hexString = argv[1];
  char *outFile = argv[2];
  if (strlen(hexString) != 20) {
    fprintf(stderr, "hex string must be 20 digits (10 byte) long\n");
    return -1;
  }
  unsigned char decoded[10];
  dehexify(decoded, hexString, 10);
  unsigned char encoded[20];
  manchester_encode(encoded, decoded, 10);
  int fd = open(outFile, O_WRONLY | O_CREAT, 0644);
  writeAm(fd, 0, 5000000);
  writeAm(fd, 1, 5000000);
  writeAm(fd, 0, 5000000);
  for (int i = 0; i < 128; i++) {
    writeAm(fd, 0, nsecsPerBit);
    writeAm(fd, 65535, nsecsPerBit);
  }
  writeAm(fd, 0, 4 * nsecsPerBit);
  printf("Bit code: ");
  for (int i = 0; i < 160; i++) {
    int bit = encoded[i / 8] & (1 << (7 - (i % 8)));
    writeAm(fd, bit ? 65535 : 0, nsecsPerBit);
    printf("%d", bit ? 1 : 0);
  }
  printf("\n");
  writeAm(fd, 0, 8 * nsecsPerBit);
  for (int i = 0; i < 160; i++) {
    int bit = encoded[i / 8] & (1 << (7 - (i % 8)));
    writeAm(fd, bit ? 65535 : 0, nsecsPerBit);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf75da,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11d1 <main+0x51>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1427 <main+0x2a7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x14,%eax
je     121e <main+0x9e>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1427 <main+0x2a7>
lea    -0x32(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1080 <dehexify@plt>
lea    -0x50(%rbp),%rdi
lea    -0x32(%rbp),%rsi
mov    $0xa,%edx
call   1060 <manchester_encode@plt>
mov    -0x28(%rbp),%rdi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
mov    0x2da2(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   1090 <open@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   10a0 <writeAm@plt>
mov    -0x54(%rbp),%edi
mov    $0x1,%esi
mov    $0x4c4b40,%edx
call   10a0 <writeAm@plt>
mov    -0x54(%rbp),%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   10a0 <writeAm@plt>
movl   $0x0,-0x58(%rbp)
cmpl   $0x80,-0x58(%rbp)
jge    12d4 <main+0x154>
mov    -0x54(%rbp),%edi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   10a0 <writeAm@plt>
mov    -0x54(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    $0xffff,%esi
call   10a0 <writeAm@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    129c <main+0x11c>
mov    -0x54(%rbp),%edi
mov    -0x14(%rbp),%edx
shl    $0x2,%edx
xor    %esi,%esi
call   10a0 <writeAm@plt>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0xa0,-0x5c(%rbp)
jge    1385 <main+0x205>
mov    -0x5c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
movzbl -0x50(%rbp,%rax,1),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x5c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x6c(%rbp),%eax
mov    $0x7,%ecx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x60(%rbp),%ecx
xor    %esi,%esi
mov    $0xffff,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0x14(%rbp),%edx
call   10a0 <writeAm@plt>
mov    -0x60(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f9 <main+0x179>
lea    0xca0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%edi
mov    -0x14(%rbp),%edx
shl    $0x3,%edx
xor    %esi,%esi
call   10a0 <writeAm@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xa0,-0x64(%rbp)
jge    1418 <main+0x298>
mov    -0x64(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
movzbl -0x50(%rbp,%rax,1),%eax
mov    %eax,-0x70(%rbp)
mov    -0x64(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x70(%rbp),%eax
mov    $0x7,%ecx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x68(%rbp),%ecx
xor    %esi,%esi
mov    $0xffff,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0x14(%rbp),%edx
call   10a0 <writeAm@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    13aa <main+0x22a>
mov    -0x54(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x2,%edi
jg     11c5 <main+0x35>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1395 <main+0x205>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jne    136d <main+0x1dd>
lea    0x16(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1090 <dehexify@plt>
mov    %rsp,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1070 <manchester_encode@plt>
mov    0x2dbe(%rip),%rax
mov    0x2de7(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
mov    $0x1a4,%edx
call   10a0 <open@plt>
mov    %eax,%r12d
mov    %eax,%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   10b0 <writeAm@plt>
mov    %r12d,%edi
mov    $0x1,%esi
mov    $0x4c4b40,%edx
call   10b0 <writeAm@plt>
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x4c4b40,%edx
call   10b0 <writeAm@plt>
mov    $0x80,%ebx
nopl   0x0(%rax)
mov    %r12d,%edi
xor    %esi,%esi
mov    $0xf75da,%edx
call   10b0 <writeAm@plt>
mov    %r12d,%edi
mov    $0xffff,%esi
mov    $0xf75da,%edx
call   10b0 <writeAm@plt>
add    $0xffffffff,%ebx
jne    1260 <main+0xd0>
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x3dd768,%edx
call   10b0 <writeAm@plt>
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffff,%r15d
lea    0xdb6(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
shr    $0x3,%rax
movzbl (%rsp,%rax,1),%eax
mov    %ebx,%ecx
not    %cl
and    $0x7,%cl
mov    $0x1,%esi
shl    %cl,%esi
xor    %ebp,%ebp
and    %eax,%esi
setne  %bpl
cmovne %r15d,%esi
mov    %r12d,%edi
mov    $0xf75da,%edx
call   10b0 <writeAm@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    $0xa0,%ebx
jne    12c0 <main+0x130>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x7baed0,%edx
call   10b0 <writeAm@plt>
jmp    1348 <main+0x1b8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%edi
mov    $0xf75da,%edx
call   10b0 <writeAm@plt>
add    $0x1,%ebx
cmp    $0xa0,%ebx
je     138b <main+0x1fb>
mov    %ebx,%eax
shr    $0x3,%rax
movzbl (%rsp,%rax,1),%eax
mov    %ebx,%ecx
not    %cl
and    $0x7,%cl
movzbl %cl,%ecx
bt     %ecx,%eax
mov    $0x0,%esi
jae    1330 <main+0x1a0>
mov    $0xffff,%esi
jmp    1330 <main+0x1a0>
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
lea    0xcb1(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1395 <main+0x205>
mov    %r12d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"usage, %s <hex string code> <rpitx rfa file>\0A\00"
@.str.1 = [45 x i8] c"hex string must be 20 digits (10 byte) long\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [11 x i8] c"Bit code: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [10 x i8]
%10 = alloca [20 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1013210, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 -1, i32* %3
br label %139
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
store i8* %31, i8** %8
%32 = load i8*, i8** %7
%33 = call i32 @strlen(i8* %32)
%34 = icmp ne i32 %33, 20
br i1 %34, label %35, label %38
35: ; preds = %25
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %139
38: ; preds = %25
%39 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%40 = load i8*, i8** %7
%41 = call i32 @dehexify(i8* %39, i8* %40, i32 10)
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%44 = call i32 @manchester_encode(i8* %42, i8* %43, i32 10)
%45 = load i8*, i8** %8
%46 = load i32, i32* @O_WRONLY
%47 = load i32, i32* @O_CREAT
%48 = or i32 %46, %47
%49 = call i32 @open(i8* %45, i32 %48, i32 420)
store i32 %49, i32* %11
%50 = load i32, i32* %11
%51 = call i32 @writeAm(i32 %50, i32 0, i32 5000000)
%52 = load i32, i32* %11
%53 = call i32 @writeAm(i32 %52, i32 1, i32 5000000)
%54 = load i32, i32* %11
%55 = call i32 @writeAm(i32 %54, i32 0, i32 5000000)
store i32 0, i32* %12
br label %56
56: ; preds = %66, %38
%57 = load i32, i32* %12
%58 = icmp slt i32 %57, 128
br i1 %58, label %59, label %69
59: ; preds = %56
%60 = load i32, i32* %11
%61 = load i32, i32* %6
%62 = call i32 @writeAm(i32 %60, i32 0, i32 %61)
%63 = load i32, i32* %11
%64 = load i32, i32* %6
%65 = call i32 @writeAm(i32 %63, i32 65535, i32 %64)
br label %66
66: ; preds = %59
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %56
69: ; preds = %56
%70 = load i32, i32* %11
%71 = load i32, i32* %6
%72 = mul nsw i32 4, %71
%73 = call i32 @writeAm(i32 %70, i32 0, i32 %72)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %13
br label %75
75: ; preds = %102, %69
%76 = load i32, i32* %13
%77 = icmp slt i32 %76, 160
br i1 %77, label %78, label %105
78: ; preds = %75
%79 = load i32, i32* %13
%80 = sdiv i32 %79, 8
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = load i32, i32* %13
%86 = srem i32 %85, 8
%87 = sub nsw i32 7, %86
%88 = shl i32 1, %87
%89 = and i32 %84, %88
store i32 %89, i32* %14
%90 = load i32, i32* %11
%91 = load i32, i32* %14
%92 = icmp ne i32 %91, 0
%93 = zext i1 %92 to i64
%94 = select i1 %92, i32 65535, i32 0
%95 = load i32, i32* %6
%96 = call i32 @writeAm(i32 %90, i32 %94, i32 %95)
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
%99 = zext i1 %98 to i64
%100 = select i1 %98, i32 1, i32 0
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %100)
br label %102
102: ; preds = %78
%103 = load i32, i32* %13
%104 = add nsw i32 %103, 1
store i32 %104, i32* %13
br label %75
105: ; preds = %75
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%107 = load i32, i32* %11
%108 = load i32, i32* %6
%109 = mul nsw i32 8, %108
%110 = call i32 @writeAm(i32 %107, i32 0, i32 %109)
store i32 0, i32* %15
br label %111
111: ; preds = %133, %105
%112 = load i32, i32* %15
%113 = icmp slt i32 %112, 160
br i1 %113, label %114, label %136
114: ; preds = %111
%115 = load i32, i32* %15
%116 = sdiv i32 %115, 8
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %117
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = load i32, i32* %15
%122 = srem i32 %121, 8
%123 = sub nsw i32 7, %122
%124 = shl i32 1, %123
%125 = and i32 %120, %124
store i32 %125, i32* %16
%126 = load i32, i32* %11
%127 = load i32, i32* %16
%128 = icmp ne i32 %127, 0
%129 = zext i1 %128 to i64
%130 = select i1 %128, i32 65535, i32 0
%131 = load i32, i32* %6
%132 = call i32 @writeAm(i32 %126, i32 %130, i32 %131)
br label %133
133: ; preds = %114
%134 = load i32, i32* %15
%135 = add nsw i32 %134, 1
store i32 %135, i32* %15
br label %111
136: ; preds = %111
%137 = load i32, i32* %11
%138 = call i32 @close(i32 %137)
store i32 0, i32* %3
br label %139
139: ; preds = %136, %35, %19
%140 = load i32, i32* %3
ret i32 %140
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"usage, %s <hex string code> <rpitx rfa file>\0A\00"
@.str.1 = [45 x i8] c"hex string must be 20 digits (10 byte) long\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [11 x i8] c"Bit code: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [20 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %81
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %12)
%16 = icmp eq i32 %15, 20
br i1 %16, label %20, label %17
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %81
20: ; preds = %10
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%22 = call i32 @dehexify(i8* %21, i8* %12, i32 10)
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%24 = call i32 @manchester_encode(i8* %23, i8* %21, i32 10)
%25 = load i32, i32* @O_WRONLY
%26 = load i32, i32* @O_CREAT
%27 = or i32 %26, %25
%28 = call i32 @open(i8* %14, i32 %27, i32 420)
%29 = call i32 @writeAm(i32 %28, i32 0, i32 5000000)
%30 = call i32 @writeAm(i32 %28, i32 1, i32 5000000)
%31 = call i32 @writeAm(i32 %28, i32 0, i32 5000000)
br label %35
32: ; preds = %35
%33 = call i32 @writeAm(i32 %28, i32 0, i32 4052840)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %44
35: ; preds = %20, %35
%36 = phi i32 [ 0, %20 ], [ %39, %35 ]
%37 = call i32 @writeAm(i32 %28, i32 0, i32 1013210)
%38 = call i32 @writeAm(i32 %28, i32 65535, i32 1013210)
%39 = add nuw nsw i32 %36, 1
%40 = icmp eq i32 %39, 128
br i1 %40, label %32, label %35
41: ; preds = %44
%42 = call i32 @putchar(i32 10)
%43 = call i32 @writeAm(i32 %28, i32 0, i32 8105680)
br label %65
44: ; preds = %32, %44
%45 = phi i32 [ 0, %32 ], [ %61, %44 ]
%46 = lshr i32 %45, 3
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = and i32 %45, 7
%52 = xor i32 %51, 7
%53 = shl nuw i32 1, %52
%54 = and i32 %53, %50
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i32 0, i32 65535
%57 = call i32 @writeAm(i32 %28, i32 %56, i32 1013210)
%58 = xor i1 %55, true
%59 = zext i1 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = add nuw nsw i32 %45, 1
%62 = icmp eq i32 %61, 160
br i1 %62, label %41, label %44
63: ; preds = %65
%64 = call i32 @close(i32 %28)
br label %81
65: ; preds = %41, %65
%66 = phi i32 [ 0, %41 ], [ %79, %65 ]
%67 = lshr i32 %66, 3
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = and i32 %66, 7
%73 = xor i32 %72, 7
%74 = shl nuw i32 1, %73
%75 = and i32 %74, %71
%76 = icmp eq i32 %75, 0
%77 = select i1 %76, i32 0, i32 65535
%78 = call i32 @writeAm(i32 %28, i32 %77, i32 1013210)
%79 = add nuw nsw i32 %66, 1
%80 = icmp eq i32 %79, 160
br i1 %80, label %63, label %65
81: ; preds = %17, %63, %6
%82 = phi i32 [ -1, %6 ], [ -1, %17 ], [ 0, %63 ]
ret i32 %82
}