#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ get_buildno_ptr(char **, char **);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
void update_prop_file(char *filename, int rev) {
  char line[512];
  char fileout[128];
  char *out;
  char *outComment;
  char *outVersion;
  char *outFileVersion;
  FILE *fsource;
  FILE *fdest;
  if (filename == NULL || strlen(filename) == 0) {
    return;
  }
  if ((fsource = fopen(filename, "r+")) == NULL) {
    fprintf(stderr, "Failed to open output file '%s'\n", filename);
    return;
  }
  sprintf(fileout, "%s.tmp", filename);
  if ((fdest = fopen(fileout, "w")) == NULL) {
    fprintf(stderr, "Failed to create output file '%s'\n", fileout);
    fclose(fsource);
    return;
  }
  while ((out = fgets(line, 512, fsource)) != NULL) {
    outComment = strstr(line, "//");
    outVersion = strstr(line, "AssemblyVersion");
    outFileVersion = strstr(line, "AssemblyFileVersion");
    if (outVersion == NULL && outFileVersion == NULL) {
      fputs(line, fdest);
      continue;
    }
    if (outVersion != NULL) {
      if (outComment == NULL || outComment > outVersion) {
        char *start, *stop;
        char buffer[512];
        start = outVersion + strlen("AssemblyVersion") + 2;
        stop = start + strlen(start) - 1;
        get_buildno_ptr(&start, &stop);
        strcpy(buffer, stop);
        sprintf(start, "%i%s", rev, buffer);
        fputs(line, fdest);
      } else {
        fputs(line, fdest);
        continue;
      }
    }
    if (outFileVersion != NULL) {
      if (outComment == NULL || outComment > outFileVersion) {
        char *start, *stop;
        char buffer[512];
        start = outFileVersion + strlen("AssemblyFileVersion") + 2;
        stop = start + strlen(start) - 1;
        get_buildno_ptr(&start, &stop);
        strcpy(buffer, stop);
        sprintf(start, "%i%s", rev, buffer);
        fputs(line, fdest);
      } else {
        fputs(line, fdest);
        continue;
      }
    }
  }
  fclose(fsource);
  fclose(fdest);
  remove(filename);
  rename(fileout, filename);
  (void)out;
}


