#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 BUFSIZ;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  int id = 0;
  int strl;
  char buff[BUFSIZ];
  char *name = malloc(BUFSIZ * sizeof(char));
  char *prog_name = argv[0];
  char *file_name = argv[1];
  FILE *file_pointer;
  size_t tsize = 0;
  if (argc == 1) {
    fprintf(stderr, "only program name \"%s\"\n", prog_name);
    exit(1);
  } else if (argc == 2) {
    file_pointer = fopen(file_name, "w");
    if (file_pointer == NULL) {
      fprintf(stderr, "cannot open file \"%s\" for writing\n", prog_name);
      exit(1);
    } else {
      while (id < 5) {
        printf("name = ");
        getline(&name, &tsize, stdin);
        strl = strlen(name) - 1;
        if (name[strl] == '\n') {
          name[strl] = '\0';
        }
        fprintf(file_pointer, "%d.%s\n", id, name);
        id++;
      }
      fclose(file_pointer);
      if (id == 5) {
        file_pointer = fopen(file_name, "r");
        if (file_pointer == NULL) {
          fprintf(stderr, "cannot open file \"%s\" for reading\n", prog_name);
          exit(1);
        } else {
          printf("\n");
          while (fgets(buff, BUFSIZ, file_pointer) != NULL) {
            strl = strlen(buff) - 1;
            if (buff[strl] == '\n') {
              buff[strl] = '\0';
            }
            printf("%s\n", buff);
          }
          fclose(file_pointer);
          free(name);
          name = NULL;
        }
      } else {
        fprintf(stderr, "error writing to file %s\n", prog_name);
        exit(1);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2de0(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1250 <main+0xb0>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1446 <main+0x2a6>
mov    -0x40(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    129e <main+0xfe>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    12a3 <main+0x103>
cmpl   $0x5,-0x14(%rbp)
jge    132a <main+0x18a>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10b0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1301 <main+0x161>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
mov    %eax,%edi
mov    -0x14(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a3 <main+0x103>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x5,-0x14(%rbp)
jne    1417 <main+0x277>
mov    -0x40(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1381 <main+0x1e1>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xcde(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    0x2c36(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13f8 <main+0x258>
mov    -0x58(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
sub    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    13e1 <main+0x241>
mov    -0x58(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rsi
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138f <main+0x1ef>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
jmp    143c <main+0x29c>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc46(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1441 <main+0x2a1>
jmp    1446 <main+0x2a6>
jmp    144b <main+0x2ab>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    0x2df2(%rip),%r14
mov    (%r14),%edi
mov    %rsp,%r13
mov    %rdi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    (%rbx),%rdx
mov    0x8(%rbx),%r15
movq   $0x0,-0x38(%rbp)
cmp    $0x2,%r12d
je     1232 <main+0x72>
cmp    $0x1,%r12d
jne    1466 <main+0x2a6>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
jmp    149d <main+0x2dd>
mov    %rdx,-0x40(%rbp)
lea    0xddb(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1477 <main+0x2b7>
mov    %rax,%r12
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d82(%rip),%rbx
mov    (%rbx),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    -0x30(%rbp),%rcx
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    1294 <main+0xd4>
movb   $0x0,-0x1(%rcx,%rax,1)
mov    -0x30(%rbp),%rcx
lea    0xdaa(%rip),%rsi
mov    %r12d,%edi
xor    %edx,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd8f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    -0x30(%rbp),%rcx
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    12e3 <main+0x123>
movb   $0x0,-0x1(%rcx,%rax,1)
mov    -0x30(%rbp),%rcx
lea    0xd5b(%rip),%rsi
mov    %r12d,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xd3d(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    -0x30(%rbp),%rcx
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    1335 <main+0x175>
movb   $0x0,-0x1(%rcx,%rax,1)
mov    -0x30(%rbp),%rcx
lea    0xd09(%rip),%rsi
mov    %r12d,%edi
mov    $0x2,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xceb(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    -0x30(%rbp),%rcx
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    1387 <main+0x1c7>
movb   $0x0,-0x1(%rcx,%rax,1)
mov    -0x30(%rbp),%rcx
lea    0xcb7(%rip),%rsi
mov    %r12d,%edi
mov    $0x3,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xc99(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cltq
mov    -0x30(%rbp),%rcx
cmpb   $0xa,-0x1(%rax,%rcx,1)
jne    13d9 <main+0x219>
movb   $0x0,-0x1(%rcx,%rax,1)
mov    -0x30(%rbp),%rcx
lea    0xc65(%rip),%rsi
mov    %r12d,%edi
mov    $0x4,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
lea    0xc4e(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1489 <main+0x2c9>
mov    %rax,%rbx
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1428 <main+0x268>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1050 <puts@plt>
mov    (%r14),%esi
mov    %r13,%rdi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1455 <main+0x295>
mov    %r13,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r13,1)
jne    1420 <main+0x260>
movb   $0x0,-0x1(%r13,%rax,1)
jmp    1420 <main+0x260>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b5a(%rip),%rax
mov    (%rax),%edi
lea    0xb93(%rip),%rsi
jmp    1499 <main+0x2d9>
mov    0x2b48(%rip),%rax
mov    (%rax),%edi
lea    0xbb5(%rip),%rsi
mov    -0x40(%rbp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"only program name \22%s\22\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [35 x i8] c"cannot open file \22%s\22 for writing\0A\00"
@.str.3 = [8 x i8] c"name = \00"
@stdin = global i32 0
@.str.4 = [7 x i8] c"%d.%s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [35 x i8] c"cannot open file \22%s\22 for reading\0A\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@.str.9 = [26 x i8] c"error writing to file %s\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 i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%15 = load i32, i32* @BUFSIZ
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %8
%18 = alloca i8, i64 %16
store i64 %16, i64* %9
%19 = load i32, i32* @BUFSIZ
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i8* @malloc(i32 %22)
store i8* %23, i8** %10
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
store i8* %26, i8** %11
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %12
store i64 0, i64* %14
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %11
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %131
40: ; preds = %37
%41 = load i8*, i8** %12
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %42, i32** %13
%43 = load i32*, i32** %13
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %11
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %40
br label %51
51: ; preds = %73, %50
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 5
br i1 %53, label %54, label %81
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* @stdin
%57 = call i32 @getline(i8** %10, i64* %14, i32 %56)
%58 = load i8*, i8** %10
%59 = call i32 @strlen(i8* %58)
%60 = sub nsw i32 %59, 1
store i32 %60, i32* %7
%61 = load i8*, i8** %10
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 10
br i1 %67, label %68, label %73
68: ; preds = %54
%69 = load i8*, i8** %10
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 0, i8* %72
br label %73
73: ; preds = %68, %54
%74 = load i32*, i32** %13
%75 = ptrtoint i32* %74 to i32
%76 = load i32, i32* %6
%77 = load i8*, i8** %10
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %76, i8* %77)
%79 = load i32, i32* %6
%80 = add nsw i32 %79, 1
store i32 %80, i32* %6
br label %51
81: ; preds = %51
%82 = load i32*, i32** %13
%83 = call i32 @fclose(i32* %82)
%84 = load i32, i32* %6
%85 = icmp eq i32 %84, 5
br i1 %85, label %86, label %124
86: ; preds = %81
%87 = load i8*, i8** %12
%88 = call i32* @fopen(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %88, i32** %13
%89 = load i32*, i32** %13
%90 = icmp eq i32* %89, null
br i1 %90, label %91, label %96
91: ; preds = %86
%92 = load i32, i32* @stderr
%93 = load i8*, i8** %11
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %93)
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %86
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %98
98: ; preds = %116, %96
%99 = load i32, i32* @BUFSIZ
%100 = load i32*, i32** %13
%101 = call i32* @fgets(i8* %18, i32 %99, i32* %100)
%102 = icmp ne i32* %101, null
br i1 %102, label %103, label %118
103: ; preds = %98
%104 = call i32 @strlen(i8* %18)
%105 = sub nsw i32 %104, 1
store i32 %105, i32* %7
%106 = load i32, i32* %7
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %18, i64 %107
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 10
br i1 %111, label %112, label %116
112: ; preds = %103
%113 = load i32, i32* %7
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %18, i64 %114
store i8 0, i8* %115
br label %116
116: ; preds = %112, %103
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %18)
br label %98
118: ; preds = %98
%119 = load i32*, i32** %13
%120 = call i32 @fclose(i32* %119)
%121 = load i8*, i8** %10
%122 = call i32 @free(i8* %121)
store i8* null, i8** %10
br label %123
123: ; preds = %118
br label %129
124: ; preds = %81
%125 = load i32, i32* @stderr
%126 = load i8*, i8** %11
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %126)
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %123
br label %130
130: ; preds = %129
br label %131
131: ; preds = %130, %37
br label %132
132: ; preds = %131
store i32 0, i32* %3
%133 = load i8*, i8** %8
%134 = load i32, i32* %3
ret i32 %134
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"only program name \22%s\22\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [35 x i8] c"cannot open file \22%s\22 for writing\0A\00"
@.str.3 = [8 x i8] c"name = \00"
@stdin = global i32 0
@.str.4 = [7 x i8] c"%d.%s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [35 x i8] c"cannot open file \22%s\22 for reading\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i8** %3 to i8*
%9 = tail call i8* @malloc(i32 %5)
store i8* %9, i8** %3
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = bitcast i64* %4 to i8*
store i64 0, i64* %4
switch i32 %0, label %137 [
i32 1, label %14
i32 2, label %18
]
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %10)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %35, label %21
21: ; preds = %18
%22 = ptrtoint i32* %19 to i64
%23 = trunc i64 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @stdin
%26 = call i32 @getline(i8** %3, i64* %4, i32 %25)
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %28, -1
%30 = load i8*, i8** %3
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 10
br i1 %34, label %39, label %41
35: ; preds = %18
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %21
store i8 0, i8* %32
%40 = load i8*, i8** %3
br label %41
41: ; preds = %39, %21
%42 = phi i8* [ %40, %39 ], [ %30, %21 ]
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 0, i8* %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @stdin
%46 = call i32 @getline(i8** %3, i64* %4, i32 %45)
%47 = load i8*, i8** %3
%48 = call i32 @strlen(i8* %47)
%49 = add nsw i32 %48, -1
%50 = load i8*, i8** %3
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8, i8* %50, i64 %51
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 10
br i1 %54, label %55, label %57
55: ; preds = %41
store i8 0, i8* %52
%56 = load i8*, i8** %3
br label %57
57: ; preds = %55, %41
%58 = phi i8* [ %56, %55 ], [ %50, %41 ]
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 1, i8* %58)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* @stdin
%62 = call i32 @getline(i8** %3, i64* %4, i32 %61)
%63 = load i8*, i8** %3
%64 = call i32 @strlen(i8* %63)
%65 = add nsw i32 %64, -1
%66 = load i8*, i8** %3
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds i8, i8* %66, i64 %67
%69 = load i8, i8* %68
%70 = icmp eq i8 %69, 10
br i1 %70, label %71, label %73
71: ; preds = %57
store i8 0, i8* %68
%72 = load i8*, i8** %3
br label %73
73: ; preds = %71, %57
%74 = phi i8* [ %72, %71 ], [ %66, %57 ]
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, i8* %74)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%77 = load i32, i32* @stdin
%78 = call i32 @getline(i8** %3, i64* %4, i32 %77)
%79 = load i8*, i8** %3
%80 = call i32 @strlen(i8* %79)
%81 = add nsw i32 %80, -1
%82 = load i8*, i8** %3
%83 = sext i32 %81 to i64
%84 = getelementptr inbounds i8, i8* %82, i64 %83
%85 = load i8, i8* %84
%86 = icmp eq i8 %85, 10
br i1 %86, label %87, label %89
87: ; preds = %73
store i8 0, i8* %84
%88 = load i8*, i8** %3
br label %89
89: ; preds = %87, %73
%90 = phi i8* [ %88, %87 ], [ %82, %73 ]
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 3, i8* %90)
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%93 = load i32, i32* @stdin
%94 = call i32 @getline(i8** %3, i64* %4, i32 %93)
%95 = load i8*, i8** %3
%96 = call i32 @strlen(i8* %95)
%97 = add nsw i32 %96, -1
%98 = load i8*, i8** %3
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %98, i64 %99
%101 = load i8, i8* %100
%102 = icmp eq i8 %101, 10
br i1 %102, label %103, label %105
103: ; preds = %89
store i8 0, i8* %100
%104 = load i8*, i8** %3
br label %105
105: ; preds = %89, %103
%106 = phi i8* [ %104, %103 ], [ %98, %89 ]
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 4, i8* %106)
%108 = call i32 @fclose(i32* %19)
%109 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%110 = icmp eq i32* %109, null
br i1 %110, label %111, label %115
111: ; preds = %105
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %105
%116 = call i32 @putchar(i32 10)
%117 = load i32, i32* @BUFSIZ
%118 = call i32* @fgets(i8* %7, i32 %117, i32* %109)
%119 = icmp eq i32* %118, null
br i1 %119, label %133, label %120
120: ; preds = %115, %128
%121 = call i32 @strlen(i8* %7)
%122 = add nsw i32 %121, -1
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8, i8* %7, i64 %123
%125 = load i8, i8* %124
%126 = icmp eq i8 %125, 10
br i1 %126, label %127, label %128
127: ; preds = %120
store i8 0, i8* %124
br label %128
128: ; preds = %127, %120
%129 = call i32 @puts(i8* %7)
%130 = load i32, i32* @BUFSIZ
%131 = call i32* @fgets(i8* %7, i32 %130, i32* %109)
%132 = icmp eq i32* %131, null
br i1 %132, label %133, label %120
133: ; preds = %128, %115
%134 = call i32 @fclose(i32* %109)
%135 = load i8*, i8** %3
%136 = call i32 @free(i8* %135)
br label %137
137: ; preds = %2, %133
ret i32 0
}