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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ get_basename(char const *);
int /*<<< orphan*/ handle_jis(int /*<<< orphan*/ **, char *, char const *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ qe_pstrcpy(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strip_extension(char *);
int main(int argc, char **argv) {
  int i;
  const char *filename;
  char name[256];
  FILE *f;
  printf("/* This file was generated automatically by jistoqe */\n");
  printf(
      "\n"
      "/*"
      "\n"
      " * JIS Tables for QEmacs"
      "\n"
      " * Copyright (c) 2002 Fabrice Bellard."
      "\n"
      " *"
      "\n"
      " * This library is free software; you can redistribute it and/or"
      "\n"
      " * modify it under the terms of the GNU Lesser General Public"
      "\n"
      " * License as published by the Free Software Foundation; either"
      "\n"
      " * version 2 of the License, or (at your option) any later version."
      "\n"
      " *"
      "\n"
      " * This library is distributed in the hope that it will be useful,"
      "\n"
      " * but WITHOUT ANY WARRANTY; without even the implied warranty of"
      "\n"
      " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU"
      "\n"
      " * Lesser General Public License for more details."
      "\n"
      " *"
      "\n"
      " * You should have received a copy of the GNU Lesser General Public"
      "\n"
      " * License along with this library; if not, write to the Free Software"
      "\n"
      " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 "
      " USA"
      "\n"
      " */"
      "\n"
      ""
      "\n");
  for (i = 1; i < argc; i++) {
    filename = argv[i];
    qe_pstrcpy(name, sizeof(name), get_basename(filename));
    strip_extension(name);
    f = fopen(filename, "r");
    if (!f) {
      perror(filename);
      exit(1);
    }
    handle_jis(&f, name, filename);
    fclose(f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1283 <main+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <get_basename@plt>
mov    -0x130(%rbp),%rdi
mov    %eax,%edx
mov    $0x100,%esi
call   1050 <qe_pstrcpy@plt>
lea    -0x120(%rbp),%rdi
call   1070 <strip_extension@plt>
mov    -0x20(%rbp),%rdi
lea    0x113e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    1252 <main+0xc2>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x120(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x128(%rbp),%rdi
call   1060 <handle_jis@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c8 <main+0x38>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebx
jl     123d <main+0xad>
mov    %ebx,%ebp
mov    $0x1,%r15d
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%r15,8),%rbx
mov    %rbx,%rdi
call   1080 <get_basename@plt>
mov    %r13,%rdi
mov    $0x100,%esi
mov    %eax,%edx
call   1050 <qe_pstrcpy@plt>
mov    %r13,%rdi
call   1070 <strip_extension@plt>
mov    %rbx,%rdi
lea    0xdf3(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1251 <main+0xc1>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <handle_jis@plt>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    11e0 <main+0x50>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [56 x i8] c"/* This file was generated automatically by jistoqe */\0A\00"
@.str.1 = [811 x i8] c"\0A/*\0A * JIS Tables for QEmacs\0A * Copyright (c) 2002 Fabrice Bellard.\0A *\0A * This library is free software; you can redistribute it and/or\0A * modify it under the terms of the GNU Lesser General Public\0A * License as published by the Free Software Foundation; either\0A * version 2 of the License, or (at your option) any later version.\0A *\0A * This library is distributed in the hope that it will be useful,\0A * but WITHOUT ANY WARRANTY; without even the implied warranty of\0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\0A * Lesser General Public License for more details.\0A *\0A * You should have received a copy of the GNU Lesser General Public\0A * License along with this library; if not, write to the Free Software\0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\0A */\0A\0A\00"
@.str.2 = [2 x i8] c"r\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 [256 x i8]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([811 x i8], [811 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %12
12: ; preds = %42, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %45
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
store i8* %21, i8** %7
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%23 = load i8*, i8** %7
%24 = call i32 @get_basename(i8* %23)
%25 = call i32 @qe_pstrcpy(i8* %22, i32 256, i32 %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%27 = call i32 @strip_extension(i8* %26)
%28 = load i8*, i8** %7
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %29, i32** %9
%30 = load i32*, i32** %9
%31 = icmp ne i32* %30, null
br i1 %31, label %36, label %32
32: ; preds = %16
%33 = load i8*, i8** %7
%34 = call i32 @perror(i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %16
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%38 = load i8*, i8** %7
%39 = call i32 @handle_jis(i32** %9, i8* %37, i8* %38)
%40 = load i32*, i32** %9
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %12
45: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [2 x i8] c"r\00"
@str = [55 x i8] c"/* This file was generated automatically by jistoqe */\00"
@str.3 = [810 x i8] c"\0A/*\0A * JIS Tables for QEmacs\0A * Copyright (c) 2002 Fabrice Bellard.\0A *\0A * This library is free software; you can redistribute it and/or\0A * modify it under the terms of the GNU Lesser General Public\0A * License as published by the Free Software Foundation; either\0A * version 2 of the License, or (at your option) any later version.\0A *\0A * This library is distributed in the hope that it will be useful,\0A * but WITHOUT ANY WARRANTY; without even the implied warranty of\0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\0A * Lesser General Public License for more details.\0A *\0A * You should have received a copy of the GNU Lesser General Public\0A * License along with this library; if not, write to the Free Software\0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\0A */\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca i32*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i32** %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([810 x i8], [810 x i8]* @str.3, i64 0, i64 0))
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %30
10: ; preds = %2
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %24
%13 = phi i64 [ 1, %10 ], [ %28, %24 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @get_basename(i8* %15)
%17 = call i32 @qe_pstrcpy(i8* %5, i32 256, i32 %16)
%18 = call i32 @strip_extension(i8* %5)
%19 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %4
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = call i32 @perror(i8* %15)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %12
%25 = call i32 @handle_jis(i32** %4, i8* %5, i8* %15)
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
%28 = add nuw nsw i64 %13, 1
%29 = icmp eq i64 %28, %11
br i1 %29, label %30, label %12
30: ; preds = %24, %2
ret i32 0
}