#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*/ convert(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                           char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int ii;
  char line[1024];
  char buff[1024];
  FILE *input;
  FILE *output;
  if (argc < 2) {
    usage(argv[0]);
  } else if (strcasecmp(argv[1], "--help") == 0 ||
             strcasecmp(argv[1], "-help") == 0) {
    usage(argv[0]);
  } else {
    for (ii = 1; ii < argc; ii++) {
      input = fopen(argv[ii], "r");
      if (input == NULL) {
        perror(argv[ii]);
        continue;
      }
      snprintf(line, 1024, "%s.g", argv[ii]);
      output = fopen(line, "w");
      if (output == NULL) {
        perror(line);
        fclose(input);
        continue;
      }
      convert(input, output, line, buff);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a4 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
jmp    12e9 <main+0x179>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11e0 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe30(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
jmp    12e4 <main+0x174>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12df <main+0x16f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf0(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1247 <main+0xd7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <perror@plt>
jmp    12d1 <main+0x161>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0x400,%esi
lea    0xda3(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x420(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x830(%rbp)
jne    12b0 <main+0x140>
lea    -0x420(%rbp),%rdi
call   1090 <perror@plt>
mov    -0x828(%rbp),%rdi
call   1050 <fclose@plt>
jmp    12d1 <main+0x161>
mov    -0x828(%rbp),%rdi
mov    -0x830(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    -0x820(%rbp),%rcx
call   1040 <convert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f8 <main+0x88>
jmp    12e4 <main+0x174>
jmp    12e9 <main+0x179>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     125c <main+0xec>
mov    %edi,%r14d
mov    0x8(%rbx),%rbp
lea    0xe65(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     125c <main+0xec>
lea    0xe4e(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     125c <main+0xec>
mov    %r14d,%r15d
mov    $0x2,%r13d
lea    0xe33(%rip),%r14
lea    0x400(%rsp),%r12
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <fopen@plt>
mov    -0x8(%rbx,%r13,8),%rcx
test   %rax,%rax
je     1240 <main+0xd0>
mov    %rax,%rbp
mov    %r12,%rdi
mov    $0x400,%esi
lea    0xe02(%rip),%rdx
call   1060 <snprintf@plt>
mov    %r12,%rdi
lea    0xdf8(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     124a <main+0xda>
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r12,%rdx
mov    %rsp,%rcx
call   1040 <convert@plt>
cmp    %r13,%r15
je     1264 <main+0xf4>
mov    (%rbx,%r13,8),%rbp
add    $0x1,%r13
jmp    11e0 <main+0x70>
mov    %rcx,%rdi
call   1090 <perror@plt>
jmp    1231 <main+0xc1>
mov    %r12,%rdi
call   1090 <perror@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
jmp    1231 <main+0xc1>
mov    (%rbx),%rdi
call   1070 <usage@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [6 x i8] c"-help\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"%s.g\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @usage(i8* %16)
br label %84
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcasecmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcasecmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %24, %18
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33)
br label %83
35: ; preds = %24
store i32 1, i32* %6
br label %36
36: ; preds = %79, %35
%37 = load i32, i32* %6
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %82
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %46, i32** %9
%47 = load i32*, i32** %9
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %56
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @perror(i8* %54)
br label %79
56: ; preds = %40
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%58 = load i8**, i8*** %5
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @snprintf(i8* %57, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %65, i32** %10
%66 = load i32*, i32** %10
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %73
68: ; preds = %56
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%70 = call i32 @perror(i8* %69)
%71 = load i32*, i32** %9
%72 = call i32 @fclose(i32* %71)
br label %79
73: ; preds = %56
%74 = load i32*, i32** %9
%75 = load i32*, i32** %10
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%78 = call i32 @convert(i32* %74, i32* %75, i8* %76, i8* %77)
br label %79
79: ; preds = %73, %68, %49
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %36
82: ; preds = %36
br label %83
83: ; preds = %82, %30
br label %84
84: ; preds = %83, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [6 x i8] c"-help\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"%s.g\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %42, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %42, label %13
13: ; preds = %8
%14 = tail call i64 @strcasecmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %42, label %16
16: ; preds = %13
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %39, %16
%19 = phi i8* [ %10, %16 ], [ %41, %39 ]
%20 = phi i64 [ 1, %16 ], [ %37, %39 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32* %22, null
%24 = load i8*, i8** %21
br i1 %23, label %25, label %27
25: ; preds = %18
%26 = call i32 @perror(i8* %24)
br label %36
27: ; preds = %18
%28 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%29 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = call i32 @perror(i8* %5)
%33 = call i32 @fclose(i32* %22)
br label %36
34: ; preds = %27
%35 = call i32 @convert(i32* %22, i32* %29, i8* %5, i8* %6)
br label %36
36: ; preds = %34, %31, %25
%37 = add nuw nsw i64 %20, 1
%38 = icmp eq i64 %37, %17
br i1 %38, label %45, label %39
39: ; preds = %36
%40 = getelementptr inbounds i8*, i8** %1, i64 %37
%41 = load i8*, i8** %40
br label %18
42: ; preds = %8, %13, %2
%43 = load i8*, i8** %1
%44 = tail call i32 @usage(i8* %43)
br label %45
45: ; preds = %36, %42
ret i32 0
}