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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long, int, char *);
char getchar();
int rand();
int /*<<< orphan*/ srand(char);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(void) {
  FILE *nodes;
  FILE *check;
  FILE *inputFiles[30];
  int i = 0;
  nodes = fopen("motePaths.txt", "r");
  check = fopen("check.txt", "w");
  char filename[256];
  while (fgets(filename, 256, nodes)) {
    if (strlen(filename) > 2 && filename[0] != '\n' && filename[0] != '#') {
      char subbuff[strlen(filename) - 4];
      strncpy(subbuff, filename + 5, strlen(filename) - 3);
      subbuff[strlen(filename) - 6] = '\0';
      inputFiles[i] = fopen(subbuff, "w");
      i++;
    }
  }
  fclose(nodes);
  char c = getchar();
  srand(c);
  long counter = 0;
  FILE *f;
  f = fopen("messageText.txt", "r");
  char buf[20 + 2];
  while (fgets(buf, sizeof(buf) - 2, f)) {
    if (strlen(buf) > 15 && buf[0] != '\0') {
      if (buf[strlen(buf) - 1] == '\n') {
        fprintf(inputFiles[counter % i], "#%ld%ld#%s", counter, rand() % 10,
                buf);
        fprintf(check, "#%ld#%ld#%s#", counter, rand() % 100000, buf);
      } else {
        fprintf(inputFiles[counter % i], "#%ld%ld#%s\n", counter, rand() % 10,
                buf);
        fprintf(check, "#%ld%ld#%s#\n", counter, rand() % 10, buf);
      }
      counter++;
    }
  }
  fclose(f);
  fclose(check);
  for (int j = 0; j < i; j++) {
    fclose(inputFiles[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
lea    0xe4d(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe46(%rip),%rdi
lea    0xe49(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12f7 <main+0x167>
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jle    12f2 <main+0x162>
movsbl -0x220(%rbp),%eax
cmp    $0xa,%eax
je     12f2 <main+0x162>
movsbl -0x220(%rbp),%eax
cmp    $0x23,%eax
je     12f2 <main+0x162>
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
add    $0xfffffffc,%eax
mov    %rsp,%rcx
mov    %rcx,-0x228(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x270(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x230(%rbp)
lea    -0x220(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x278(%rbp)
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x278(%rbp),%rsi
mov    -0x270(%rbp),%rdi
mov    %eax,%edx
sub    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x270(%rbp),%rdi
sub    $0x6,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
lea    0xd58(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rcx
movslq -0x114(%rbp),%rax
mov    %rcx,-0x110(%rbp,%rax,8)
ff
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
mov    -0x228(%rbp),%rax
mov    %rax,%rsp
jmp    11da <main+0x4a>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x231(%rbp)
movsbl -0x231(%rbp),%edi
call   1060 <srand@plt>
movq   $0x0,-0x240(%rbp)
lea    0xcf1(%rip),%rdi
lea    0xcdc(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x248(%rbp)
lea    -0x260(%rbp),%rdi
mov    -0x248(%rbp),%rdx
mov    $0x14,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     151d <main+0x38d>
lea    -0x260(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xf,%eax
jle    1518 <main+0x388>
movsbl -0x260(%rbp),%eax
cmp    $0x0,%eax
je     1518 <main+0x388>
lea    -0x260(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x260(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1459 <main+0x2c9>
mov    -0x240(%rbp),%rax
movslq -0x114(%rbp),%rcx
cqto
idiv   %rcx
mov    -0x110(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x298(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x290(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x298(%rbp),%rdi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x290(%rbp),%rdx
lea    -0x260(%rbp),%r8
lea    0xc28(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x288(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x280(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x288(%rbp),%rdi
mov    $0x186a0,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x280(%rbp),%rdx
lea    -0x260(%rbp),%r8
lea    0xbe8(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1506 <main+0x376>
mov    -0x240(%rbp),%rax
movslq -0x114(%rbp),%rcx
cqto
idiv   %rcx
mov    -0x110(%rbp,%rdx,8),%rax
ff
mov    %rax,-0x2b8(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x2b8(%rbp),%rdi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x2b0(%rbp),%rdx
lea    -0x260(%rbp),%r8
lea    0xb8e(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x2a8(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x2a0(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x2a8(%rbp),%rdi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x2a0(%rbp),%rdx
lea    -0x260(%rbp),%r8
lea    0xb4f(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x240(%rbp)
jmp    133e <main+0x1ae>
mov    -0x248(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x264(%rbp)
mov    -0x264(%rbp),%eax
cmp    -0x114(%rbp),%eax
jge    1576 <main+0x3e6>
movslq -0x264(%rbp),%rax
mov    -0x110(%rbp,%rax,8),%rdi
ff
call   1040 <fclose@plt>
mov    -0x264(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x264(%rbp)
jmp    153c <main+0x3ac>
xor    %eax,%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    $0x228,%rsp
lea    0xe55(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
lea    0xe4f(%rip),%rdi
lea    0xe52(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
lea    -0x160(%rbp),%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12b7 <main+0x127>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
lea    -0x160(%rbp),%rbx
lea    0xe18(%rip),%r13
jmp    1229 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12bd <main+0x12d>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jl     1210 <main+0x80>
movzbl -0x160(%rbp),%eax
cmp    $0xa,%al
je     1210 <main+0x80>
cmp    $0x23,%al
je     1210 <main+0x80>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%r14
add    $0xfffffffc,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    -0x3(%rax),%edx
mov    %r15,%rdi
lea    -0x15b(%rbp),%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x6(%rax,%r15,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   10a0 <fopen@plt>
mov    -0x30(%rbp),%rcx
movslq %ecx,%rcx
mov    %rax,-0x250(%rbp,%rcx,8)
ff
add    $0x1,%ecx
mov    %rcx,-0x30(%rbp)
mov    %r14,%rsp
jmp    1210 <main+0x80>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
movsbl %al,%edi
call   1060 <srand@plt>
lea    0xd41(%rip),%rdi
lea    0xd2c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
lea    -0x60(%rbp),%r12
mov    %r12,%rdi
mov    $0x14,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1419 <main+0x289>
movslq -0x30(%rbp),%r15
xor    %ebx,%ebx
mov    %r14,-0x48(%rbp)
mov    %r15,-0x40(%rbp)
jmp    13da <main+0x24a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
cqto
idiv   %r15
mov    -0x250(%rbp,%rdx,8),%r13
ff
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
cmp    $0xa,%r14b
lea    0xce4(%rip),%rsi
lea    0xcc5(%rip),%rax
cmove  %rax,%rsi
mov    $0xa,%r15d
mov    $0x186a0,%eax
cmove  %eax,%r15d
lea    0xccf(%rip),%r14
lea    0xcaf(%rip),%rax
cmove  %rax,%r14
mov    %r13,%rdi
mov    %rbx,%rdx
mov    %r12,%r8
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
cltd
idiv   %r15d
mov    %edx,%ecx
mov    -0x38(%rbp),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%r8
call   1090 <fprintf@plt>
add    $0x1,%rbx
mov    -0x48(%rbp),%r14
mov    -0x40(%rbp),%r15
mov    %r12,%rdi
mov    $0x14,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1419 <main+0x289>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0x10,%eax
jl     13c5 <main+0x235>
cmpb   $0x0,-0x60(%rbp)
je     13c5 <main+0x235>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
movzbl -0x1(%rax,%r12,1),%r14d
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
jne    1320 <main+0x190>
mov    %ebx,%eax
xor    %edx,%edx
divl   -0x30(%rbp)
jmp    1328 <main+0x198>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rax
test   %eax,%eax
jle    1456 <main+0x2c6>
mov    %eax,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    -0x250(%rbp,%rbx,8),%rdi
ff
call   1040 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1440 <main+0x2b0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"motePaths.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"check.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [16 x i8] c"messageText.txt\00"
@.str.5 = [11 x i8] c"#%ld%ld#%s\00"
@.str.6 = [13 x i8] c"#%ld#%ld#%s#\00"
@.str.7 = [12 x i8] c"#%ld%ld#%s\0A\00"
@.str.8 = [13 x i8] c"#%ld%ld#%s#\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [30 x i32*]
%5 = alloca i32
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8
%10 = alloca i64
%11 = alloca i32*
%12 = alloca [22 x i8]
%13 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%14 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %2
%15 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %15, i32** %3
br label %16
16: ; preds = %60, %0
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = load i32*, i32** %2
%19 = call i64 @fgets(i8* %17, i32 256, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %61
21: ; preds = %16
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %60
25: ; preds = %21
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %60
30: ; preds = %25
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 35
br i1 %34, label %35, label %60
35: ; preds = %30
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = sub nsw i32 %37, 4
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %7
%41 = alloca i8, i64 %39
store i64 %39, i64* %8
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%43 = getelementptr inbounds i8, i8* %42, i64 5
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = sub nsw i32 %45, 3
%47 = call i32 @strncpy(i8* %41, i8* %43, i32 %46)
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %41, i64 %51
store i8 0, i8* %52
%53 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [30 x i32*], [30 x i32*]* %4, i64 0, i64 %55
store i32* %53, i32** %56
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
%59 = load i8*, i8** %7
br label %60
60: ; preds = %35, %30, %25, %21
br label %16
61: ; preds = %16
%62 = load i32*, i32** %2
%63 = call i32 @fclose(i32* %62)
%64 = call signext i8 (...) @getchar()
store i8 %64, i8* %9
%65 = load i8, i8* %9
%66 = call i32 @srand(i8 signext %65)
store i64 0, i64* %10
%67 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %67, i32** %11
br label %68
68: ; preds = %130, %61
%69 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%70 = load i32*, i32** %11
%71 = call i64 @fgets(i8* %69, i32 20, i32* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %131
73: ; preds = %68
%74 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%75 = call i32 @strlen(i8* %74)
%76 = icmp sgt i32 %75, 15
br i1 %76, label %77, label %130
77: ; preds = %73
%78 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %130
82: ; preds = %77
%83 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%84 = call i32 @strlen(i8* %83)
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 10
br i1 %90, label %91, label %109
91: ; preds = %82
%92 = load i64, i64* %10
%93 = load i32, i32* %5
%94 = sext i32 %93 to i64
%95 = srem i64 %92, %94
%96 = getelementptr inbounds [30 x i32*], [30 x i32*]* %4, i64 0, i64 %95
%97 = load i32*, i32** %96
%98 = load i64, i64* %10
%99 = call i32 (...) @rand()
%100 = srem i32 %99, 10
%101 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%102 = call i32 @fprintf(i32* %97, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i64 %98, i32 %100, i8* %101)
%103 = load i32*, i32** %3
%104 = load i64, i64* %10
%105 = call i32 (...) @rand()
%106 = srem i32 %105, 100000
%107 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%108 = call i32 @fprintf(i32* %103, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 %104, i32 %106, i8* %107)
br label %127
109: ; preds = %82
%110 = load i64, i64* %10
%111 = load i32, i32* %5
%112 = sext i32 %111 to i64
%113 = srem i64 %110, %112
%114 = getelementptr inbounds [30 x i32*], [30 x i32*]* %4, i64 0, i64 %113
%115 = load i32*, i32** %114
%116 = load i64, i64* %10
%117 = call i32 (...) @rand()
%118 = srem i32 %117, 10
%119 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%120 = call i32 @fprintf(i32* %115, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i64 %116, i32 %118, i8* %119)
%121 = load i32*, i32** %3
%122 = load i64, i64* %10
%123 = call i32 (...) @rand()
%124 = srem i32 %123, 10
%125 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%126 = call i32 @fprintf(i32* %121, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i64 %122, i32 %124, i8* %125)
br label %127
127: ; preds = %109, %91
%128 = load i64, i64* %10
%129 = add nsw i64 %128, 1
store i64 %129, i64* %10
br label %130
130: ; preds = %127, %77, %73
br label %68
131: ; preds = %68
%132 = load i32*, i32** %11
%133 = call i32 @fclose(i32* %132)
%134 = load i32*, i32** %3
%135 = call i32 @fclose(i32* %134)
store i32 0, i32* %13
br label %136
136: ; preds = %146, %131
%137 = load i32, i32* %13
%138 = load i32, i32* %5
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %149
140: ; preds = %136
%141 = load i32, i32* %13
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [30 x i32*], [30 x i32*]* %4, i64 0, i64 %142
%144 = load i32*, i32** %143
%145 = call i32 @fclose(i32* %144)
br label %146
146: ; preds = %140
%147 = load i32, i32* %13
%148 = add nsw i32 %147, 1
store i32 %148, i32* %13
br label %136
149: ; preds = %136
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"motePaths.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"check.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [16 x i8] c"messageText.txt\00"
@.str.5 = [11 x i8] c"#%ld%ld#%s\00"
@.str.6 = [13 x i8] c"#%ld#%ld#%s#\00"
@.str.7 = [12 x i8] c"#%ld%ld#%s\0A\00"
@.str.8 = [13 x i8] c"#%ld%ld#%s#\0A\00"
define i32 @main() {
%1 = alloca [30 x i32*]
%2 = alloca [256 x i8]
%3 = alloca [22 x i8]
%4 = bitcast [30 x i32*]* %1 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i64 @fgets(i8* %7, i32 256, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %40, label %10
10: ; preds = %0
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 5
br label %12
12: ; preds = %10, %36
%13 = phi i32 [ 0, %10 ], [ %37, %36 ]
%14 = call i32 @strlen(i8* %7)
%15 = freeze i32 %14
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %36
17: ; preds = %12
%18 = load i8, i8* %7
switch i8 %18, label %19 [
i8 35, label %36
i8 10, label %36
]
19: ; preds = %17
%20 = call i32 @strlen(i8* %7)
%21 = add nsw i32 %20, -4
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
%24 = alloca i8, i64 %22
%25 = call i32 @strlen(i8* %7)
%26 = add nsw i32 %25, -3
%27 = call i32 @strncpy(i8* %24, i8* %11, i32 %26)
%28 = call i32 @strlen(i8* %7)
%29 = add nsw i32 %28, -6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %24, i64 %30
store i8 0, i8* %31
%32 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = sext i32 %13 to i64
%34 = getelementptr inbounds [30 x i32*], [30 x i32*]* %1, i64 0, i64 %33
store i32* %32, i32** %34
%35 = add nsw i32 %13, 1
br label %36
36: ; preds = %17, %17, %12, %19
%37 = phi i32 [ %35, %19 ], [ %13, %17 ], [ %13, %12 ], [ %13, %17 ]
%38 = call i64 @fgets(i8* %7, i32 256, i32* %5)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %12
40: ; preds = %36, %0
%41 = phi i32 [ 0, %0 ], [ %37, %36 ]
%42 = call i32 @fclose(i32* %5)
%43 = call signext i8 (...) @getchar()
%44 = call i32 @srand(i8 signext %43)
%45 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%47 = call i64 @fgets(i8* %46, i32 20, i32* %45)
%48 = icmp eq i64 %47, 0
br i1 %48, label %82, label %49
49: ; preds = %40
%50 = sext i32 %41 to i64
br label %51
51: ; preds = %49, %78
%52 = phi i64 [ 0, %49 ], [ %79, %78 ]
%53 = call i32 @strlen(i8* %46)
%54 = icmp sgt i32 %53, 15
%55 = load i8, i8* %46
%56 = icmp ne i8 %55, 0
%57 = select i1 %54, i1 %56, i1 false
br i1 %57, label %58, label %78
58: ; preds = %51
%59 = call i32 @strlen(i8* %46)
%60 = add nsw i32 %59, -1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 10
%65 = srem i64 %52, %50
%66 = getelementptr inbounds [30 x i32*], [30 x i32*]* %1, i64 0, i64 %65
%67 = load i32*, i32** %66
%68 = call i32 (...) @rand()
%69 = srem i32 %68, 10
%70 = select i1 %64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0)
%71 = select i1 %64, i32 100000, i32 10
%72 = select i1 %64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0)
%73 = call i32 @fprintf(i32* %67, i8* %70, i64 %52, i32 %69, i8* %46)
%74 = call i32 (...) @rand()
%75 = srem i32 %74, %71
%76 = call i32 @fprintf(i32* %6, i8* %72, i64 %52, i32 %75, i8* %46)
%77 = add nsw i64 %52, 1
br label %78
78: ; preds = %58, %51
%79 = phi i64 [ %77, %58 ], [ %52, %51 ]
%80 = call i64 @fgets(i8* %46, i32 20, i32* %45)
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %51
82: ; preds = %78, %40
%83 = call i32 @fclose(i32* %45)
%84 = call i32 @fclose(i32* %6)
%85 = icmp sgt i32 %41, 0
br i1 %85, label %86, label %88
86: ; preds = %82
%87 = zext i32 %41 to i64
br label %89
88: ; preds = %89, %82
ret i32 0
89: ; preds = %86, %89
%90 = phi i64 [ 0, %86 ], [ %94, %89 ]
%91 = getelementptr inbounds [30 x i32*], [30 x i32*]* %1, i64 0, i64 %90
%92 = load i32*, i32** %91
%93 = call i32 @fclose(i32* %92)
%94 = add nuw nsw i64 %90, 1
%95 = icmp eq i64 %94, %87
br i1 %95, label %88, label %89
}