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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ helptext(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strip(char *);
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int dos2unix = 0;
  int unix2dos = 0;
  int v_auto = 0;
  char *infile;
  char *outfile;
  FILE *ifptr;
  FILE *ofptr;
  char *line = NULL;
  char *testline = NULL;
  size_t len = 0;
  ssize_t read;
  char *pos;
  unsigned char cr = 0x0d;
  unsigned char lf = 0x0a;
  if (argc < 5) {
    helptext(argv[0]);
    exit(EXIT_FAILURE);
  }
  int i = 1;
  while (i < argc) {
    if (strcmp(argv[i], "--dos2unix") == 0) {
      dos2unix = 1;
    }
    if (strcmp(argv[i], "--unix2dos") == 0) {
      unix2dos = 1;
    }
    if (strcmp(argv[i], "-a") == 0) {
      testline = (char *)malloc(2000);
      v_auto = 1;
    }
    if (strcmp(argv[i], "-i") == 0) {
      i++;
      infile = argv[i];
    }
    if (strcmp(argv[i], "-o") == 0) {
      i++;
      outfile = argv[i];
    }
    i++;
  }
  if ((dos2unix + unix2dos + v_auto) != 1) {
    puts(
        "Select either dos2unix or unix2dos, or auto if you are feeling brave");
    helptext(argv[0]);
    exit(EXIT_FAILURE);
  }
  if (v_auto == 1) {
    dos2unix = 0;
    unix2dos = 0;
  }
  if (strcmp(infile, outfile) == 0) {
    puts("Input and output file may not be the same");
    helptext(argv[0]);
    exit(EXIT_FAILURE);
  }
  while ((ifptr = fopen(infile, "r")) == NULL) {
    puts("Input file can not be opened");
    helptext(argv[0]);
    exit(EXIT_FAILURE);
  }
  while ((ofptr = fopen(outfile, "w")) == NULL) {
    puts("Output file can not be opened");
    helptext(argv[0]);
    exit(EXIT_FAILURE);
  }
  while ((read = getline(&line, &len, ifptr)) != -1) {
    if (v_auto == 1) {
      strcpy(testline, line);
      strip(line);
      if ((strlen(line) + 1) < strlen(testline)) {
        dos2unix = 1;
      } else {
        unix2dos = 1;
      }
    } else {
      strip(line);
    }
    fprintf(ofptr, "%s", line);
    if (dos2unix == 1) {
      fprintf(ofptr, "%c", lf);
    } else {
      fprintf(ofptr, "%c%c", cr, lf);
    }
  }
  fclose(ifptr);
  fclose(ofptr);
  if (line)
    free(line);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movb   $0xd,-0x69(%rbp)
movb   $0xa,-0x6a(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1242 <main+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <helptext@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
movl   $0x1,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1362 <main+0x192>
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd98(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <main+0xae>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd7a(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12a7 <main+0xd7>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd5c(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12de <main+0x10e>
mov    $0x7d0,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd28(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1319 <main+0x149>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcf0(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1354 <main+0x184>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x70(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1249 <main+0x79>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
cmp    $0x1,%eax
je     139a <main+0x1ca>
lea    0xca4(%rip),%rdi
call   1050 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <helptext@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    13b2 <main+0x1e2>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13ef <main+0x21f>
lea    0xc94(%rip),%rdi
call   1050 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <helptext@plt>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    13f4 <main+0x224>
mov    -0x28(%rbp),%rdi
lea    0xc8f(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1438 <main+0x268>
lea    0xc77(%rip),%rdi
call   1050 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <helptext@plt>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    143d <main+0x26d>
mov    -0x30(%rbp),%rdi
lea    0xc65(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1481 <main+0x2b1>
lea    0xc4d(%rip),%rdi
call   1050 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <helptext@plt>
mov    0x2b66(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    1486 <main+0x2b6>
mov    -0x38(%rbp),%rdx
lea    -0x48(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   10e0 <getline@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0xffffffff,%eax
je     1568 <main+0x398>
cmpl   $0x1,-0x1c(%rbp)
jne    1505 <main+0x335>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1080 <strip@plt>
mov    -0x48(%rbp),%rdi
call   1070 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
jge    14f9 <main+0x329>
movl   $0x1,-0x14(%rbp)
jmp    1500 <main+0x330>
movl   $0x1,-0x18(%rbp)
jmp    150e <main+0x33e>
mov    -0x48(%rbp),%rdi
call   1080 <strip@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rdx
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    1549 <main+0x379>
mov    -0x40(%rbp),%rdi
movzbl -0x6a(%rbp),%edx
lea    0xb95(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1563 <main+0x393>
mov    -0x40(%rbp),%rdi
movzbl -0x69(%rbp),%edx
movzbl -0x6a(%rbp),%ecx
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1486 <main+0x2b6>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x48(%rbp)
je     158e <main+0x3be>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a43(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
movq   $0x0,0x10(%rsp)
movq   $0x0,0x28(%rsp)
cmp    $0x5,%edi
jl     1372 <main+0x182>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r13d
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
mov    %edi,0x1c(%rsp)
mov    $0x1,%r15d
jmp    1261 <main+0x71>
nopw   0x0(%rax,%rax,1)
mov    0x1c(%rsp),%edi
add    $0x1,%r13d
cmp    %edi,%r13d
jge    1327 <main+0x137>
movslq %r13d,%rbp
mov    (%rbx,%rbp,8),%rdi
lea    0xd91(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
mov    0x8(%rsp),%rax
cmove  %r15d,%eax
mov    %rax,0x8(%rsp)
mov    (%rbx,%rbp,8),%rdi
lea    0xd7b(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
cmove  %r15d,%r12d
mov    (%rbx,%rbp,8),%rdi
lea    0xd6f(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12c8 <main+0xd8>
mov    $0x7d0,%edi
call   10d0 <malloc@plt>
mov    %rax,0x20(%rsp)
movl   $0x1,0x4(%rsp)
mov    (%rbx,%rbp,8),%rdi
lea    0xd46(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12f0 <main+0x100>
mov    (%rbx,%rbp,8),%rdi
jmp    12fc <main+0x10c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbp),%r13d
mov    0x8(%rbx,%rbp,8),%rdi
mov    %rdi,%r14
lea    0xd19(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1250 <main+0x60>
movslq %r13d,%rax
add    $0x1,%r13d
mov    0x8(%rbx,%rax,8),%rax
mov    %rax,0x30(%rsp)
jmp    1250 <main+0x60>
mov    0x4(%rsp),%ebp
add    %ebp,%r12d
mov    0x8(%rsp),%r13
add    %r13d,%r12d
cmp    $0x1,%r12d
jne    1366 <main+0x176>
xor    %eax,%eax
cmp    $0x1,%ebp
cmove  %eax,%r13d
mov    %r14,%r15
mov    %r14,%rdi
mov    0x30(%rsp),%r14
mov    %r14,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1388 <main+0x198>
lea    0xd00(%rip),%rdi
jmp    136d <main+0x17d>
lea    0xcb2(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rdi
call   10e0 <helptext@plt>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    %ebp,%r12d
lea    0xcfc(%rip),%rsi
mov    %r15,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
jne    13a8 <main+0x1b8>
lea    0xcea(%rip),%rdi
jmp    136d <main+0x17d>
mov    %rax,0x8(%rsp)
lea    0xcf9(%rip),%rsi
mov    %r14,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
jne    13ca <main+0x1da>
lea    0xce7(%rip),%rdi
jmp    136d <main+0x17d>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    0x8(%rsp),%rbx
mov    %rbx,%rdx
call   1100 <getline@plt>
cmp    $0xffffffff,%eax
mov    %r13,%r14
mov    %rbx,%r13
jne    141c <main+0x22c>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     140e <main+0x21e>
call   1030 <free@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0x10(%rsp),%rbp
jmp    146d <main+0x27d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <fputs@plt>
mov    0x4(%rsp),%r12d
mov    0x8(%rsp),%r13
mov    $0xa,%edi
mov    %r15,%rsi
call   10a0 <fputc@plt>
mov    $0x1,%r14d
mov    %rbp,%rdi
lea    0x28(%rsp),%rsi
mov    %r13,%rdx
call   1100 <getline@plt>
cmp    $0xffffffff,%eax
je     13ef <main+0x1ff>
mov    0x10(%rsp),%rsi
cmp    $0x1,%r12d
jne    14c0 <main+0x2d0>
mov    0x20(%rsp),%r13
mov    %r13,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rsp),%rdi
call   1090 <strip@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %rax,%r12
add    $0x1,%r12
mov    %r13,%rdi
call   1070 <strlen@plt>
cmp    %rax,%r12
jl     1430 <main+0x240>
mov    0x4(%rsp),%r12d
mov    0x8(%rsp),%r13
jmp    14cd <main+0x2dd>
nopl   0x0(%rax)
mov    %rsi,%rdi
call   1090 <strip@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <fputs@plt>
cmp    $0x1,%r14d
je     1445 <main+0x255>
mov    %r15,%rdi
lea    0xbe1(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1458 <main+0x268>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [11 x i8] c"--dos2unix\00"
@.str.1 = [11 x i8] c"--unix2dos\00"
@.str.2 = [3 x i8] c"-a\00"
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [3 x i8] c"-o\00"
@.str.5 = [69 x i8] c"Select either dos2unix or unix2dos, or auto if you are feeling brave\00"
@.str.6 = [42 x i8] c"Input and output file may not be the same\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [29 x i8] c"Input file can not be opened\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [30 x i8] c"Output file can not be opened\00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [3 x i8] c"%c\00"
@.str.13 = [5 x i8] c"%c%c\00"
@EXIT_SUCCESS = global i32 0
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 i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8
%19 = alloca i8
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %13
store i8* null, i8** %14
store i64 0, i64* %15
store i8 13, i8* %18
store i8 10, i8* %19
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 5
br i1 %22, label %23, label %30
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @helptext(i8* %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %2
store i32 1, i32* %20
br label %31
31: ; preds = %96, %30
%32 = load i32, i32* %20
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %99
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %20
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %35
store i32 1, i32* %6
br label %44
44: ; preds = %43, %35
%45 = load i8**, i8*** %5
%46 = load i32, i32* %20
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %44
store i32 1, i32* %7
br label %53
53: ; preds = %52, %44
%54 = load i8**, i8*** %5
%55 = load i32, i32* %20
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %53
%62 = call i64 @malloc(i32 2000)
%63 = inttoptr i64 %62 to i8*
store i8* %63, i8** %14
store i32 1, i32* %8
br label %64
64: ; preds = %61, %53
%65 = load i8**, i8*** %5
%66 = load i32, i32* %20
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %80
72: ; preds = %64
%73 = load i32, i32* %20
%74 = add nsw i32 %73, 1
store i32 %74, i32* %20
%75 = load i8**, i8*** %5
%76 = load i32, i32* %20
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
%79 = load i8*, i8** %78
store i8* %79, i8** %9
br label %80
80: ; preds = %72, %64
%81 = load i8**, i8*** %5
%82 = load i32, i32* %20
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %96
88: ; preds = %80
%89 = load i32, i32* %20
%90 = add nsw i32 %89, 1
store i32 %90, i32* %20
%91 = load i8**, i8*** %5
%92 = load i32, i32* %20
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %91, i64 %93
%95 = load i8*, i8** %94
store i8* %95, i8** %10
br label %96
96: ; preds = %88, %80
%97 = load i32, i32* %20
%98 = add nsw i32 %97, 1
store i32 %98, i32* %20
br label %31
99: ; preds = %31
%100 = load i32, i32* %6
%101 = load i32, i32* %7
%102 = add nsw i32 %100, %101
%103 = load i32, i32* %8
%104 = add nsw i32 %102, %103
%105 = icmp ne i32 %104, 1
br i1 %105, label %106, label %114
106: ; preds = %99
%107 = call i32 @puts(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0))
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 0
%110 = load i8*, i8** %109
%111 = call i32 @helptext(i8* %110)
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %99
%115 = load i32, i32* %8
%116 = icmp eq i32 %115, 1
br i1 %116, label %117, label %118
117: ; preds = %114
store i32 0, i32* %6
store i32 0, i32* %7
br label %118
118: ; preds = %117, %114
%119 = load i8*, i8** %9
%120 = load i8*, i8** %10
%121 = call i64 @strcmp(i8* %119, i8* %120)
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %131
123: ; preds = %118
%124 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%125 = load i8**, i8*** %5
%126 = getelementptr inbounds i8*, i8** %125, i64 0
%127 = load i8*, i8** %126
%128 = call i32 @helptext(i8* %127)
%129 = load i32, i32* @EXIT_FAILURE
%130 = call i32 @exit(i32 %129)
unreachable
131: ; preds = %118
br label %132
132: ; preds = %131
%133 = load i8*, i8** %9
%134 = call i32* @fopen(i8* %133, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %134, i32** %11
%135 = icmp eq i32* %134, null
br i1 %135, label %136, label %144
136: ; preds = %132
%137 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 0
%140 = load i8*, i8** %139
%141 = call i32 @helptext(i8* %140)
%142 = load i32, i32* @EXIT_FAILURE
%143 = call i32 @exit(i32 %142)
unreachable
144: ; preds = %132
br label %145
145: ; preds = %144
%146 = load i8*, i8** %10
%147 = call i32* @fopen(i8* %146, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %147, i32** %12
%148 = icmp eq i32* %147, null
br i1 %148, label %149, label %157
149: ; preds = %145
%150 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%151 = load i8**, i8*** %5
%152 = getelementptr inbounds i8*, i8** %151, i64 0
%153 = load i8*, i8** %152
%154 = call i32 @helptext(i8* %153)
%155 = load i32, i32* @EXIT_FAILURE
%156 = call i32 @exit(i32 %155)
unreachable
157: ; preds = %145
br label %158
158: ; preds = %201, %157
%159 = load i32*, i32** %11
%160 = call i32 @getline(i8** %13, i64* %15, i32* %159)
store i32 %160, i32* %16
%161 = icmp ne i32 %160, -1
br i1 %161, label %162, label %202
162: ; preds = %158
%163 = load i32, i32* %8
%164 = icmp eq i32 %163, 1
br i1 %164, label %165, label %180
165: ; preds = %162
%166 = load i8*, i8** %14
%167 = load i8*, i8** %13
%168 = call i32 @strcpy(i8* %166, i8* %167)
%169 = load i8*, i8** %13
%170 = call i32 @strip(i8* %169)
%171 = load i8*, i8** %13
%172 = call i64 @strlen(i8* %171)
%173 = add nsw i64 %172, 1
%174 = load i8*, i8** %14
%175 = call i64 @strlen(i8* %174)
%176 = icmp slt i64 %173, %175
br i1 %176, label %177, label %178
177: ; preds = %165
store i32 1, i32* %6
br label %179
178: ; preds = %165
store i32 1, i32* %7
br label %179
179: ; preds = %178, %177
br label %183
180: ; preds = %162
%181 = load i8*, i8** %13
%182 = call i32 @strip(i8* %181)
br label %183
183: ; preds = %180, %179
%184 = load i32*, i32** %12
%185 = load i8*, i8** %13
%186 = call i32 (i32*, i8*, ...) @fprintf(i32* %184, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %185)
%187 = load i32, i32* %6
%188 = icmp eq i32 %187, 1
br i1 %188, label %189, label %194
189: ; preds = %183
%190 = load i32*, i32** %12
%191 = load i8, i8* %19
%192 = zext i8 %191 to i32
%193 = call i32 (i32*, i8*, ...) @fprintf(i32* %190, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i32 %192)
br label %201
194: ; preds = %183
%195 = load i32*, i32** %12
%196 = load i8, i8* %18
%197 = zext i8 %196 to i32
%198 = load i8, i8* %19
%199 = zext i8 %198 to i32
%200 = call i32 (i32*, i8*, ...) @fprintf(i32* %195, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %197, i32 %199)
br label %201
201: ; preds = %194, %189
br label %158
202: ; preds = %158
%203 = load i32*, i32** %11
%204 = call i32 @fclose(i32* %203)
%205 = load i32*, i32** %12
%206 = call i32 @fclose(i32* %205)
%207 = load i8*, i8** %13
%208 = icmp ne i8* %207, null
br i1 %208, label %209, label %212
209: ; preds = %202
%210 = load i8*, i8** %13
%211 = call i32 @free(i8* %210)
br label %212
212: ; preds = %209, %202
%213 = load i32, i32* @EXIT_SUCCESS
%214 = call i32 @exit(i32 %213)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [11 x i8] c"--dos2unix\00"
@.str.1 = [11 x i8] c"--unix2dos\00"
@.str.2 = [3 x i8] c"-a\00"
@.str.3 = [3 x i8] c"-i\00"
@.str.4 = [3 x i8] c"-o\00"
@.str.5 = [69 x i8] c"Select either dos2unix or unix2dos, or auto if you are feeling brave\00"
@.str.6 = [42 x i8] c"Input and output file may not be the same\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [29 x i8] c"Input file can not be opened\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [30 x i8] c"Output file can not be opened\00"
@.str.13 = [5 x i8] c"%c%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp slt i32 %0, 5
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @helptext(i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2, %61
%14 = phi i32 [ %64, %61 ], [ 1, %2 ]
%15 = phi i32 [ %26, %61 ], [ 0, %2 ]
%16 = phi i32 [ %30, %61 ], [ 0, %2 ]
%17 = phi i32 [ %39, %61 ], [ 0, %2 ]
%18 = phi i8* [ %52, %61 ], [ undef, %2 ]
%19 = phi i8* [ %38, %61 ], [ null, %2 ]
%20 = phi i8* [ %62, %61 ], [ undef, %2 ]
%21 = sext i32 %14 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i32 1, i32 %15
%27 = load i8*, i8** %22
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i32 1, i32 %16
%31 = load i8*, i8** %22
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %13
%35 = tail call i64 @malloc(i32 2000)
%36 = inttoptr i64 %35 to i8*
br label %37
37: ; preds = %34, %13
%38 = phi i8* [ %36, %34 ], [ %19, %13 ]
%39 = phi i32 [ 1, %34 ], [ %17, %13 ]
%40 = load i8*, i8** %22
%41 = tail call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %37
%44 = load i8*, i8** %22
br label %50
45: ; preds = %37
%46 = add nsw i32 %14, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
br label %50
50: ; preds = %43, %45
%51 = phi i8* [ %49, %45 ], [ %44, %43 ]
%52 = phi i8* [ %49, %45 ], [ %18, %43 ]
%53 = phi i32 [ %46, %45 ], [ %14, %43 ]
%54 = tail call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %50
%57 = add nsw i32 %53, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
br label %61
61: ; preds = %56, %50
%62 = phi i8* [ %60, %56 ], [ %20, %50 ]
%63 = phi i32 [ %57, %56 ], [ %53, %50 ]
%64 = add nsw i32 %63, 1
%65 = icmp slt i32 %64, %0
br i1 %65, label %13, label %66
66: ; preds = %61
%67 = add i32 %30, %39
%68 = add i32 %67, %26
%69 = icmp eq i32 %68, 1
br i1 %69, label %76, label %70
70: ; preds = %66
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0))
%72 = load i8*, i8** %1
%73 = tail call i32 @helptext(i8* %72)
%74 = load i32, i32* @EXIT_FAILURE
%75 = tail call i32 @exit(i32 %74)
unreachable
76: ; preds = %66
%77 = icmp eq i32 %39, 1
%78 = select i1 %77, i32 0, i32 %26
%79 = tail call i64 @strcmp(i8* %52, i8* %62)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %87
81: ; preds = %76
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%83 = load i8*, i8** %1
%84 = tail call i32 @helptext(i8* %83)
%85 = load i32, i32* @EXIT_FAILURE
%86 = tail call i32 @exit(i32 %85)
unreachable
87: ; preds = %76
%88 = tail call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%92 = load i8*, i8** %1
%93 = tail call i32 @helptext(i8* %92)
%94 = load i32, i32* @EXIT_FAILURE
%95 = tail call i32 @exit(i32 %94)
unreachable
96: ; preds = %87
%97 = tail call i32* @fopen(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%98 = icmp eq i32* %97, null
br i1 %98, label %102, label %99
99: ; preds = %96
%100 = call i32 @getline(i8** %3, i64* %4, i32* %88)
%101 = icmp eq i32 %100, -1
br i1 %101, label %137, label %108
102: ; preds = %96
%103 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%104 = load i8*, i8** %1
%105 = tail call i32 @helptext(i8* %104)
%106 = load i32, i32* @EXIT_FAILURE
%107 = tail call i32 @exit(i32 %106)
unreachable
108: ; preds = %99, %133
%109 = phi i32 [ %134, %133 ], [ %78, %99 ]
%110 = load i8*, i8** %3
br i1 %77, label %111, label %120
111: ; preds = %108
%112 = call i32 @strcpy(i8* %38, i8* %110)
%113 = load i8*, i8** %3
%114 = call i32 @strip(i8* %113)
%115 = load i8*, i8** %3
%116 = call i64 @strlen(i8* dereferenceable(1) %115)
%117 = add nsw i64 %116, 1
%118 = call i64 @strlen(i8* dereferenceable(1) %38)
%119 = icmp slt i64 %117, %118
br i1 %119, label %123, label %125
120: ; preds = %108
%121 = call i32 @strip(i8* %110)
%122 = load i8*, i8** %3
br label %125
123: ; preds = %111
%124 = call i32 @fputs(i8* %115, i32* %97)
br label %129
125: ; preds = %111, %120
%126 = phi i8* [ %115, %111 ], [ %122, %120 ]
%127 = call i32 @fputs(i8* %126, i32* %97)
%128 = icmp eq i32 %109, 1
br i1 %128, label %129, label %131
129: ; preds = %123, %125
%130 = call i32 @fputc(i32 10, i32* %97)
br label %133
131: ; preds = %125
%132 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 13, i32 10)
br label %133
133: ; preds = %131, %129
%134 = phi i32 [ %109, %131 ], [ 1, %129 ]
%135 = call i32 @getline(i8** %3, i64* %4, i32* %88)
%136 = icmp eq i32 %135, -1
br i1 %136, label %137, label %108
137: ; preds = %133, %99
%138 = call i32 @fclose(i32* %88)
%139 = call i32 @fclose(i32* %97)
%140 = load i8*, i8** %3
%141 = icmp eq i8* %140, null
br i1 %141, label %144, label %142
142: ; preds = %137
%143 = call i32 @free(i8* %140)
br label %144
144: ; preds = %142, %137
%145 = load i32, i32* @EXIT_SUCCESS
%146 = call i32 @exit(i32 %145)
unreachable
}