x86 assembly (clang, -O0):
<update_prop_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x700,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ef <update_prop_file+0x2f>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%eax
jne    11f4 <update_prop_file+0x34>
jmp    15a7 <update_prop_file+0x3e7>
mov    -0x8(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x2b8(%rbp)
cmp    $0x0,%rax
jne    1233 <update_prop_file+0x73>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdda(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    15a7 <update_prop_file+0x3e7>
lea    -0x290(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
lea    -0x290(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x2c0(%rbp)
cmp    $0x0,%rax
jne    129d <update_prop_file+0xdd>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    -0x290(%rbp),%rdx
lea    0xda6(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x2b8(%rbp),%rdi
call   1050 <fclose@plt>
jmp    15a7 <update_prop_file+0x3e7>
jmp    12a2 <update_prop_file+0xe2>
lea    -0x210(%rbp),%rdi
mov    -0x2b8(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
mov    %rax,-0x298(%rbp)
cmp    $0x0,%rax
je     1576 <update_prop_file+0x3b6>
lea    -0x210(%rbp),%rdi
lea    0xd77(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x2a0(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x2a8(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xd56(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x2b0(%rbp)
cmpq   $0x0,-0x2a8(%rbp)
jne    134d <update_prop_file+0x18d>
cmpq   $0x0,-0x2b0(%rbp)
jne    134d <update_prop_file+0x18d>
lea    -0x210(%rbp),%rdi
mov    -0x2c0(%rbp),%rsi
call   1080 <fputs@plt>
jmp    12a2 <update_prop_file+0xe2>
cmpq   $0x0,-0x2a8(%rbp)
je     145f <update_prop_file+0x29f>
cmpq   $0x0,-0x2a0(%rbp)
je     137d <update_prop_file+0x1bd>
mov    -0x2a0(%rbp),%rax
cmp    -0x2a8(%rbp),%rax
jbe    1442 <update_prop_file+0x282>
mov    -0x2a8(%rbp),%rax
mov    %rax,-0x6f0(%rbp)
lea    0xcc1(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x6f0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x2,%rax
mov    %rax,-0x2c8(%rbp)
mov    -0x2c8(%rbp),%rax
mov    %rax,-0x6e8(%rbp)
mov    -0x2c8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x6e8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x2d0(%rbp)
lea    -0x2c8(%rbp),%rdi
lea    -0x2d0(%rbp),%rsi
call   1070 <get_buildno_ptr@plt>
lea    -0x4d0(%rbp),%rdi
mov    -0x2d0(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x2c8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x4d0(%rbp),%rcx
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x2c0(%rbp),%rsi
call   1080 <fputs@plt>
jmp    145a <update_prop_file+0x29a>
lea    -0x210(%rbp),%rdi
mov    -0x2c0(%rbp),%rsi
call   1080 <fputs@plt>
jmp    12a2 <update_prop_file+0xe2>
jmp    145f <update_prop_file+0x29f>
cmpq   $0x0,-0x2b0(%rbp)
je     1571 <update_prop_file+0x3b1>
cmpq   $0x0,-0x2a0(%rbp)
je     148f <update_prop_file+0x2cf>
mov    -0x2a0(%rbp),%rax
cmp    -0x2b0(%rbp),%rax
jbe    1554 <update_prop_file+0x394>
mov    -0x2b0(%rbp),%rax
mov    %rax,-0x700(%rbp)
lea    0xbbf(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x700(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x2,%rax
mov    %rax,-0x4d8(%rbp)
mov    -0x4d8(%rbp),%rax
mov    %rax,-0x6f8(%rbp)
mov    -0x4d8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x6f8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x4e0(%rbp)
lea    -0x4d8(%rbp),%rdi
lea    -0x4e0(%rbp),%rsi
call   1070 <get_buildno_ptr@plt>
lea    -0x6e0(%rbp),%rdi
mov    -0x4e0(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x4d8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x6e0(%rbp),%rcx
lea    0xb42(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x2c0(%rbp),%rsi
call   1080 <fputs@plt>
jmp    156c <update_prop_file+0x3ac>
lea    -0x210(%rbp),%rdi
mov    -0x2c0(%rbp),%rsi
call   1080 <fputs@plt>
jmp    12a2 <update_prop_file+0xe2>
jmp    1571 <update_prop_file+0x3b1>
jmp    12a2 <update_prop_file+0xe2>
mov    -0x2b8(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x2c0(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x8(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x290(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10c0 <rename@plt>
add    $0x700,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_prop_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4b8,%rsp
test   %rdi,%rdi
je     1489 <update_prop_file+0x2c9>
mov    %esi,%r13d
mov    %rdi,%rbp
call   1060 <strlen@plt>
test   %eax,%eax
je     1489 <update_prop_file+0x2c9>
lea    0xe0c(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     143c <update_prop_file+0x27c>
mov    %rax,0x20(%rsp)
lea    0xe13(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xe01(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1465 <update_prop_file+0x2a5>
mov    %rbp,0x28(%rsp)
lea    0x2b0(%rsp),%rdi
mov    $0x200,%esi
mov    0x20(%rsp),%rbx
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     140e <update_prop_file+0x24e>
lea    0x2b0(%rsp),%rbp
jmp    1316 <update_prop_file+0x156>
lea    0xde7(%rip),%rdi
call   1060 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
lea    (%r14,%rax,1),%rdi
add    $0x2,%rdi
mov    %rdi,0x18(%rsp)
call   1060 <strlen@plt>
cltq
add    %rbx,%rax
add    $0x1,%rax
mov    0x20(%rsp),%rbx
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <get_buildno_ptr@plt>
mov    0x10(%rsp),%rsi
lea    0xb0(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x18(%rsp),%rdi
lea    0xd9b(%rip),%rsi
mov    %r13d,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
call   1080 <fputs@plt>
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     140e <update_prop_file+0x24e>
mov    %rbp,%rdi
lea    0xd30(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,%r12
mov    %rbp,%rdi
lea    0xd21(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,%r15
mov    %rbp,%rdi
lea    0xd1f(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,%r14
mov    %r15,%rax
or     %r14,%rax
je     12f0 <update_prop_file+0x130>
test   %r15,%r15
je     13ee <update_prop_file+0x22e>
test   %r12,%r12
je     1367 <update_prop_file+0x1a7>
cmp    %r15,%r12
jbe    12f0 <update_prop_file+0x130>
lea    0xce5(%rip),%rdi
call   1060 <strlen@plt>
cltq
mov    %r13d,%ebx
lea    (%r15,%rax,1),%r13
lea    (%r15,%rax,1),%rdi
add    $0x2,%rdi
mov    %rdi,0x18(%rsp)
call   1060 <strlen@plt>
cltq
add    %r13,%rax
add    $0x1,%rax
mov    %ebx,%r13d
mov    0x20(%rsp),%rbx
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1070 <get_buildno_ptr@plt>
mov    0x10(%rsp),%rsi
lea    0xb0(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
mov    0x18(%rsp),%rdi
lea    0xca3(%rip),%rsi
mov    %r13d,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
mov    0x8(%rsp),%rsi
call   1080 <fputs@plt>
test   %r14,%r14
je     12fd <update_prop_file+0x13d>
test   %r12,%r12
je     1275 <update_prop_file+0xb5>
cmp    %r14,%r12
jbe    12f0 <update_prop_file+0x130>
jmp    1275 <update_prop_file+0xb5>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x28(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <remove@plt>
lea    0x30(%rsp),%rdi
mov    %rbx,%rsi
call   10c0 <rename@plt>
jmp    1489 <update_prop_file+0x2c9>
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
lea    0xbb7(%rip),%rsi
mov    %rbp,%rdx
add    $0x4b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <fprintf@plt>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
lea    0xbb8(%rip),%rsi
lea    0x30(%rsp),%rdx
call   10a0 <fprintf@plt>
mov    0x20(%rsp),%rdi
call   1050 <fclose@plt>
add    $0x4b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Failed to open output file '%s'\0A\00"
@.str.2 = [7 x i8] c"%s.tmp\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [35 x i8] c"Failed to create output file '%s'\0A\00"
@.str.5 = [3 x i8] c"//\00"
@.str.6 = [16 x i8] c"AssemblyVersion\00"
@.str.7 = [20 x i8] c"AssemblyFileVersion\00"
@.str.8 = [5 x i8] c"%i%s\00"
define void @update_prop_file(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [512 x i8]
%6 = alloca [128 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [512 x i8]
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca [512 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%19 = load i8*, i8** %3
%20 = icmp eq i8* %19, null
br i1 %20, label %25, label %21
21: ; preds = %2
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21, %2
br label %157
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %28, i32** %11
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %3
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %157
34: ; preds = %26
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%36 = load i8*, i8** %3
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %39, i32** %12
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %47
41: ; preds = %34
%42 = load i32, i32* @stderr
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %11
%46 = call i32 @fclose(i32* %45)
br label %157
47: ; preds = %34
br label %48
48: ; preds = %145, %140, %102, %65, %47
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%50 = load i32*, i32** %11
%51 = call i8* @fgets(i8* %49, i32 512, i32* %50)
store i8* %51, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %146
53: ; preds = %48
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%55 = call i8* @strstr(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i8* %55, i8** %8
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%57 = call i8* @strstr(i8* %56, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
store i8* %57, i8** %9
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%59 = call i8* @strstr(i8* %58, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
store i8* %59, i8** %10
%60 = load i8*, i8** %9
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %69
62: ; preds = %53
%63 = load i8*, i8** %10
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%67 = load i32*, i32** %12
%68 = call i32 @fputs(i8* %66, i32* %67)
br label %48
69: ; preds = %62, %53
%70 = load i8*, i8** %9
%71 = icmp ne i8* %70, null
br i1 %71, label %72, label %107
72: ; preds = %69
%73 = load i8*, i8** %8
%74 = icmp eq i8* %73, null
br i1 %74, label %79, label %75
75: ; preds = %72
%76 = load i8*, i8** %8
%77 = load i8*, i8** %9
%78 = icmp ugt i8* %76, %77
br i1 %78, label %79, label %102
79: ; preds = %75, %72
%80 = load i8*, i8** %9
%81 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = getelementptr inbounds i8, i8* %83, i64 2
store i8* %84, i8** %13
%85 = load i8*, i8** %13
%86 = load i8*, i8** %13
%87 = call i32 @strlen(i8* %86)
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %85, i64 %88
%90 = getelementptr inbounds i8, i8* %89, i64 -1
store i8* %90, i8** %14
%91 = call i32 @get_buildno_ptr(i8** %13, i8** %14)
%92 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 0
%93 = load i8*, i8** %14
%94 = call i32 @strcpy(i8* %92, i8* %93)
%95 = load i8*, i8** %13
%96 = load i32, i32* %4
%97 = getelementptr inbounds [512 x i8], [512 x i8]* %15, i64 0, i64 0
%98 = call i32 (i8*, i8*, ...) @sprintf(i8* %95, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %96, i8* %97)
%99 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%100 = load i32*, i32** %12
%101 = call i32 @fputs(i8* %99, i32* %100)
br label %106
102: ; preds = %75
%103 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%104 = load i32*, i32** %12
%105 = call i32 @fputs(i8* %103, i32* %104)
br label %48
106: ; preds = %79
br label %107
107: ; preds = %106, %69
%108 = load i8*, i8** %10
%109 = icmp ne i8* %108, null
br i1 %109, label %110, label %145
110: ; preds = %107
%111 = load i8*, i8** %8
%112 = icmp eq i8* %111, null
br i1 %112, label %117, label %113
113: ; preds = %110
%114 = load i8*, i8** %8
%115 = load i8*, i8** %10
%116 = icmp ugt i8* %114, %115
br i1 %116, label %117, label %140
117: ; preds = %113, %110
%118 = load i8*, i8** %10
%119 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = getelementptr inbounds i8, i8* %121, i64 2
store i8* %122, i8** %16
%123 = load i8*, i8** %16
%124 = load i8*, i8** %16
%125 = call i32 @strlen(i8* %124)
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %123, i64 %126
%128 = getelementptr inbounds i8, i8* %127, i64 -1
store i8* %128, i8** %17
%129 = call i32 @get_buildno_ptr(i8** %16, i8** %17)
%130 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%131 = load i8*, i8** %17
%132 = call i32 @strcpy(i8* %130, i8* %131)
%133 = load i8*, i8** %16
%134 = load i32, i32* %4
%135 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%136 = call i32 (i8*, i8*, ...) @sprintf(i8* %133, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %134, i8* %135)
%137 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%138 = load i32*, i32** %12
%139 = call i32 @fputs(i8* %137, i32* %138)
br label %144
140: ; preds = %113
%141 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%142 = load i32*, i32** %12
%143 = call i32 @fputs(i8* %141, i32* %142)
br label %48
144: ; preds = %117
br label %145
145: ; preds = %144, %107
br label %48
146: ; preds = %48
%147 = load i32*, i32** %11
%148 = call i32 @fclose(i32* %147)
%149 = load i32*, i32** %12
%150 = call i32 @fclose(i32* %149)
%151 = load i8*, i8** %3
%152 = call i32 @remove(i8* %151)
%153 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%154 = load i8*, i8** %3
%155 = call i32 @rename(i8* %153, i8* %154)
%156 = load i8*, i8** %7
br label %157
157: ; preds = %146, %41, %30, %25
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Failed to open output file '%s'\0A\00"
@.str.2 = [7 x i8] c"%s.tmp\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [35 x i8] c"Failed to create output file '%s'\0A\00"
@.str.5 = [3 x i8] c"//\00"
@.str.6 = [16 x i8] c"AssemblyVersion\00"
@.str.7 = [20 x i8] c"AssemblyFileVersion\00"
@.str.8 = [5 x i8] c"%i%s\00"
define void @update_prop_file(i8* %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = alloca [128 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [512 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [512 x i8]
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = icmp eq i8* %0, null
br i1 %13, label %102, label %14
14: ; preds = %2
%15 = tail call i32 @strlen(i8* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %102, label %17
17: ; preds = %14
%18 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %102
23: ; preds = %17
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%25 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %37, label %27
27: ; preds = %23
%28 = call i8* @fgets(i8* %11, i32 512, i32* %18)
%29 = icmp eq i8* %28, null
br i1 %29, label %97, label %30
30: ; preds = %27
%31 = bitcast i8** %5 to i8*
%32 = bitcast i8** %6 to i8*
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%34 = bitcast i8** %8 to i8*
%35 = bitcast i8** %9 to i8*
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
br label %41
37: ; preds = %23
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%40 = call i32 @fclose(i32* %18)
br label %102
41: ; preds = %30, %50
%42 = call i8* @strstr(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%43 = call i8* @strstr(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%44 = call i8* @strstr(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i8* %43, null
%46 = icmp eq i8* %44, null
%47 = select i1 %45, i1 %46, i1 false
br i1 %47, label %48, label %53
48: ; preds = %41
%49 = call i32 @fputs(i8* %11, i32* %25)
br label %50
50: ; preds = %75, %80, %48, %73, %95
%51 = call i8* @fgets(i8* %11, i32 512, i32* %18)
%52 = icmp eq i8* %51, null
br i1 %52, label %97, label %41
53: ; preds = %41
br i1 %45, label %75, label %54
54: ; preds = %53
%55 = icmp eq i8* %42, null
%56 = icmp ugt i8* %42, %43
%57 = select i1 %55, i1 true, i1 %56
br i1 %57, label %58, label %73
58: ; preds = %54
%59 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %43, i64 2
%62 = getelementptr inbounds i8, i8* %61, i64 %60
store i8* %62, i8** %5
%63 = call i32 @strlen(i8* %62)
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 -1
%66 = getelementptr inbounds i8, i8* %65, i64 %64
store i8* %66, i8** %6
%67 = call i32 @get_buildno_ptr(i8** %5, i8** %6)
%68 = load i8*, i8** %6
%69 = call i32 @strcpy(i8* %33, i8* %68)
%70 = load i8*, i8** %5
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %70, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %1, i8* %33)
%72 = call i32 @fputs(i8* %11, i32* %25)
br label %75
73: ; preds = %54
%74 = call i32 @fputs(i8* %11, i32* %25)
br label %50
75: ; preds = %58, %53
br i1 %46, label %50, label %76
76: ; preds = %75
%77 = icmp eq i8* %42, null
%78 = icmp ugt i8* %42, %44
%79 = select i1 %77, i1 true, i1 %78
br i1 %79, label %80, label %95
80: ; preds = %76
%81 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %44, i64 2
%84 = getelementptr inbounds i8, i8* %83, i64 %82
store i8* %84, i8** %8
%85 = call i32 @strlen(i8* %84)
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 -1
%88 = getelementptr inbounds i8, i8* %87, i64 %86
store i8* %88, i8** %9
%89 = call i32 @get_buildno_ptr(i8** %8, i8** %9)
%90 = load i8*, i8** %9
%91 = call i32 @strcpy(i8* %36, i8* %90)
%92 = load i8*, i8** %8
%93 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %92, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %1, i8* %36)
%94 = call i32 @fputs(i8* %11, i32* %25)
br label %50
95: ; preds = %76
%96 = call i32 @fputs(i8* %11, i32* %25)
br label %50
97: ; preds = %50, %27
%98 = call i32 @fclose(i32* %18)
%99 = call i32 @fclose(i32* %25)
%100 = call i32 @remove(i8* %0)
%101 = call i32 @rename(i8* %12, i8* %0)
br label %102
102: ; preds = %2, %14, %97, %37, %20
ret void
}