#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*/ time_t;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int in2hex(char *);
int in4hex(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int swap(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int ac, char *av[]) {
  int nb, add, type, i;
  int first = 1;
  time_t temps;
  FILE *fptr;
  char buf[256];
  if (ac != 3) {
    fprintf(stderr, "format : mcs2h 1200|9600 filename\n");
    return 1;
  }
  fptr = fopen(av[2], "r");
  if (fptr == NULL) {
    fprintf(stderr, "file %s not found\n", av[2]);
    return 1;
  }
  time(&temps);
  printf("/*\n"
         " *\n"
         " * File %s converted to h format by mcs2h\n"
         " *\n"
         " * (C) F6FBB 1998\n"
         " *\n"
         " * %s"
         " *\n"
         " */\n\n",
         av[2], ctime(&temps));
  printf("static unsigned char bits_%s[]= {\n", av[1]);
  while (fgets(buf, sizeof(buf), fptr)) {
    nb = in2hex(buf + 1);
    add = in4hex(buf + 3);
    type = in2hex(buf + 7);
    if (type != 0)
      continue;
    if (first)
      first = 0;
    else
      printf(",\n");
    for (i = 0; i < nb; i++) {
      printf("0x%02x%s", swap(in2hex(buf + 9 + i * 2)),
             (i < (nb - 1)) ? "," : "");
    }
  }
  printf(" };\n");
  fclose(fptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ed <main+0x4d>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a8 <main+0x208>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe27(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    123b <main+0x9b>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a8 <main+0x208>
lea    -0x28(%rbp),%rdi
call   1090 <time@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x138(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <ctime@plt>
mov    -0x138(%rbp),%rsi
mov    %rax,%rdx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     138a <main+0x1ea>
lea    -0x130(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <in2hex@plt>
mov    %eax,-0x14(%rbp)
lea    -0x130(%rbp),%rdi
add    $0x3,%rdi
call   1030 <in4hex@plt>
mov    %eax,-0x18(%rbp)
lea    -0x130(%rbp),%rdi
add    $0x7,%rdi
call   10a0 <in2hex@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12f1 <main+0x151>
jmp    128a <main+0xea>
cmpl   $0x0,-0x24(%rbp)
je     1307 <main+0x167>
movl   $0x0,-0x24(%rbp)
jmp    1315 <main+0x175>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1385 <main+0x1e5>
lea    -0x130(%rbp),%rdi
add    $0x9,%rdi
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
call   10a0 <in2hex@plt>
mov    %eax,%edi
call   10c0 <swap@plt>
mov    %eax,%esi
mov    -0x20(%rbp),%ecx
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
lea    0xd31(%rip),%rdx
lea    0xd5a(%rip),%rax
cmp    %edi,%ecx
cmovl  %rax,%rdx
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    131c <main+0x17c>
jmp    128a <main+0xea>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x3,%edi
jne    1316 <main+0x166>
mov    %rsi,%rbp
mov    0x10(%rsi),%rdi
lea    0xe4b(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1347 <main+0x197>
mov    %rax,%r13
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   10a0 <time@plt>
mov    0x10(%rbp),%r15
mov    %r14,%rdi
call   1060 <ctime@plt>
lea    0xe2f(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x11(%rsp),%r14
lea    0x13(%rsp),%r15
lea    0x17(%rsp),%rbx
lea    0x19(%rsp),%r12
xor    %eax,%eax
mov    %rax,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     132f <main+0x17f>
mov    %r14,%rdi
call   10b0 <in2hex@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <in4hex@plt>
mov    %rbx,%rdi
call   10b0 <in2hex@plt>
test   %eax,%eax
jne    1250 <main+0xa0>
testb  $0x1,(%rsp)
je     129b <main+0xeb>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%al
mov    %rax,(%rsp)
test   %ebp,%ebp
jle    1250 <main+0xa0>
lea    -0x1(%rbp),%r14d
mov    %ebp,%r15d
mov    %r12,%rbp
xor    %r12d,%r12d
lea    0xdf8(%rip),%rbx
nopl   0x0(%rax)
mov    %rbp,%rdi
call   10b0 <in2hex@plt>
mov    %eax,%edi
call   10d0 <swap@plt>
cmp    %r14,%r12
lea    0xdb4(%rip),%rdx
lea    0xdde(%rip),%rcx
cmovb  %rcx,%rdx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r12
add    $0x2,%rbp
cmp    %r12,%r15
jne    12c0 <main+0x110>
lea    0x11(%rsp),%r14
lea    0x13(%rsp),%r15
lea    0x17(%rsp),%rbx
lea    0x19(%rsp),%r12
jmp    1250 <main+0xa0>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
lea    0xcda(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1362 <main+0x1b2>
lea    0xd84(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1367 <main+0x1b7>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xcca(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"format : mcs2h 1200|9600 filename\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"file %s not found\0A\00"
@.str.3 = [86 x i8] c"/*\0A *\0A * File %s converted to h format by mcs2h\0A *\0A * (C) F6FBB 1998\0A *\0A * %s *\0A */\0A\0A\00"
@.str.4 = [35 x i8] c"static unsigned char bits_%s[]= {\0A\00"
@.str.5 = [3 x i8] c",\0A\00"
@.str.6 = [9 x i8] c"0x%02x%s\00"
@.str.7 = [2 x i8] c",\00"
@.str.8 = [1 x i8] zeroinitializer
@.str.9 = [5 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 i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %10
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %96
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %12
%24 = load i32*, i32** %12
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %96
32: ; preds = %19
%33 = call i32 @time(i32* %11)
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i8* @ctime(i32* %11)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), i8* %36, i8* %37)
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %91, %60, %32
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%45 = load i32*, i32** %12
%46 = call i64 @fgets(i8* %44, i32 256, i32* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %92
48: ; preds = %43
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = call i32 @in2hex(i8* %50)
store i32 %51, i32* %6
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%53 = getelementptr inbounds i8, i8* %52, i64 3
%54 = call i32 @in4hex(i8* %53)
store i32 %54, i32* %7
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%56 = getelementptr inbounds i8, i8* %55, i64 7
%57 = call i32 @in2hex(i8* %56)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %48
br label %43
61: ; preds = %48
%62 = load i32, i32* %10
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %61
store i32 0, i32* %10
br label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %67
67: ; preds = %65, %64
store i32 0, i32* %9
br label %68
68: ; preds = %88, %67
%69 = load i32, i32* %9
%70 = load i32, i32* %6
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %91
72: ; preds = %68
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%74 = getelementptr inbounds i8, i8* %73, i64 9
%75 = load i32, i32* %9
%76 = mul nsw i32 %75, 2
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %74, i64 %77
%79 = call i32 @in2hex(i8* %78)
%80 = call i32 @swap(i32 %79)
%81 = load i32, i32* %9
%82 = load i32, i32* %6
%83 = sub nsw i32 %82, 1
%84 = icmp slt i32 %81, %83
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %80, i8* %86)
br label %88
88: ; preds = %72
%89 = load i32, i32* %9
%90 = add nsw i32 %89, 1
store i32 %90, i32* %9
br label %68
91: ; preds = %68
br label %43
92: ; preds = %43
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%94 = load i32*, i32** %12
%95 = call i32 @fclose(i32* %94)
store i32 0, i32* %3
br label %96
96: ; preds = %92, %26, %16
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"format : mcs2h 1200|9600 filename\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"file %s not found\0A\00"
@.str.3 = [86 x i8] c"/*\0A *\0A * File %s converted to h format by mcs2h\0A *\0A * (C) F6FBB 1998\0A *\0A * %s *\0A */\0A\0A\00"
@.str.4 = [35 x i8] c"static unsigned char bits_%s[]= {\0A\00"
@.str.6 = [9 x i8] c"0x%02x%s\00"
@.str.8 = [1 x i8] zeroinitializer
@str = [4 x i8] c" };\00"
@str.10 = [2 x i8] c",\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %66
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %66
20: ; preds = %11
%21 = call i32 @time(i32* %3)
%22 = load i8*, i8** %12
%23 = call i8* @ctime(i32* %3)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 1
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 3
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 7
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 9
br label %32
32: ; preds = %47, %20
%33 = phi i1 [ false, %20 ], [ true, %47 ]
br label %34
34: ; preds = %32, %37
%35 = call i64 @fgets(i8* %6, i32 256, i32* %14)
%36 = icmp eq i64 %35, 0
br i1 %36, label %63, label %37
37: ; preds = %34
%38 = call i32 @in2hex(i8* %28)
%39 = call i32 @in4hex(i8* %29)
%40 = call i32 @in2hex(i8* %30)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %34
42: ; preds = %37
br i1 %33, label %43, label %45
43: ; preds = %42
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
br label %45
45: ; preds = %42, %43
%46 = icmp sgt i32 %38, 0
br i1 %46, label %48, label %47
47: ; preds = %52, %45
br label %32
48: ; preds = %45
%49 = add nsw i32 %38, -1
%50 = zext i32 %49 to i64
%51 = zext i32 %38 to i64
br label %52
52: ; preds = %48, %52
%53 = phi i64 [ 0, %48 ], [ %61, %52 ]
%54 = shl nuw nsw i64 %53, 1
%55 = getelementptr inbounds i8, i8* %31, i64 %54
%56 = call i32 @in2hex(i8* %55)
%57 = call i32 @swap(i32 %56)
%58 = icmp ult i64 %53, %50
%59 = select i1 %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.8, i64 0, i64 0)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %57, i8* %59)
%61 = add nuw nsw i64 %53, 1
%62 = icmp eq i64 %61, %51
br i1 %62, label %47, label %52
63: ; preds = %34
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%65 = call i32 @fclose(i32* %14)
br label %66
66: ; preds = %63, %16, %8
%67 = phi i32 [ 1, %8 ], [ 1, %16 ], [ 0, %63 ]
ret i32 %67
}