#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void main(int argc, char *argv[]) {
  FILE *openme;
  char inbuf[512];
  int i, pb = 0, rb = 0, mi = 0, ma = 0;
  if (argc == 1)
    exit(-1);
  if ((openme = fopen(argv[1], "r+")) == NULL) {
    printf("error\n");
    exit(-1);
  }
  fscanf(openme, "%s %s %d\n", inbuf, inbuf, &pb);
  fscanf(openme, "%s %s %d\n", inbuf, inbuf, &rb);
  fscanf(openme, "%s %s %d\n", inbuf, inbuf, &mi);
  fscanf(openme, "%s %s %d\n", inbuf, inbuf, &ma);
  pb++;
  if (argc > 2)
    if (atoi(argv[2]) == 0)
      rb++;
  printf("new version = %d,%d,%d,%d", ma, mi, rb, pb);
  rewind(openme);
  fprintf(openme, "#define pb %d\n", pb);
  fprintf(openme, "#define rb %d\n", rb);
  fprintf(openme, "#define mi %d\n", mi);
  fprintf(openme, "#define ma %d\n", ma);
  fprintf(openme,
          "#define vFILEVERSION ma,mi,rb,pb\n#define vPRODUCTVERSION "
          "ma,mi,0,0\n#define vDISPFILEVERSION \"%d,%d,%d,%d\\0\"\n#define "
          "vSUBBUILD \"%d\\0\"\n",
          ma, mi, rb, pb, pb);
  fclose(openme);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x228(%rbp)
