#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 /*<<< orphan*/ RemoveSpecialChars(char *, int);
int /*<<< orphan*/ WriteArrayBeginExpression(char *, char *, char *,
                                             int /*<<< orphan*/ *);
int /*<<< orphan*/ WriteArrayEndExpression(int /*<<< orphan*/ *);
int /*<<< orphan*/ WriteBitmapText(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ WriteCommentoutText(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ WriteElementEndExpression(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
void WriteCharArrayExpression(FILE *out, FILE *in, char *bmapName,
                              char *bmapSize) {
  int bmapSizeNum;
  WriteArrayBeginExpression("char", bmapName, bmapSize, out);
  int i = 1;
  char s[12];
  while (fgets(s, 12, in) != NULL) {
    RemoveSpecialChars(s, 12);
    if (strstr(s, "char") != NULL) {
      WriteCommentoutText(s, out);
    } else if (strlen(s) == 10) {
      WriteBitmapText(s, out);
      bmapSizeNum = (int)strtol(bmapSize, NULL, 10);
      WriteElementEndExpression(i, bmapSizeNum, out);
      i += 1;
    }
  }
  WriteArrayEndExpression(out);
  return;
}


x86 assembly (clang, -O0):
<WriteCharArrayExpression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe35(%rip),%rdi
call   10a0 <WriteArrayBeginExpression@plt>
movl   $0x1,-0x28(%rbp)
lea    -0x34(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1283 <WriteCharArrayExpression+0xe3>
lea    -0x34(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <RemoveSpecialChars@plt>
lea    -0x34(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     122d <WriteCharArrayExpression+0x8d>
lea    -0x34(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <WriteCommentoutText@plt>
jmp    127e <WriteCharArrayExpression+0xde>
lea    -0x34(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jne    1279 <WriteCharArrayExpression+0xd9>
lea    -0x34(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <WriteBitmapText@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1080 <WriteElementEndExpression@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    127e <WriteCharArrayExpression+0xde>
jmp    11d7 <WriteCharArrayExpression+0x37>
mov    -0x8(%rbp),%rdi
call   1040 <WriteArrayEndExpression@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteCharArrayExpression>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe42(%rip),%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %rbx,%rcx
call   10a0 <WriteArrayBeginExpression@plt>
lea    0xc(%rsp),%rdi
mov    $0xc,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1274 <WriteCharArrayExpression+0xd4>
mov    $0x1,%r12d
lea    0xc(%rsp),%rbp
lea    0xe07(%rip),%r13
jmp    121d <WriteCharArrayExpression+0x7d>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rsi
call   1070 <WriteCommentoutText@plt>
mov    %rbp,%rdi
mov    $0xc,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1274 <WriteCharArrayExpression+0xd4>
mov    %rbp,%rdi
mov    $0xc,%esi
call   10b0 <RemoveSpecialChars@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   10c0 <strstr@plt>
mov    %rbp,%rdi
test   %rax,%rax
jne    1200 <WriteCharArrayExpression+0x60>
call   1030 <strlen@plt>
cmp    $0xa,%eax
jne    1208 <WriteCharArrayExpression+0x68>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <WriteBitmapText@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %r12d,%edi
mov    %eax,%esi
mov    %rbx,%rdx
call   1080 <WriteElementEndExpression@plt>
add    $0x1,%r12d
jmp    1208 <WriteCharArrayExpression+0x68>
mov    %rbx,%rdi
call   1040 <WriteArrayEndExpression@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"char\00"
define void @WriteCharArrayExpression(i32* %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [12 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i32*, i32** %5
%15 = call i32 @WriteArrayBeginExpression(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i32* %14)
store i32 1, i32* %10
br label %16
16: ; preds = %49, %4
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i32* @fgets(i8* %17, i32 12, i32* %18)
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %50
21: ; preds = %16
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%23 = call i32 @RemoveSpecialChars(i8* %22, i32 12)
%24 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%25 = call i32* @strstr(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%29 = load i32*, i32** %5
%30 = call i32 @WriteCommentoutText(i8* %28, i32* %29)
br label %49
31: ; preds = %21
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %48
35: ; preds = %31
%36 = getelementptr inbounds [12 x i8], [12 x i8]* %11, i64 0, i64 0
%37 = load i32*, i32** %5
%38 = call i32 @WriteBitmapText(i8* %36, i32* %37)
%39 = load i8*, i8** %8
%40 = call i64 @strtol(i8* %39, i32* null, i32 10)
%41 = trunc i64 %40 to i32
store i32 %41, i32* %9
%42 = load i32, i32* %10
%43 = load i32, i32* %9
%44 = load i32*, i32** %5
%45 = call i32 @WriteElementEndExpression(i32 %42, i32 %43, i32* %44)
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %48
48: ; preds = %35, %31
br label %49
49: ; preds = %48, %27
br label %16
50: ; preds = %16
%51 = load i32*, i32** %5
%52 = call i32 @WriteArrayEndExpression(i32* %51)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"char\00"
define void @WriteCharArrayExpression(i32* %0, i32* nocapture %1, i8* %2, i8* %3) {
%5 = alloca [12 x i8]
%6 = tail call i32 @WriteArrayBeginExpression(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i32* %0)
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %5, i64 0, i64 0
%8 = call i32* @fgets(i8* %7, i32 12, i32* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %30, label %10
10: ; preds = %4, %26
%11 = phi i32 [ %27, %26 ], [ 1, %4 ]
%12 = call i32 @RemoveSpecialChars(i8* %7, i32 12)
%13 = call i32* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call i32 @WriteCommentoutText(i8* %7, i32* %0)
br label %26
17: ; preds = %10
%18 = call i32 @strlen(i8* %7)
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = call i32 @WriteBitmapText(i8* %7, i32* %0)
%22 = call i64 @strtol(i8* nocapture %3, i32* null, i32 10)
%23 = trunc i64 %22 to i32
%24 = call i32 @WriteElementEndExpression(i32 %11, i32 %23, i32* %0)
%25 = add nsw i32 %11, 1
br label %26
26: ; preds = %17, %20, %15
%27 = phi i32 [ %11, %15 ], [ %25, %20 ], [ %11, %17 ]
%28 = call i32* @fgets(i8* %7, i32 12, i32* %1)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %10
30: ; preds = %26, %4
%31 = call i32 @WriteArrayEndExpression(i32* %0)
ret void
}