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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ rename(char *, char const *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strstr(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ unlink(char const *);
int main(int argc, const char *argv[]) {
  char buf[256];
  char _tmpfile[1024];
  FILE *fd = NULL;
  FILE *fd2 = NULL;
  int line_found = 0;
  char *vstr = NULL;
  if (argc < 2) {
    fprintf(stderr, "%s [FILE]\n", argv[0]);
    return 1;
  }
  if ((fd = fopen(argv[1], "r+")) == NULL) {
    perror("Cannot open file\n");
    return 1;
  }
  strcpy(_tmpfile, argv[1]);
  strcat(_tmpfile, ".tmp");
  if ((fd2 = fopen(_tmpfile, "w+")) == NULL) {
    perror("Cannot open file\n");
    fclose(fd);
    return 1;
  }
  int found = 0;
  while (fgets(buf, sizeof(buf) - 10, fd)) {
    ++line_found;
    char *pch = strtok(buf, " \t");
    while (pch != NULL) {
      if (found) {
        vstr = malloc(sizeof(pch) + 1);
        strcpy(vstr, pch);
        goto replace;
      }
      if (!strcmp(pch, "VERSION_PATCH")) {
        found = 1;
      }
      pch = strtok(NULL, " \t");
    }
  }
replace:
  rewind(fd);
  int ver = atoi(vstr);
  ver += 1;
  fprintf(stdout,
          "VERSION_PATCH"
          " %d => %d\n",
          ver - 1, ver);
  int lcnt = 0;
  while (fgets(buf, sizeof(buf) - 10, fd)) {
    if (++lcnt == line_found) {
      char *pch = strstr(buf, vstr);
      sprintf(pch, "%d\n", ver);
    }
    fputs(buf, fd2);
  }
  free(vstr);
  fclose(fd);
  fclose(fd2);
  unlink(argv[1]);
  rename(_tmpfile, argv[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x550,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x518(%rbp)
movq   $0x0,-0x520(%rbp)
movl   $0x0,-0x524(%rbp)
movq   $0x0,-0x530(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1298 <main+0x78>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    155a <main+0x33a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd64(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x518(%rbp)
cmp    $0x0,%rax
jne    12d5 <main+0xb5>
lea    0xd4a(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    155a <main+0x33a>
lea    -0x510(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <strcpy@plt>
lea    -0x510(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   1120 <strcat@plt>
lea    -0x510(%rbp),%rdi
lea    0xd1b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x520(%rbp)
cmp    $0x0,%rax
jne    1344 <main+0x124>
lea    0xce7(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x518(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    155a <main+0x33a>
movl   $0x0,-0x534(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x518(%rbp),%rdx
mov    $0xf6,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1424 <main+0x204>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xc9b(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x540(%rbp)
cmpq   $0x0,-0x540(%rbp)
je     141f <main+0x1ff>
cmpl   $0x0,-0x534(%rbp)
je     13dd <main+0x1bd>
mov    $0x9,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x530(%rbp)
mov    -0x530(%rbp),%rdi
mov    -0x540(%rbp),%rsi
call   1050 <strcpy@plt>
jmp    1429 <main+0x209>
mov    -0x540(%rbp),%rdi
lea    0xc40(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1403 <main+0x1e3>
movl   $0x1,-0x534(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xc1a(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x540(%rbp)
jmp    1399 <main+0x179>
jmp    134e <main+0x12e>
jmp    1429 <main+0x209>
mov    -0x518(%rbp),%rdi
call   1070 <rewind@plt>
mov    -0x530(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x544(%rbp)
mov    -0x544(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x544(%rbp)
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
mov    -0x544(%rbp),%edx
sub    $0x1,%edx
mov    -0x544(%rbp),%ecx
lea    0xbc4(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x0,-0x548(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x518(%rbp),%rdx
mov    $0xf6,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     150e <main+0x2ee>
mov    -0x548(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x548(%rbp)
cmp    -0x524(%rbp),%eax
jne    14f6 <main+0x2d6>
lea    -0x110(%rbp),%rdi
mov    -0x530(%rbp),%rsi
call   1140 <strstr@plt>
mov    %rax,-0x550(%rbp)
mov    -0x550(%rbp),%rdi
mov    -0x544(%rbp),%edx
lea    0xb5c(%rip),%rsi
call   1130 <sprintf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x520(%rbp),%rsi
call   1080 <fputs@plt>
jmp    1486 <main+0x266>
mov    -0x530(%rbp),%rdi
call   1030 <free@plt>
mov    -0x518(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x520(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <unlink@plt>
lea    -0x510(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1100 <rename@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x550,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x518,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     125e <main+0x3e>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xdb3(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%eax
jmp    146d <main+0x24d>
mov    0x8(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     147f <main+0x25f>
mov    %rax,%r12
mov    0x8(%rbp),%rsi
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcpy@plt>
lea    0xd8b(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xd81(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1492 <main+0x272>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0xf6,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1389 <main+0x169>
mov    %rbx,(%rsp)
lea    0xd45(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xd3c(%rip),%r13
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    131e <main+0xfe>
cs nopw 0x0(%rax,%rax,1)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xf6,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     14ad <main+0x28d>
add    $0x1,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
je     1300 <main+0xe0>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebp,%ebp
jne    136b <main+0x14b>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
xor    %edi,%edi
mov    %r14,%rsi
call   10f0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1340 <main+0x120>
jmp    1300 <main+0xe0>
mov    $0x9,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    (%rsp),%rbx
jmp    138e <main+0x16e>
xor    %r15d,%r15d
xor    %ebp,%ebp
mov    %r12,%rdi
call   1070 <rewind@plt>
mov    %rbp,%r13
mov    %rbp,%rdi
call   1110 <atoi@plt>
lea    0x1(%rax),%ebp
mov    0x2c2d(%rip),%rcx
mov    (%rcx),%edi
lea    0xc85(%rip),%rsi
mov    %eax,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0x10(%rsp),%rdi
mov    $0xf6,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1434 <main+0x214>
add    $0xffffffff,%r15d
lea    0x10(%rsp),%r14
jmp    1410 <main+0x1f0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
mov    %r14,%rdi
mov    $0xf6,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1434 <main+0x214>
sub    $0x1,%r15d
jae    13f0 <main+0x1d0>
mov    %r14,%rdi
mov    %r13,%rsi
call   1140 <strstr@plt>
mov    %rax,%rdi
lea    0xc22(%rip),%rsi
mov    %ebp,%edx
call   1130 <sprintf@plt>
jmp    13f0 <main+0x1d0>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rbx
mov    0x8(%rbx),%rdi
call   1040 <unlink@plt>
mov    0x8(%rbx),%rsi
lea    0x110(%rsp),%rdi
call   1100 <rename@plt>
xor    %eax,%eax
add    $0x518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb88(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%eax
jmp    146d <main+0x24d>
lea    0xb75(%rip),%rdi
call   10e0 <perror@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    $0x1,%eax
jmp    146d <main+0x24d>
mov    (%rsp),%rbx
jmp    138c <main+0x16c>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"%s [FILE]\0A\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [18 x i8] c"Cannot open file\0A\00"
@.str.3 = [5 x i8] c".tmp\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [3 x i8] c" \09\00"
@.str.6 = [14 x i8] c"VERSION_PATCH\00"
@stdout = global i32 0
@.str.7 = [24 x i8] c"VERSION_PATCH %d => %d\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %8
store i32* null, i32** %9
store i32 0, i32* %10
store i8* null, i8** %11
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 1, i32* %3
br label %128
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %8
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %128
33: ; preds = %25
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @strcpy(i8* %34, i8* %37)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %42, i32** %9
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %48
44: ; preds = %33
%45 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32*, i32** %8
%47 = call i32 @fclose(i32* %46)
store i32 1, i32* %3
br label %128
48: ; preds = %33
store i32 0, i32* %12
br label %49
49: ; preds = %77, %48
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%51 = load i32*, i32** %8
%52 = call i64 @fgets(i8* %50, i32 246, i32* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %78
54: ; preds = %49
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%58 = call i8* @strtok(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i8* %58, i8** %13
br label %59
59: ; preds = %75, %54
%60 = load i8*, i8** %13
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %77
62: ; preds = %59
%63 = load i32, i32* %12
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = call i8* @malloc(i32 9)
store i8* %66, i8** %11
%67 = load i8*, i8** %11
%68 = load i8*, i8** %13
%69 = call i32 @strcpy(i8* %67, i8* %68)
br label %79
70: ; preds = %62
%71 = load i8*, i8** %13
%72 = call i32 @strcmp(i8* %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%73 = icmp ne i32 %72, 0
br i1 %73, label %75, label %74
74: ; preds = %70
store i32 1, i32* %12
br label %75
75: ; preds = %74, %70
%76 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i8* %76, i8** %13
br label %59
77: ; preds = %59
br label %49
78: ; preds = %49
br label %79
79: ; preds = %78, %65
%80 = load i32*, i32** %8
%81 = call i32 @rewind(i32* %80)
%82 = load i8*, i8** %11
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %14
%84 = load i32, i32* %14
%85 = add nsw i32 %84, 1
store i32 %85, i32* %14
%86 = load i32, i32* @stdout
%87 = load i32, i32* %14
%88 = sub nsw i32 %87, 1
%89 = load i32, i32* %14
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %88, i32 %89)
store i32 0, i32* %15
br label %91
91: ; preds = %108, %79
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%93 = load i32*, i32** %8
%94 = call i64 @fgets(i8* %92, i32 246, i32* %93)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %112
96: ; preds = %91
%97 = load i32, i32* %15
%98 = add nsw i32 %97, 1
store i32 %98, i32* %15
%99 = load i32, i32* %10
%100 = icmp eq i32 %98, %99
br i1 %100, label %101, label %108
101: ; preds = %96
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%103 = load i8*, i8** %11
%104 = call i8* @strstr(i8* %102, i8* %103)
store i8* %104, i8** %16
%105 = load i8*, i8** %16
%106 = load i32, i32* %14
%107 = call i32 @sprintf(i8* %105, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %106)
br label %108
108: ; preds = %101, %96
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%110 = load i32*, i32** %9
%111 = call i32 @fputs(i8* %109, i32* %110)
br label %91
112: ; preds = %91
%113 = load i8*, i8** %11
%114 = call i32 @free(i8* %113)
%115 = load i32*, i32** %8
%116 = call i32 @fclose(i32* %115)
%117 = load i32*, i32** %9
%118 = call i32 @fclose(i32* %117)
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 1
%121 = load i8*, i8** %120
%122 = call i32 @unlink(i8* %121)
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%124 = load i8**, i8*** %5
%125 = getelementptr inbounds i8*, i8** %124, i64 1
%126 = load i8*, i8** %125
%127 = call i32 @rename(i8* %123, i8* %126)
store i32 0, i32* %3
br label %128
128: ; preds = %112, %44, %31, %19
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"%s [FILE]\0A\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [18 x i8] c"Cannot open file\0A\00"
@.str.3 = [5 x i8] c".tmp\00"
@.str.4 = [3 x i8] c"w+\00"
@.str.5 = [3 x i8] c" \09\00"
@.str.6 = [14 x i8] c"VERSION_PATCH\00"
@stdout = global i32 0
@.str.7 = [24 x i8] c"VERSION_PATCH %d => %d\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [256 x i8], [256 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 %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %83
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %83
19: ; preds = %12
%20 = load i8*, i8** %13
%21 = call i32 @strcpy(i8* %6, i8* %20)
%22 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = call i64 @fgets(i8* %5, i32 246, i32* %15)
%27 = icmp eq i64 %26, 0
br i1 %27, label %54, label %35
28: ; preds = %19
%29 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @fclose(i32* %15)
br label %83
31: ; preds = %48, %35
%32 = phi i32 [ %36, %35 ], [ %51, %48 ]
%33 = call i64 @fgets(i8* %5, i32 246, i32* %15)
%34 = icmp eq i64 %33, 0
br i1 %34, label %54, label %35
35: ; preds = %25, %31
%36 = phi i32 [ %32, %31 ], [ 0, %25 ]
%37 = phi i32 [ %38, %31 ], [ 0, %25 ]
%38 = add nuw nsw i32 %37, 1
%39 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i8* %39, null
br i1 %40, label %31, label %41
41: ; preds = %35, %48
%42 = phi i8* [ %52, %48 ], [ %39, %35 ]
%43 = phi i32 [ %51, %48 ], [ %36, %35 ]
%44 = icmp eq i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %41
%46 = call dereferenceable_or_null(9) i8* @malloc(i32 9)
%47 = call i32 @strcpy(i8* %46, i8* %42)
br label %54
48: ; preds = %41
%49 = call i32 @strcmp(i8* %42, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i32 %49, 0
%51 = zext i1 %50 to i32
%52 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i8* %52, null
br i1 %53, label %31, label %41
54: ; preds = %31, %25, %45
%55 = phi i32 [ %38, %45 ], [ 0, %25 ], [ %38, %31 ]
%56 = phi i8* [ %46, %45 ], [ null, %25 ], [ null, %31 ]
%57 = call i32 @rewind(i32* %15)
%58 = call i32 @atoi(i8* %56)
%59 = add nsw i32 %58, 1
%60 = load i32, i32* @stdout
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %58, i32 %59)
%62 = call i64 @fgets(i8* %5, i32 246, i32* %15)
%63 = icmp eq i64 %62, 0
br i1 %63, label %75, label %64
64: ; preds = %54, %71
%65 = phi i32 [ %66, %71 ], [ 0, %54 ]
%66 = add nuw nsw i32 %65, 1
%67 = icmp eq i32 %66, %55
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = call i8* @strstr(i8* %5, i8* dereferenceable(1) %56)
%70 = call i32 @sprintf(i8* dereferenceable(1) %69, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %59)
br label %71
71: ; preds = %68, %64
%72 = call i32 @fputs(i8* %5, i32* %23)
%73 = call i64 @fgets(i8* %5, i32 246, i32* %15)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %64
75: ; preds = %71, %54
%76 = call i32 @free(i8* %56)
%77 = call i32 @fclose(i32* %15)
%78 = call i32 @fclose(i32* %23)
%79 = load i8*, i8** %13
%80 = call i32 @unlink(i8* %79)
%81 = load i8*, i8** %13
%82 = call i32 @rename(i8* %6, i8* %81)
br label %83
83: ; preds = %75, %28, %17, %8
%84 = phi i32 [ 1, %8 ], [ 1, %17 ], [ 1, %28 ], [ 0, %75 ]
ret i32 %84
}