#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ read_cdata(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
char *strrchr(char *, char);
int /*<<< orphan*/ write_cdata(char *);
void main(int argc, char *argv[]) {
  FILE *in;
  char *prog, *opath;
  if ((prog = strrchr(argv[0], '/')) != 0)
    prog++;
  else
    prog = argv[0];
  opath = 0;
  in = stdin;
  argc--;
  argv++;
  while (argc > 0) {
    if (argv[0][0] == '-' && argv[0][1] == 'o') {
      argc--;
      argv++;
      opath = argv[0];
    } else {
      if (in != stdin)
        fclose(in);
      if ((in = fopen(argv[0], "rb")) == 0)
        fprintf(stderr, "%s: unable to open ctype file %s\n", prog, argv[0]);
      else {
        read_cdata(in);
        fclose(in);
        in = 0;
      }
    }
    argc--;
    argv++;
  }
  if (opath == 0)
    opath = ".";
  write_cdata(opath);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11af <main+0x3f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11ba <main+0x4a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    12d7 <main+0x167>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    123b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    123b <main+0xcb>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    12bd <main+0x14d>
mov    -0x18(%rbp),%rax
mov    0x2da2(%rip),%rcx
cmp    (%rcx),%rax
je     1258 <main+0xe8>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd9a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    129e <main+0x12e>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xd6f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    12b8 <main+0x148>
mov    -0x18(%rbp),%rdi
call   1080 <read_cdata@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x18(%rbp)
jmp    12bd <main+0x14d>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e5 <main+0x75>
cmpq   $0x0,-0x28(%rbp)
jne    12ed <main+0x17d>
lea    0xd3c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <write_cdata@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r13d
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbp,%r14
cmp    $0x2,%r13d
jl     1253 <main+0xe3>
mov    0x2e3b(%rip),%r12
mov    (%r12),%rdi
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe42(%rip),%r15
jmp    11db <main+0x6b>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <read_cdata@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
cmp    $0x1,%r13d
jle    1259 <main+0xe9>
mov    0x8(%rbx),%rax
cmpb   $0x2d,(%rax)
jne    1210 <main+0xa0>
cmpb   $0x6f,0x1(%rax)
jne    1210 <main+0xa0>
add    $0xfffffffe,%r13d
mov    0x10(%rbx),%rax
mov    %rax,(%rsp)
add    $0x10,%rbx
cmp    $0x1,%r13d
jg     11db <main+0x6b>
jmp    1259 <main+0xe9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x8,%rbx
cmp    (%r12),%rdi
je     1222 <main+0xb2>
call   1030 <fclose@plt>
mov    (%rbx),%rax
add    $0xffffffff,%r13d
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11c0 <main+0x50>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
lea    0xdba(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
jmp    11d3 <main+0x63>
xor    %eax,%eax
mov    %rax,(%rsp)
mov    (%rsp),%rax
test   %rax,%rax
lea    0xdbe(%rip),%rdi
cmovne %rax,%rdi
call   1070 <write_cdata@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"%s: unable to open ctype file %s\0A\00"
@.str.2 = [2 x i8] c".\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i8* @strrchr(i8* %10, i8 signext 47)
store i8* %11, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %6
br label %20
16: ; preds = %2
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
store i8* %19, i8** %6
br label %20
20: ; preds = %16, %13
store i8* null, i8** %7
%21 = load i32*, i32** @stdin
store i32* %21, i32** %5
%22 = load i32, i32* %3
%23 = add nsw i32 %22, -1
store i32 %23, i32* %3
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %4
br label %26
26: ; preds = %79, %20
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %84
29: ; preds = %26
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 45
br i1 %36, label %37, label %53
37: ; preds = %29
%38 = load i8**, i8*** %4
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 111
br i1 %44, label %45, label %53
45: ; preds = %37
%46 = load i32, i32* %3
%47 = add nsw i32 %46, -1
store i32 %47, i32* %3
%48 = load i8**, i8*** %4
%49 = getelementptr inbounds i8*, i8** %48, i32 1
store i8** %49, i8*** %4
%50 = load i8**, i8*** %4
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
store i8* %52, i8** %7
br label %79
53: ; preds = %37, %29
%54 = load i32*, i32** %5
%55 = load i32*, i32** @stdin
%56 = icmp ne i32* %54, %55
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i32*, i32** %5
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %57, %53
%61 = load i8**, i8*** %4
%62 = getelementptr inbounds i8*, i8** %61, i64 0
%63 = load i8*, i8** %62
%64 = call i32* @fopen(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %64, i32** %5
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %73
66: ; preds = %60
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %6
%69 = load i8**, i8*** %4
%70 = getelementptr inbounds i8*, i8** %69, i64 0
%71 = load i8*, i8** %70
%72 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %68, i8* %71)
br label %78
73: ; preds = %60
%74 = load i32*, i32** %5
%75 = call i32 @read_cdata(i32* %74)
%76 = load i32*, i32** %5
%77 = call i32 @fclose(i32* %76)
store i32* null, i32** %5
br label %78
78: ; preds = %73, %66
br label %79
79: ; preds = %78, %45
%80 = load i32, i32* %3
%81 = add nsw i32 %80, -1
store i32 %81, i32* %3
%82 = load i8**, i8*** %4
%83 = getelementptr inbounds i8*, i8** %82, i32 1
store i8** %83, i8*** %4
br label %26
84: ; preds = %26
%85 = load i8*, i8** %7
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %88
87: ; preds = %84
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %88
88: ; preds = %87, %84
%89 = load i8*, i8** %7
%90 = call i32 @write_cdata(i8* %89)
%91 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"%s: unable to open ctype file %s\0A\00"
@.str.2 = [2 x i8] c".\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %3, i8* %6
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %52
9: ; preds = %2
%10 = load i32*, i32** @stdin
br label %11
11: ; preds = %9, %46
%12 = phi i8* [ %50, %46 ], [ null, %9 ]
%13 = phi i32* [ %49, %46 ], [ %10, %9 ]
%14 = phi i8** [ %48, %46 ], [ %1, %9 ]
%15 = phi i32 [ %47, %46 ], [ %0, %9 ]
%16 = getelementptr inbounds i8*, i8** %14, i64 1
%17 = add nsw i32 %15, -1
%18 = load i8*, i8** %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 45
br i1 %20, label %21, label %29
21: ; preds = %11
%22 = getelementptr inbounds i8, i8* %18, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 111
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = add nsw i32 %15, -2
%27 = getelementptr inbounds i8*, i8** %14, i64 2
%28 = load i8*, i8** %27
br label %46
29: ; preds = %21, %11
%30 = load i32*, i32** @stdin
%31 = icmp eq i32* %13, %30
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = tail call i32 @fclose(i32* %13)
%34 = load i8*, i8** %16
br label %35
35: ; preds = %32, %29
%36 = phi i8* [ %34, %32 ], [ %18, %29 ]
%37 = tail call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %16
%42 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %41)
br label %46
43: ; preds = %35
%44 = tail call i32 @read_cdata(i32* %37)
%45 = tail call i32 @fclose(i32* %37)
br label %46
46: ; preds = %39, %43, %25
%47 = phi i32 [ %26, %25 ], [ %17, %39 ], [ %17, %43 ]
%48 = phi i8** [ %27, %25 ], [ %16, %39 ], [ %16, %43 ]
%49 = phi i32* [ %13, %25 ], [ null, %39 ], [ null, %43 ]
%50 = phi i8* [ %28, %25 ], [ %12, %39 ], [ %12, %43 ]
%51 = icmp sgt i32 %47, 1
br i1 %51, label %11, label %52
52: ; preds = %46, %2
%53 = phi i8* [ null, %2 ], [ %50, %46 ]
%54 = icmp eq i8* %53, null
%55 = select i1 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %53
%56 = tail call i32 @write_cdata(i8* %55)
%57 = tail call i32 @exit(i32 0)
unreachable
}