#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 */
float atof(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ *stderr;
main(int argc, char *argv[]) {
  FILE *frun, *foldparam, *fnewparam;
  int i, j, ncol, nrow;
  int runflag;
  char tmpstr[512];
  float value;
  float param;
  if (argc != 5) {
    fprintf(stderr,
            "Usage: %s <run mask> <old param file> <new param file> <value>\n",
            argv[0]);
    fprintf(stderr, "\tThis program sets the activated grid cells in the old "
                    "parameter file to the given value, and writes the results "
                    "to the new parameter file.  Activated cells have values "
                    "other than 0 in the run mask file.\n");
    exit(0);
  }
  if ((frun = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "ERROR: Unable to open %s\n", argv[1]);
    exit(0);
  }
  if ((foldparam = fopen(argv[2], "r")) == NULL) {
    fprintf(stderr, "ERROR: Unable to open %s\n", argv[2]);
    exit(0);
  }
  if ((fnewparam = fopen(argv[3], "w")) == NULL) {
    fprintf(stderr, "ERROR: Unable to open %s\n", argv[3]);
    exit(0);
  }
  value = atof(argv[4]);
  for (i = 0; i < 6; i++) {
    fgets(tmpstr, 512, frun);
    fgets(tmpstr, 512, foldparam);
    if (i == 0)
      sscanf(tmpstr, "%*s %i", &ncol);
    if (i == 1)
      sscanf(tmpstr, "%*s %i", &nrow);
    fprintf(fnewparam, "%s", tmpstr);
  }
  for (i = 0; i < nrow; i++) {
    for (j = 0; j < ncol; j++) {
      fscanf(frun, "%i", &runflag);
      fscanf(foldparam, "%f", &param);
      if (runflag != 0) {
        fprintf(fnewparam, "%f", value);
      } else {
        fprintf(fnewparam, "%f", param);
      }
      if (j == ncol - 1)
        fprintf(fnewparam, "\n");
      else
        fprintf(fnewparam, " ");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11d1 <main+0x61>
mov    0x2e46(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf2d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    121a <main+0xaa>
mov    0x2de6(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xf03(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xee4(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1263 <main+0xf3>
mov    0x2d9d(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xeb7(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12ac <main+0x13c>
mov    0x2d54(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x244(%rbp)
ff
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    1365 <main+0x1f5>
lea    -0x240(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    131d <main+0x1ad>
lea    -0x240(%rbp),%rdi
lea    0xe17(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1070 <sscanf@plt>
cmpl   $0x1,-0x2c(%rbp)
jne    133e <main+0x1ce>
lea    -0x240(%rbp),%rdi
lea    0xdf6(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x240(%rbp),%rdx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c8 <main+0x158>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1465 <main+0x2f5>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1452 <main+0x2e2>
mov    -0x18(%rbp),%rdi
lea    0xd99(%rip),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd89(%rip),%rsi
lea    -0x248(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
cmpl   $0x0,-0x3c(%rbp)
je     13e7 <main+0x277>
mov    -0x28(%rbp),%rdi
movss  -0x244(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd5a(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
jmp    1405 <main+0x295>
mov    -0x28(%rbp),%rdi
movss  -0x248(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd37(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    142d <main+0x2bd>
mov    -0x28(%rbp),%rdi
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    143f <main+0x2cf>
mov    -0x28(%rbp),%rdi
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1444 <main+0x2d4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    137f <main+0x20f>
jmp    1457 <main+0x2e7>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    136c <main+0x1fc>
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbp
cmp    $0x5,%edi
jne    143a <main+0x29a>
mov    0x8(%rbp),%rdi
lea    0xf45(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     1476 <main+0x2d6>
mov    0x10(%rbp),%rdi
lea    0xf27(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     1486 <main+0x2e6>
mov    0x18(%rbp),%rdi
lea    0xf25(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1496 <main+0x2f6>
mov    %rax,%rbx
mov    0x20(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,0x14(%rsp)
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    $0x200,%esi
mov    0x28(%rsp),%rbp
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    0x20(%rsp),%r15
mov    %r15,%rdx
call   1070 <fgets@plt>
lea    0xed1(%rip),%r14
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <sscanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
lea    0xc(%rsp),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <sscanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1426 <main+0x286>
mov    0x8(%rsp),%ecx
lea    0x1c(%rsp),%r13
lea    0xdba(%rip),%rbp
lea    0x18(%rsp),%r14
mov    $0xa,%r15d
xor    %edx,%edx
jmp    13a3 <main+0x203>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%edx
add    $0x1,%edx
cmp    %eax,%edx
jge    1426 <main+0x286>
test   %ecx,%ecx
jle    1398 <main+0x1f8>
mov    %edx,0x10(%rsp)
xor    %r12d,%r12d
jmp    13ef <main+0x24f>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r12d
mov    $0x20,%edi
cmove  %r15d,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0x1,%r12d
mov    0x8(%rsp),%ecx
cmp    %ecx,%r12d
jge    1390 <main+0x1f0>
mov    0x28(%rsp),%rdi
lea    0xd34(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x20(%rsp),%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmpl   $0x0,0x1c(%rsp)
jne    13b0 <main+0x210>
movss  0x18(%rsp),%xmm0
jmp    13b6 <main+0x216>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b9f(%rip),%rbx
mov    (%rbx),%rdi
mov    0x0(%rbp),%rdx
lea    0xbb1(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%rcx
lea    0xbe0(%rip),%rdi
mov    $0xcc,%esi
mov    $0x1,%edx
call   10c0 <fwrite@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x2b63(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%rbp),%rdx
jmp    14a4 <main+0x304>
mov    0x2b53(%rip),%rax
mov    (%rax),%rdi
mov    0x10(%rbp),%rdx
jmp    14a4 <main+0x304>
mov    0x2b43(%rip),%rax
mov    (%rax),%rdi
mov    0x18(%rbp),%rdx
lea    0xc64(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [64 x i8] c"Usage: %s <run mask> <old param file> <new param file> <value>\0A\00"
@.str.1 = [205 x i8] c"\09This program sets the activated grid cells in the old parameter file to the given value, and writes the results to the new parameter file. Activated cells have values other than 0 in the run mask file.\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"ERROR: Unable to open %s\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [7 x i8] c"%*s %i\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [3 x i8] c"%i\00"
@.str.8 = [3 x i8] c"%f\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [2 x i8] c" \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 i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [512 x i8]
%15 = alloca float
%16 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 5
br i1 %18, label %19, label %28
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 ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32*, i32** @stderr
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([205 x i8], [205 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %6
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = load i32*, i32** @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %28
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %45, i32** %7
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %54
47: ; preds = %41
%48 = load i32*, i32** @stderr
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = call i32 @exit(i32 0)
unreachable
54: ; preds = %41
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 3
%57 = load i8*, i8** %56
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %58, i32** %8
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %67
60: ; preds = %54
%61 = load i32*, i32** @stderr
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 3
%64 = load i8*, i8** %63
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 0)
unreachable
67: ; preds = %54
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 4
%70 = load i8*, i8** %69
%71 = call float @atof(i8* %70)
store float %71, float* %15
store i32 0, i32* %9
br label %72
72: ; preds = %97, %67
%73 = load i32, i32* %9
%74 = icmp slt i32 %73, 6
br i1 %74, label %75, label %100
75: ; preds = %72
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%77 = load i32*, i32** %6
%78 = call i32 @fgets(i8* %76, i32 512, i32* %77)
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%80 = load i32*, i32** %7
%81 = call i32 @fgets(i8* %79, i32 512, i32* %80)
%82 = load i32, i32* %9
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %75
%85 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%86 = call i32 @sscanf(i8* %85, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %11)
br label %87
87: ; preds = %84, %75
%88 = load i32, i32* %9
%89 = icmp eq i32 %88, 1
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%92 = call i32 @sscanf(i8* %91, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %12)
br label %93
93: ; preds = %90, %87
%94 = load i32*, i32** %8
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %95)
br label %97
97: ; preds = %93
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 1
store i32 %99, i32* %9
br label %72
100: ; preds = %72
store i32 0, i32* %9
br label %101
101: ; preds = %143, %100
%102 = load i32, i32* %9
%103 = load i32, i32* %12
%104 = icmp slt i32 %102, %103
br i1 %104, label %105, label %146
105: ; preds = %101
store i32 0, i32* %10
br label %106
106: ; preds = %139, %105
%107 = load i32, i32* %10
%108 = load i32, i32* %11
%109 = icmp slt i32 %107, %108
br i1 %109, label %110, label %142
110: ; preds = %106
%111 = load i32*, i32** %6
%112 = call i32 (i32*, i8*, ...) @fscanf(i32* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %13)
%113 = load i32*, i32** %7
%114 = call i32 (i32*, i8*, ...) @fscanf(i32* %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), float* %16)
%115 = load i32, i32* %13
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %122
117: ; preds = %110
%118 = load i32*, i32** %8
%119 = load float, float* %15
%120 = fpext float %119 to double
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), double %120)
br label %127
122: ; preds = %110
%123 = load i32*, i32** %8
%124 = load float, float* %16
%125 = fpext float %124 to double
%126 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), double %125)
br label %127
127: ; preds = %122, %117
%128 = load i32, i32* %10
%129 = load i32, i32* %11
%130 = sub nsw i32 %129, 1
%131 = icmp eq i32 %128, %130
br i1 %131, label %132, label %135
132: ; preds = %127
%133 = load i32*, i32** %8
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %133, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %138
135: ; preds = %127
%136 = load i32*, i32** %8
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %138
138: ; preds = %135, %132
br label %139
139: ; preds = %138
%140 = load i32, i32* %10
%141 = add nsw i32 %140, 1
store i32 %141, i32* %10
br label %106
142: ; preds = %106
br label %143
143: ; preds = %142
%144 = load i32, i32* %9
%145 = add nsw i32 %144, 1
store i32 %145, i32* %9
br label %101
146: ; preds = %101
%147 = load i32, i32* %3
ret i32 %147
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [64 x i8] c"Usage: %s <run mask> <old param file> <new param file> <value>\0A\00"
@.str.1 = [205 x i8] c"\09This program sets the activated grid cells in the old parameter file to the given value, and writes the results to the new parameter file. Activated cells have values other than 0 in the run mask file.\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"ERROR: Unable to open %s\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [7 x i8] c"%*s %i\00"
@.str.7 = [3 x i8] c"%i\00"
@.str.8 = [3 x i8] c"%f\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [512 x i8]
%7 = alloca float
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = bitcast float* %7 to i8*
%13 = icmp eq i32 %0, 5
br i1 %13, label %21, label %14
14: ; preds = %2
%15 = load i32*, i32** @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** @stderr
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([205 x i8], [205 x i8]* @.str.1, i64 0, i64 0), i64 204, i64 1, i32* %18)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = load i32*, i32** @stderr
%28 = load i8*, i8** %22
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = tail call i32 @exit(i32 0)
unreachable
31: ; preds = %21
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32*, i32** @stderr
%38 = load i8*, i8** %32
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = tail call i32 @exit(i32 0)
unreachable
41: ; preds = %31
%42 = getelementptr inbounds i8*, i8** %1, i64 3
%43 = load i8*, i8** %42
%44 = tail call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %53
46: ; preds = %41
%47 = load i32*, i32** @stderr
%48 = load i8*, i8** %42
%49 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = tail call i32 @exit(i32 0)
unreachable
51: ; preds = %53
%52 = load i32, i32* %3
br label %79
53: ; preds = %41
%54 = getelementptr inbounds i8*, i8** %1, i64 4
%55 = load i8*, i8** %54
%56 = tail call float @atof(i8* %55)
%57 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%58 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%59 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%60 = call i32 @fputs(i8* %11, i32* %44)
%61 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%62 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%63 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%64 = call i32 @fputs(i8* %11, i32* %44)
%65 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%66 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%67 = call i32 @fputs(i8* %11, i32* %44)
%68 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%69 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%70 = call i32 @fputs(i8* %11, i32* %44)
%71 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%72 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%73 = call i32 @fputs(i8* %11, i32* %44)
%74 = call i32 @fgets(i8* %11, i32 512, i32* %24)
%75 = call i32 @fgets(i8* %11, i32 512, i32* %34)
%76 = call i32 @fputs(i8* %11, i32* %44)
%77 = load i32, i32* %4
%78 = icmp sgt i32 %77, 0
br i1 %78, label %51, label %109
79: ; preds = %51, %104
%80 = phi i32 [ %77, %51 ], [ %105, %104 ]
%81 = phi i32 [ %52, %51 ], [ %106, %104 ]
%82 = phi i32 [ 0, %51 ], [ %107, %104 ]
%83 = icmp sgt i32 %81, 0
br i1 %83, label %84, label %104
84: ; preds = %79, %84
%85 = phi i32 [ %99, %84 ], [ 0, %79 ]
%86 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%87 = call i32 (i32*, i8*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), float* %7)
%88 = load i32, i32* %5
%89 = icmp eq i32 %88, 0
%90 = load float, float* %7
%91 = select i1 %89, float %90, float %56
%92 = fpext float %91 to double
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), double %92)
%94 = load i32, i32* %3
%95 = add nsw i32 %94, -1
%96 = icmp eq i32 %85, %95
%97 = select i1 %96, i32 10, i32 32
%98 = call i32 @fputc(i32 %97, i32* %44)
%99 = add nuw nsw i32 %85, 1
%100 = load i32, i32* %3
%101 = icmp slt i32 %99, %100
br i1 %101, label %84, label %102
102: ; preds = %84
%103 = load i32, i32* %4
br label %104
104: ; preds = %102, %79
%105 = phi i32 [ %103, %102 ], [ %80, %79 ]
%106 = phi i32 [ %100, %102 ], [ %81, %79 ]
%107 = add nuw nsw i32 %82, 1
%108 = icmp slt i32 %107, %105
br i1 %108, label %79, label %109
109: ; preds = %104, %53
ret i32 0
}