movl   $0x0,-0x22c(%rbp)
movl   $0x0,-0x230(%rbp)
movl   $0x0,-0x234(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    11ce <main+0x4e>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1208 <main+0x88>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xde9(%rip),%rsi
lea    -0x228(%rbp),%r8
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xdc4(%rip),%rsi
lea    -0x22c(%rbp),%r8
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xd9f(%rip),%rsi
lea    -0x230(%rbp),%r8
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xd7a(%rip),%rsi
lea    -0x234(%rbp),%r8
call   1060 <fscanf@plt>
mov    -0x228(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x228(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    12e0 <main+0x160>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
cmp    $0x0,%rax
jne    12db <main+0x15b>
mov    -0x22c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x22c(%rbp)
jmp    12e0 <main+0x160>
mov    -0x234(%rbp),%esi
mov    -0x230(%rbp),%edx
mov    -0x22c(%rbp),%ecx
mov    -0x228(%rbp),%r8d
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x18(%rbp),%rdi
mov    -0x228(%rbp),%edx
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x22c(%rbp),%edx
lea    0xd04(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x230(%rbp),%edx
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x234(%rbp),%edx
lea    0xcf2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x234(%rbp),%edx
mov    -0x230(%rbp),%ecx
mov    -0x22c(%rbp),%r8d
mov    -0x228(%rbp),%r9d
mov    -0x228(%rbp),%eax
lea    0xccf(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x220,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
cmp    $0x1,%edi
je     132a <main+0x19a>
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x8(%rsi),%rdi
lea    0xe27(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1334 <main+0x1a4>
mov    %rax,%rbx
lea    0xe12(%rip),%r12
lea    0x20(%rsp),%rbp
lea    0x14(%rsp),%r8
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
call   1070 <fscanf@plt>
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
call   1070 <fscanf@plt>
lea    0x1c(%rsp),%r8
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
call   1070 <fscanf@plt>
lea    0x18(%rsp),%r8
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
call   1070 <fscanf@plt>
mov    0x14(%rsp),%ebp
add    $0x1,%ebp
mov    %ebp,0x14(%rsp)
cmp    $0x3,%r15d
jl     1272 <main+0xe2>
mov    0x10(%r14),%rdi
call   10a0 <atoi@plt>
test   %rax,%rax
jne    1272 <main+0xe2>
addl   $0x1,0x10(%rsp)
mov    0x18(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xd88(%rip),%rdi
mov    %ebp,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <rewind@plt>
mov    0x14(%rsp),%edx
lea    0xd85(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x10(%rsp),%edx
lea    0xd7f(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x1c(%rsp),%edx
lea    0xd79(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x18(%rsp),%edx
lea    0xd73(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    %r9d,(%rsp)
lea    0xd5b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x220,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
lea    0xdae(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@.str.1 = [7 x i8] c"error\0A\00"
@.str.2 = [10 x i8] c"%s %s %d\0A\00"
@.str.3 = [26 x i8] c"new version = %d,%d,%d,%d\00"
@.str.4 = [15 x i8] c"#define pb %d\0A\00"
@.str.5 = [15 x i8] c"#define rb %d\0A\00"
@.str.6 = [15 x i8] c"#define mi %d\0A\00"
@.str.7 = [15 x i8] c"#define ma %d\0A\00"
@.str.8 = [134 x i8] c"#define vFILEVERSION ma,mi,rb,pb\0A#define vPRODUCTVERSION ma,mi,0,0\0A#define vDISPFILEVERSION \22%d,%d,%d,%d\\0\22\0A#define vSUBBUILD \22%d\\0\22\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [512 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %4
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %5
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %16
%26 = load i32*, i32** %5
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%29 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* %28, i32* %8)
%30 = load i32*, i32** %5
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%33 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32, i32* %9)
%34 = load i32*, i32** %5
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%37 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %36, i32* %10)
%38 = load i32*, i32** %5
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%41 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %40, i32* %11)
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
%44 = load i32, i32* %3
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %56
46: ; preds = %25
%47 = load i8**, i8*** %4
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i64 @atoi(i8* %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %46
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %55
55: ; preds = %52, %46
br label %56
56: ; preds = %55, %25
%57 = load i32, i32* %11
%58 = load i32, i32* %10
%59 = load i32, i32* %9
%60 = load i32, i32* %8
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %57, i32 %58, i32 %59, i32 %60)
%62 = load i32*, i32** %5
%63 = call i32 @rewind(i32* %62)
%64 = load i32*, i32** %5
%65 = load i32, i32* %8
%66 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = load i32*, i32** %5
%68 = load i32, i32* %9
%69 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = load i32*, i32** %5
%71 = load i32, i32* %10
%72 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %71)
%73 = load i32*, i32** %5
%74 = load i32, i32* %11
%75 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %74)
%76 = load i32*, i32** %5
%77 = load i32, i32* %11
%78 = load i32, i32* %10
%79 = load i32, i32* %9
%80 = load i32, i32* %8
%81 = load i32, i32* %8
%82 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.8, i64 0, i64 0), i32 %77, i32 %78, i32 %79, i32 %80, i32 %81)
%83 = load i32*, i32** %5
%84 = call i32 @fclose(i32* %83)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@.str.2 = [10 x i8] c"%s %s %d\0A\00"
@.str.3 = [26 x i8] c"new version = %d,%d,%d,%d\00"
@.str.4 = [15 x i8] c"#define pb %d\0A\00"
@.str.5 = [15 x i8] c"#define rb %d\0A\00"
@.str.6 = [15 x i8] c"#define mi %d\0A\00"
@.str.7 = [15 x i8] c"#define ma %d\0A\00"
@.str.8 = [134 x i8] c"#define vFILEVERSION ma,mi,rb,pb\0A#define vPRODUCTVERSION ma,mi,0,0\0A#define vDISPFILEVERSION \22%d,%d,%d,%d\\0\22\0A#define vSUBBUILD \22%d\\0\22\0A\00"
@str = [6 x i8] c"error\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%13 = icmp eq i32 %0, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 -1)
unreachable
24: ; preds = %16
%25 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8, i32* %4)
%26 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8, i32* %5)
%27 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8, i32* %6)
%28 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8, i32* %7)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
%31 = icmp sgt i32 %0, 2
br i1 %31, label %32, label %40
32: ; preds = %24
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = call i64 @atoi(i8* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %32, %37, %24
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = load i32, i32* %5
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42, i32 %43, i32 %30)
%45 = call i32 @rewind(i32* %19)
%46 = load i32, i32* %4
%47 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %5
%49 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %6
%51 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %7
%53 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %7
%55 = load i32, i32* %6
%56 = load i32, i32* %5
%57 = load i32, i32* %4
%58 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.8, i64 0, i64 0), i32 %54, i32 %55, i32 %56, i32 %57, i32 %57)
%59 = call i32 @fclose(i32* %19)
ret void
}