#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ stdout;
char *read_char_data(FILE *in, char *result) {
  char strscrap[255];
  int scrap, length, i;
  memcpy(strscrap, "\0", 255);
  scrap = fgetc(in);
  if (scrap != 0x00) {
    fprintf(stdout, "Cannot find a char type when expecting one! %x\n",
            ftell(in));
    return "";
  }
  length = fgetc(in);
  if (length == 0) {
    result[0] = '\0';
    return result;
  }
  fread(strscrap, length, 1, in);
  for (i = 0; i < length; i++) {
    result[i] = strscrap[length - i - 1];
  }
  result[length] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<read_char_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0xff,%edx
call   1070 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     11d3 <read_char_data+0x83>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x130(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x130(%rbp),%edi
mov    %eax,%edx
lea    0xe44(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe67(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <read_char_data+0x13b>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x128(%rbp)
cmpl   $0x0,-0x128(%rbp)
jne    1203 <read_char_data+0xb3>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <read_char_data+0x13b>
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x0,-0x12c(%rbp)
mov    -0x12c(%rbp),%eax
cmp    -0x128(%rbp),%eax
jge    1274 <read_char_data+0x124>
mov    -0x128(%rbp),%eax
sub    -0x12c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x120(%rbp,%rax,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x12c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x12c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
jmp    1228 <read_char_data+0xd8>
mov    -0x18(%rbp),%rax
movslq -0x128(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_char_data>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe96(%rip),%rsi
mov    %rsp,%rdi
mov    $0xff,%edx
call   1070 <memcpy@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
test   %eax,%eax
je     11b0 <read_char_data+0x60>
mov    0x2e56(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1060 <ftell@plt>
lea    0xe67(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
call   1050 <fprintf@plt>
lea    0xe86(%rip),%r15
jmp    137c <read_char_data+0x22c>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
test   %eax,%eax
je     11ea <read_char_data+0x9a>
mov    %eax,%r14d
mov    %rsp,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %r14d,%r14d
jle    1374 <read_char_data+0x224>
mov    %r14d,%eax
cmp    $0x8,%r14d
jae    11f3 <read_char_data+0xa3>
xor    %ecx,%ecx
jmp    1317 <read_char_data+0x1c7>
movb   $0x0,(%r15)
jmp    137c <read_char_data+0x22c>
lea    -0x1(%rax),%rsi
lea    -0x1(%r14),%edx
mov    %edx,%edi
sub    %esi,%edi
xor    %ecx,%ecx
cmp    %edx,%edi
jg     1317 <read_char_data+0x1c7>
shr    $0x20,%rsi
jne    1317 <read_char_data+0x1c7>
cmp    $0x20,%r14d
jae    1220 <read_char_data+0xd0>
xor    %ecx,%ecx
jmp    12c5 <read_char_data+0x175>
mov    %eax,%ecx
and    $0xffffffe0,%ecx
xor    %esi,%esi
pxor   %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
movslq %edx,%rdx
movdqu -0x1f(%rsp,%rdx,1),%xmm1
movdqu -0xf(%rsp,%rdx,1),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqu %xmm2,(%r15,%rsi,1)
movdqu %xmm1,0x10(%r15,%rsi,1)
add    $0x20,%rsi
add    $0xffffffe0,%edx
cmp    %rsi,%rcx
jne    1230 <read_char_data+0xe0>
cmp    %rax,%rcx
je     1374 <read_char_data+0x224>
test   $0x18,%al
je     1317 <read_char_data+0x1c7>
mov    %rcx,%rdx
mov    %eax,%ecx
and    $0xfffffff8,%ecx
mov    %edx,%esi
not    %esi
add    %r14d,%esi
pxor   %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
movslq %esi,%rsi
movq   -0x7(%rsp,%rsi,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%r15,%rdx,1)
add    $0x8,%rdx
add    $0xfffffff8,%esi
cmp    %rdx,%rcx
jne    12e0 <read_char_data+0x190>
cmp    %rax,%rcx
je     1374 <read_char_data+0x224>
mov    %rcx,%rdx
not    %rdx
test   $0x1,%al
je     1336 <read_char_data+0x1e6>
mov    %ecx,%esi
not    %esi
add    %r14d,%esi
movslq %esi,%rsi
mov    (%rsp,%rsi,1),%bl
mov    %bl,(%r15,%rcx,1)
or     $0x1,%rcx
add    %rax,%rdx
je     1374 <read_char_data+0x224>
sub    %rcx,%rax
mov    %ecx,%edx
not    %edx
add    %r14d,%edx
add    %r15,%rcx
add    $0x1,%rcx
xor    %esi,%esi
xchg   %ax,%ax
movslq %edx,%rdx
movzbl (%rsp,%rdx,1),%ebx
mov    %bl,-0x1(%rcx,%rsi,1)
lea    -0x1(%rdx),%edi
movslq %edi,%rdi
movzbl (%rsp,%rdi,1),%ebx
mov    %bl,(%rcx,%rsi,1)
add    $0x2,%rsi
add    $0xfffffffe,%edx
cmp    %rsi,%rax
jne    1350 <read_char_data+0x200>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
@stdout = global i32 0
@.str.1 = [48 x i8] c"Cannot find a char type when expecting one! %x\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @read_char_data(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [255 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%11 = call i32 @memcpy(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 255)
%12 = load i32*, i32** %4
%13 = call i32 @fgetc(i32* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* @stdout
%18 = load i32*, i32** %4
%19 = call i32 @ftell(i32* %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %19)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %60
21: ; preds = %2
%22 = load i32*, i32** %4
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 0
store i8 0, i8* %28
%29 = load i8*, i8** %5
store i8* %29, i8** %3
br label %60
30: ; preds = %21
%31 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%32 = load i32, i32* %8
%33 = load i32*, i32** %4
%34 = call i32 @fread(i8* %31, i32 %32, i32 1, i32* %33)
store i32 0, i32* %9
br label %35
35: ; preds = %51, %30
%36 = load i32, i32* %9
%37 = load i32, i32* %8
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %54
39: ; preds = %35
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = sub nsw i32 %40, %41
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = load i8*, i8** %5
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 %46, i8* %50
br label %51
51: ; preds = %39
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %35
54: ; preds = %35
%55 = load i8*, i8** %5
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 0, i8* %58
%59 = load i8*, i8** %5
store i8* %59, i8** %3
br label %60
60: ; preds = %54, %26, %16
%61 = load i8*, i8** %3
ret i8* %61
}

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
@stdout = global i32 0
@.str.1 = [48 x i8] c"Cannot find a char type when expecting one! %x\0A\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @read_char_data(i32* nocapture %0, i8* writeonly %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = call i32 @memcpy(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 255)
%6 = call i32 @fgetc(i32* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = call i32 @ftell(i32* %0)
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %120
12: ; preds = %2
%13 = call i32 @fgetc(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i8 0, i8* %1
br label %120
16: ; preds = %12
%17 = call i32 @fread(i8* %4, i32 %13, i32 1, i32* %0)
%18 = icmp sgt i32 %13, 0
br i1 %18, label %19, label %117
19: ; preds = %16
%20 = zext i32 %13 to i64
%21 = icmp ult i32 %13, 8
br i1 %21, label %80, label %22
22: ; preds = %19
%23 = add nsw i64 %20, -1
%24 = add i32 %13, -1
%25 = trunc i64 %23 to i32
%26 = sub i32 %24, %25
%27 = icmp sgt i32 %26, %24
%28 = icmp ugt i64 %23, 4294967295
%29 = or i1 %27, %28
br i1 %29, label %80, label %30
30: ; preds = %22
%31 = icmp ult i32 %13, 32
br i1 %31, label %60, label %32
32: ; preds = %30
%33 = and i64 %20, 4294967264
br label %34
34: ; preds = %34, %32
%35 = phi i64 [ 0, %32 ], [ %53, %34 ]
%36 = trunc i64 %35 to i32
%37 = xor i32 %36, -1
%38 = add i32 %13, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 -15
%42 = bitcast i8* %41 to <16 x i8>*
%43 = load <16 x i8>, <16 x i8>* %42
%44 = shufflevector <16 x i8> %43, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%45 = getelementptr inbounds i8, i8* %40, i64 -31
%46 = bitcast i8* %45 to <16 x i8>*
%47 = load <16 x i8>, <16 x i8>* %46
%48 = shufflevector <16 x i8> %47, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%49 = getelementptr inbounds i8, i8* %1, i64 %35
%50 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> %44, <16 x i8>* %50
%51 = getelementptr inbounds i8, i8* %49, i64 16
%52 = bitcast i8* %51 to <16 x i8>*
store <16 x i8> %48, <16 x i8>* %52
%53 = add nuw i64 %35, 32
%54 = icmp eq i64 %53, %33
br i1 %54, label %55, label %34
55: ; preds = %34
%56 = icmp eq i64 %33, %20
br i1 %56, label %117, label %57
57: ; preds = %55
%58 = and i64 %20, 24
%59 = icmp eq i64 %58, 0
br i1 %59, label %80, label %60
60: ; preds = %30, %57
%61 = phi i64 [ %33, %57 ], [ 0, %30 ]
%62 = and i64 %20, 4294967288
br label %63
63: ; preds = %63, %60
%64 = phi i64 [ %61, %60 ], [ %76, %63 ]
%65 = trunc i64 %64 to i32
%66 = xor i32 %65, -1
%67 = add i32 %13, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %68
%70 = getelementptr inbounds i8, i8* %69, i64 -7
%71 = bitcast i8* %70 to <8 x i8>*
%72 = load <8 x i8>, <8 x i8>* %71
%73 = shufflevector <8 x i8> %72, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%74 = getelementptr inbounds i8, i8* %1, i64 %64
%75 = bitcast i8* %74 to <8 x i8>*
store <8 x i8> %73, <8 x i8>* %75
%76 = add nuw i64 %64, 8
%77 = icmp eq i64 %76, %62
br i1 %77, label %78, label %63
78: ; preds = %63
%79 = icmp eq i64 %62, %20
br i1 %79, label %117, label %80
80: ; preds = %22, %19, %57, %78
%81 = phi i64 [ 0, %19 ], [ 0, %22 ], [ %33, %57 ], [ %62, %78 ]
%82 = xor i64 %81, -1
%83 = and i64 %20, 1
%84 = icmp eq i64 %83, 0
br i1 %84, label %94, label %85
85: ; preds = %80
%86 = trunc i64 %81 to i32
%87 = xor i32 %86, -1
%88 = add i32 %13, %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = getelementptr inbounds i8, i8* %1, i64 %81
store i8 %91, i8* %92
%93 = or i64 %81, 1
br label %94
94: ; preds = %85, %80
%95 = phi i64 [ %81, %80 ], [ %93, %85 ]
%96 = sub nsw i64 0, %20
%97 = icmp eq i64 %82, %96
br i1 %97, label %117, label %98
98: ; preds = %94, %98
%99 = phi i64 [ %115, %98 ], [ %95, %94 ]
%100 = trunc i64 %99 to i32
%101 = xor i32 %100, -1
%102 = add i32 %13, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %103
%105 = load i8, i8* %104
%106 = getelementptr inbounds i8, i8* %1, i64 %99
store i8 %105, i8* %106
%107 = add nuw nsw i64 %99, 1
%108 = trunc i64 %107 to i32
%109 = xor i32 %108, -1
%110 = add i32 %13, %109
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %111
%113 = load i8, i8* %112
%114 = getelementptr inbounds i8, i8* %1, i64 %107
store i8 %113, i8* %114
%115 = add nuw nsw i64 %99, 2
%116 = icmp eq i64 %115, %20
br i1 %116, label %117, label %98
117: ; preds = %94, %98, %55, %78, %16
%118 = sext i32 %13 to i64
%119 = getelementptr inbounds i8, i8* %1, i64 %118
store i8 0, i8* %119
br label %120
120: ; preds = %117, %15, %8
%121 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %8 ], [ %1, %15 ], [ %1, %117 ]
ret i8* %121
}