#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 */
struct utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct stat {
  int st_mode;
  int /*<<< orphan*/ st_atime;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ chmod(char *, int);
scalar_t__ compare_file(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
scalar_t__ malloc(scalar_t__);
char *optarg;
int optind;
int /*<<< orphan*/ parse_config_file(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ rename(char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ substitute_line(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
scalar_t__ utime(char *, struct utimbuf *);
int main(int argc, char **argv) {
  char line[2048];
  int c;
  FILE *in, *out;
  char *outfn = NULL, *newfn = NULL;
  int verbose = 0;
  int adjust_timestamp = 0;
  struct stat stbuf;
  struct utimbuf ut;
  while ((c = getopt(argc, argv, "f:tv")) != EOF) {
    switch (c) {
    case 'f':
      in = fopen(optarg, "r");
      if (!in) {
        perror(optarg);
        exit(1);
      }
      parse_config_file(in);
      fclose(in);
      break;
    case 't':
      adjust_timestamp++;
      break;
    case 'v':
      verbose++;
      break;
    default:
      fprintf(stderr, "%s: [-f config-file] [file]\n", argv[0]);
      break;
    }
  }
  if (optind < argc) {
    in = fopen(argv[optind], "r");
    if (!in) {
      perror(argv[optind]);
      exit(1);
    }
    optind++;
  } else
    in = stdin;
  if (optind < argc) {
    outfn = argv[optind];
    newfn = (char *)malloc(strlen(outfn) + 20);
    if (!newfn) {
      fprintf(stderr, "Memory error!  Exiting.\n");
      exit(1);
    }
    strcpy(newfn, outfn);
    strcat(newfn, ".new");
    out = fopen(newfn, "w");
    if (!out) {
      perror(newfn);
      exit(1);
    }
  } else {
    out = stdout;
    outfn = 0;
  }
  while (!feof(in)) {
    if (fgets(line, sizeof(line), in) == NULL)
      break;
    substitute_line(line);
    fputs(line, out);
  }
  fclose(in);
  fclose(out);
  if (outfn) {
    struct stat st;
    if (compare_file(outfn, newfn)) {
      if (verbose)
        printf("No change, keeping %s.\n", outfn);
      if (adjust_timestamp) {
        if (stat(outfn, &stbuf) == 0) {
          if (verbose)
            printf("Updating modtime for %s\n", outfn);
          ut.actime = stbuf.st_atime;
          ut.modtime = time(0);
          if (utime(outfn, &ut) < 0)
            perror("utime");
        }
      }
      unlink(newfn);
    } else {
      if (verbose)
        printf("Creating or replacing %s.\n", outfn);
      rename(newfn, outfn);
    }
    if (stat(outfn, &st) == 0)
      chmod(outfn, st.st_mode & ~0222);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x830(%rbp)
movq   $0x0,-0x838(%rbp)
movl   $0x0,-0x83c(%rbp)
movl   $0x0,-0x840(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd3f(%rip),%rdx
call   1160 <getopt@plt>
mov    %eax,-0x814(%rbp)
mov    0x2d05(%rip),%rcx
cmp    (%rcx),%eax
je     13c9 <main+0x159>
mov    -0x814(%rbp),%eax
mov    %eax,-0x85c(%rbp)
sub    $0x66,%eax
je     131d <main+0xad>
jmp    12f5 <main+0x85>
mov    -0x85c(%rbp),%eax
sub    $0x74,%eax
je     137e <main+0x10e>
jmp    1309 <main+0x99>
mov    -0x85c(%rbp),%eax
sub    $0x76,%eax
je     1392 <main+0x122>
jmp    13a6 <main+0x136>
mov    0x2cd4(%rip),%rax
mov    (%rax),%rdi
lea    0xcd7(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
jne    1361 <main+0xf1>
mov    0x2ca9(%rip),%rax
mov    (%rax),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x820(%rbp),%rdi
call   1190 <parse_config_file@plt>
mov    -0x820(%rbp),%rdi
call   1060 <fclose@plt>
jmp    13c4 <main+0x154>
mov    -0x840(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x840(%rbp)
jmp    13c4 <main+0x154>
mov    -0x83c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x83c(%rbp)
jmp    13c4 <main+0x154>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc4a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    12b3 <main+0x43>
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1449 <main+0x1d9>
mov    -0x10(%rbp),%rax
mov    0x2bea(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc11(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
jne    142f <main+0x1bf>
mov    -0x10(%rbp),%rax
mov    0x2bb7(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    0x2b9a(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2b8e(%rip),%rax
mov    %ecx,(%rax)
jmp    145a <main+0x1ea>
mov    0x2b90(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x820(%rbp)
mov    0x2b6f(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    153c <main+0x2cc>
mov    -0x10(%rbp),%rax
mov    0x2b59(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rdi
add    $0x14,%rdi
call   1100 <malloc@plt>
mov    %rax,-0x838(%rbp)
cmpq   $0x0,-0x838(%rbp)
jne    14d3 <main+0x263>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
lea    0xb62(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x838(%rbp),%rdi
lea    0xb49(%rip),%rsi
call   1170 <strcat@plt>
mov    -0x838(%rbp),%rdi
lea    0xb39(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1537 <main+0x2c7>
mov    -0x838(%rbp),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
jmp    1558 <main+0x2e8>
mov    0x2a75(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x828(%rbp)
movq   $0x0,-0x830(%rbp)
jmp    155d <main+0x2ed>
mov    -0x820(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    157e <main+0x30e>
jmp    15c9 <main+0x359>
lea    -0x810(%rbp),%rdi
mov    -0x820(%rbp),%rdx
mov    $0x800,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    15a5 <main+0x335>
jmp    15c9 <main+0x359>
lea    -0x810(%rbp),%rdi
call   1110 <substitute_line@plt>
lea    -0x810(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   1090 <fputs@plt>
jmp    155d <main+0x2ed>
mov    -0x820(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x828(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x830(%rbp)
je     1740 <main+0x4d0>
mov    -0x830(%rbp),%rdi
mov    -0x838(%rbp),%rsi
call   10f0 <compare_file@plt>
cmp    $0x0,%rax
je     16d3 <main+0x463>
cmpl   $0x0,-0x83c(%rbp)
je     162c <main+0x3bc>
mov    -0x830(%rbp),%rsi
lea    0xa1b(%rip),%rdi
call   1080 <printf@plt>
cmpl   $0x0,-0x840(%rbp)
je     16c2 <main+0x452>
mov    -0x830(%rbp),%rdi
lea    -0x848(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
jne    16bd <main+0x44d>
cmpl   $0x0,-0x83c(%rbp)
je     1676 <main+0x406>
mov    -0x830(%rbp),%rsi
lea    0x9e9(%rip),%rdi
call   1080 <printf@plt>
mov    -0x844(%rbp),%eax
mov    %eax,-0x84c(%rbp)
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,-0x850(%rbp)
mov    -0x830(%rbp),%rdi
lea    -0x850(%rbp),%rsi
call   1030 <utime@plt>
cmp    $0x0,%rax
jge    16b8 <main+0x448>
lea    0x9c0(%rip),%rdi
call   1140 <perror@plt>
jmp    16bd <main+0x44d>
jmp    16c2 <main+0x452>
mov    -0x838(%rbp),%rdi
call   1040 <unlink@plt>
jmp    1706 <main+0x496>
cmpl   $0x0,-0x83c(%rbp)
je     16f3 <main+0x483>
mov    -0x830(%rbp),%rsi
lea    0x98b(%rip),%rdi
call   1080 <printf@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1150 <rename@plt>
mov    -0x830(%rbp),%rdi
lea    -0x858(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
jne    173b <main+0x4cb>
mov    -0x830(%rbp),%rdi
mov    -0x858(%rbp),%esi
and    $0xffffff6d,%esi
call   1120 <chmod@plt>
jmp    1740 <main+0x4d0>
xor    %eax,%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rsi,%r14
mov    %edi,%r13d
lea    0xd72(%rip),%rdx
call   1160 <getopt@plt>
mov    0x2d3e(%rip),%rbx
xor    %r12d,%r12d
movl   $0x0,(%rsp)
cmp    (%rbx),%eax
jne    1306 <main+0x96>
mov    %r12d,0x4(%rsp)
mov    0x2d1c(%rip),%rbp
mov    0x0(%rbp),%eax
cmp    %r13d,%eax
jge    13bf <main+0x14f>
cltq
mov    (%r14,%rax,8),%rdi
lea    0xd38(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,%r15
movslq 0x0(%rbp),%rax
test   %r15,%r15
je     158d <main+0x31d>
add    $0x1,%eax
mov    %eax,0x0(%rbp)
cmp    %r13d,%eax
jl     13d2 <main+0x162>
mov    0x2cc0(%rip),%rax
mov    (%rax),%rbp
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    142a <main+0x1ba>
lea    0xcf3(%rip),%rbp
movl   $0x0,(%rsp)
xor    %r12d,%r12d
jmp    133a <main+0xca>
nopl   0x0(%rax)
add    $0x1,%r12d
mov    %r13d,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1160 <getopt@plt>
cmp    (%rbx),%eax
je     12a8 <main+0x38>
cmp    $0x76,%eax
je     1320 <main+0xb0>
cmp    $0x74,%eax
je     1390 <main+0x120>
cmp    $0x66,%eax
jne    13a0 <main+0x130>
mov    %rbp,%r15
mov    0x2ca5(%rip),%rax
mov    (%rax),%rdi
lea    0xca8(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     1574 <main+0x304>
mov    %rax,%rbp
mov    %rax,%rdi
call   1190 <parse_config_file@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r15,%rbp
jmp    1324 <main+0xb4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addl   $0x1,(%rsp)
jmp    1324 <main+0xb4>
cs nopw 0x0(%rax,%rax,1)
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc54(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1324 <main+0xb4>
mov    0x2c1a(%rip),%rcx
mov    (%rcx),%r15
cmp    %r13d,%eax
jge    12f1 <main+0x81>
cltq
mov    (%r14,%rax,8),%r13
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0x14(%rax),%rdi
call   1100 <malloc@plt>
test   %rax,%rax
je     1593 <main+0x323>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r13,%rsi
call   1050 <strcpy@plt>
lea    0xc36(%rip),%rsi
mov    %r14,%rdi
call   1170 <strcat@plt>
lea    0xc2a(%rip),%rsi
mov    %r14,%rdi
call   1130 <fopen@plt>
test   %rax,%rax
je     15b4 <main+0x344>
mov    %rax,%rbp
mov    %r15,%rdi
call   10c0 <feof@plt>
test   %eax,%eax
jne    1474 <main+0x204>
lea    0x20(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1474 <main+0x204>
mov    %rbx,%rdi
call   1110 <substitute_line@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <fputs@plt>
mov    %r15,%rdi
call   10c0 <feof@plt>
test   %eax,%eax
je     1440 <main+0x1d0>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
test   %r13,%r13
je     1552 <main+0x2e2>
mov    %r13,%rdi
mov    %r14,%rsi
call   10f0 <compare_file@plt>
test   %rax,%rax
je     150e <main+0x29e>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
je     14b4 <main+0x244>
lea    0xb96(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
cmpl   $0x0,(%rsp)
je     1504 <main+0x294>
lea    0x18(%rsp),%rsi
mov    %r13,%rdi
call   10d0 <stat@plt>
test   %rax,%rax
jne    1504 <main+0x294>
test   %ebx,%ebx
je     14df <main+0x26f>
lea    0xb83(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
mov    0x1c(%rsp),%eax
mov    %eax,0xc(%rsp)
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r13,%rdi
call   1030 <utime@plt>
test   %rax,%rax
js     1566 <main+0x2f6>
mov    %r14,%rdi
call   1040 <unlink@plt>
jmp    152f <main+0x2bf>
cmpl   $0x0,0x4(%rsp)
je     1524 <main+0x2b4>
lea    0xb5d(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1150 <rename@plt>
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   10d0 <stat@plt>
test   %rax,%rax
jne    1552 <main+0x2e2>
mov    $0xffffff6d,%esi
and    0x10(%rsp),%esi
mov    %r13,%rdi
call   1120 <chmod@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb06(%rip),%rdi
call   1140 <perror@plt>
jmp    1504 <main+0x294>
mov    0x2a7d(%rip),%rax
mov    (%rax),%rdi
call   1140 <perror@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    (%r14,%rax,8),%rdi
jmp    157e <main+0x30e>
mov    0x2a26(%rip),%rax
mov    (%rax),%edi
lea    0xa81(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1180 <exit@plt>
mov    %r14,%rdi
jmp    157e <main+0x30e>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
@.str = [5 x i8] c"f:tv\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"%s: [-f config-file] [file]\0A\00"
@optind = global i32 0
@stdin = global i32* null
@.str.3 = [25 x i8] c"Memory error! Exiting.\0A\00"
@.str.4 = [5 x i8] c".new\00"
@.str.5 = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.6 = [24 x i8] c"No change, keeping %s.\0A\00"
@.str.7 = [25 x i8] c"Updating modtime for %s\0A\00"
@.str.8 = [6 x i8] c"utime\00"
@.str.9 = [27 x i8] c"Creating or replacing %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.stat
%15 = alloca %struct.utimbuf
%16 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %10
store i8* null, i8** %11
store i32 0, i32* %12
store i32 0, i32* %13
br label %17
17: ; preds = %51, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %7
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %52
23: ; preds = %17
%24 = load i32, i32* %7
switch i32 %24, label %45 [
i32 102, label %25
i32 116, label %39
i32 118, label %42
]
25: ; preds = %23
%26 = load i8*, i8** @optarg
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %8
%28 = load i32*, i32** %8
%29 = icmp ne i32* %28, null
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = load i8*, i8** @optarg
%32 = call i32 @perror(i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %25
%35 = load i32*, i32** %8
%36 = call i32 @parse_config_file(i32* %35)
%37 = load i32*, i32** %8
%38 = call i32 @fclose(i32* %37)
br label %51
39: ; preds = %23
%40 = load i32, i32* %13
%41 = add nsw i32 %40, 1
store i32 %41, i32* %13
br label %51
42: ; preds = %23
%43 = load i32, i32* %12
%44 = add nsw i32 %43, 1
store i32 %44, i32* %12
br label %51
45: ; preds = %23
%46 = load i32, i32* @stderr
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %45, %42, %39, %34
br label %17
52: ; preds = %17
%53 = load i32, i32* @optind
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %76
56: ; preds = %52
%57 = load i8**, i8*** %5
%58 = load i32, i32* @optind
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %62, i32** %8
%63 = load i32*, i32** %8
%64 = icmp ne i32* %63, null
br i1 %64, label %73, label %65
65: ; preds = %56
%66 = load i8**, i8*** %5
%67 = load i32, i32* @optind
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @perror(i8* %70)
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %56
%74 = load i32, i32* @optind
%75 = add nsw i32 %74, 1
store i32 %75, i32* @optind
br label %78
76: ; preds = %52
%77 = load i32*, i32** @stdin
store i32* %77, i32** %8
br label %78
78: ; preds = %76, %73
%79 = load i32, i32* @optind
%80 = load i32, i32* %4
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %114
82: ; preds = %78
%83 = load i8**, i8*** %5
%84 = load i32, i32* @optind
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
store i8* %87, i8** %10
%88 = load i8*, i8** %10
%89 = call i64 @strlen(i8* %88)
%90 = add nsw i64 %89, 20
%91 = call i64 @malloc(i64 %90)
%92 = inttoptr i64 %91 to i8*
store i8* %92, i8** %11
%93 = load i8*, i8** %11
%94 = icmp ne i8* %93, null
br i1 %94, label %99, label %95
95: ; preds = %82
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %82
%100 = load i8*, i8** %11
%101 = load i8*, i8** %10
%102 = call i32 @strcpy(i8* %100, i8* %101)
%103 = load i8*, i8** %11
%104 = call i32 @strcat(i8* %103, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%105 = load i8*, i8** %11
%106 = call i32* @fopen(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %106, i32** %9
%107 = load i32*, i32** %9
%108 = icmp ne i32* %107, null
br i1 %108, label %113, label %109
109: ; preds = %99
%110 = load i8*, i8** %11
%111 = call i32 @perror(i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %99
br label %116
114: ; preds = %78
%115 = load i32*, i32** @stdout
store i32* %115, i32** %9
store i8* null, i8** %10
br label %116
116: ; preds = %114, %113
br label %117
117: ; preds = %128, %116
%118 = load i32*, i32** %8
%119 = call i32 @feof(i32* %118)
%120 = icmp ne i32 %119, 0
%121 = xor i1 %120, true
br i1 %121, label %122, label %134
122: ; preds = %117
%123 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%124 = load i32*, i32** %8
%125 = call i32* @fgets(i8* %123, i32 2048, i32* %124)
%126 = icmp eq i32* %125, null
br i1 %126, label %127, label %128
127: ; preds = %122
br label %134
128: ; preds = %122
%129 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%130 = call i32 @substitute_line(i8* %129)
%131 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%132 = load i32*, i32** %9
%133 = call i32 @fputs(i8* %131, i32* %132)
br label %117
134: ; preds = %127, %117
%135 = load i32*, i32** %8
%136 = call i32 @fclose(i32* %135)
%137 = load i32*, i32** %9
%138 = call i32 @fclose(i32* %137)
%139 = load i8*, i8** %10
%140 = icmp ne i8* %139, null
br i1 %140, label %141, label %202
141: ; preds = %134
%142 = load i8*, i8** %10
%143 = load i8*, i8** %11
%144 = call i64 @compare_file(i8* %142, i8* %143)
%145 = icmp ne i64 %144, 0
br i1 %145, label %146, label %181
146: ; preds = %141
%147 = load i32, i32* %12
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %146
%150 = load i8*, i8** %10
%151 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %150)
br label %152
152: ; preds = %149, %146
%153 = load i32, i32* %13
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %178
155: ; preds = %152
%156 = load i8*, i8** %10
%157 = call i64 @stat(i8* %156, %struct.stat* %14)
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %177
159: ; preds = %155
%160 = load i32, i32* %12
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %165
162: ; preds = %159
%163 = load i8*, i8** %10
%164 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %163)
br label %165
165: ; preds = %162, %159
%166 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 1
%167 = load i32, i32* %166
%168 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %15, i32 0, i32 1
store i32 %167, i32* %168
%169 = call i32 @time(i32 0)
%170 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %15, i32 0, i32 0
store i32 %169, i32* %170
%171 = load i8*, i8** %10
%172 = call i64 @utime(i8* %171, %struct.utimbuf* %15)
%173 = icmp slt i64 %172, 0
br i1 %173, label %174, label %176
174: ; preds = %165
%175 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %176
176: ; preds = %174, %165
br label %177
177: ; preds = %176, %155
br label %178
178: ; preds = %177, %152
%179 = load i8*, i8** %11
%180 = call i32 @unlink(i8* %179)
br label %191
181: ; preds = %141
%182 = load i32, i32* %12
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %187
184: ; preds = %181
%185 = load i8*, i8** %10
%186 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8* %185)
br label %187
187: ; preds = %184, %181
%188 = load i8*, i8** %11
%189 = load i8*, i8** %10
%190 = call i32 @rename(i8* %188, i8* %189)
br label %191
191: ; preds = %187, %178
%192 = load i8*, i8** %10
%193 = call i64 @stat(i8* %192, %struct.stat* %16)
%194 = icmp eq i64 %193, 0
br i1 %194, label %195, label %201
195: ; preds = %191
%196 = load i8*, i8** %10
%197 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%198 = load i32, i32* %197
%199 = and i32 %198, -147
%200 = call i32 @chmod(i8* %196, i32 %199)
br label %201
201: ; preds = %195, %191
br label %202
202: ; preds = %201, %134
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
@.str = [5 x i8] c"f:tv\00"
@EOF = global i32 0
@optarg = global i8* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"%s: [-f config-file] [file]\0A\00"
@optind = global i32 0
@stdin = global i32* null
@.str.3 = [25 x i8] c"Memory error! Exiting.\0A\00"
@.str.4 = [5 x i8] c".new\00"
@.str.5 = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.6 = [24 x i8] c"No change, keeping %s.\0A\00"
@.str.7 = [25 x i8] c"Updating modtime for %s\0A\00"
@.str.8 = [6 x i8] c"utime\00"
@.str.9 = [27 x i8] c"Creating or replacing %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2048 x i8]
%4 = alloca %struct.stat
%5 = alloca %struct.utimbuf
%6 = alloca %struct.stat
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.stat* %4 to i8*
%9 = bitcast %struct.utimbuf* %5 to i8*
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %42, label %13
13: ; preds = %2, %36
%14 = phi i32 [ %39, %36 ], [ %10, %2 ]
%15 = phi i32 [ %38, %36 ], [ 0, %2 ]
%16 = phi i32 [ %37, %36 ], [ 0, %2 ]
switch i32 %14, label %32 [
i32 102, label %17
i32 116, label %28
i32 118, label %30
]
17: ; preds = %13
%18 = load i8*, i8** @optarg
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8*, i8** @optarg
%23 = tail call i32 @perror(i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = tail call i32 @parse_config_file(i32* %19)
%27 = tail call i32 @fclose(i32* %19)
br label %36
28: ; preds = %13
%29 = add nsw i32 %15, 1
br label %36
30: ; preds = %13
%31 = add nsw i32 %16, 1
br label %36
32: ; preds = %13
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %1
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %32, %30, %28, %25
%37 = phi i32 [ %16, %32 ], [ %31, %30 ], [ %16, %28 ], [ %16, %25 ]
%38 = phi i32 [ %15, %32 ], [ %15, %30 ], [ %29, %28 ], [ %15, %25 ]
%39 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %13
42: ; preds = %36, %2
%43 = phi i32 [ 0, %2 ], [ %37, %36 ]
%44 = phi i32 [ 0, %2 ], [ %38, %36 ]
%45 = load i32, i32* @optind
%46 = icmp slt i32 %45, %0
br i1 %46, label %47, label %62
47: ; preds = %42
%48 = sext i32 %45 to i64
%49 = getelementptr inbounds i8*, i8** %1, i64 %48
%50 = load i8*, i8** %49
%51 = tail call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp eq i32* %51, null
%53 = load i32, i32* @optind
br i1 %52, label %54, label %60
54: ; preds = %47
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8*, i8** %1, i64 %55
%57 = load i8*, i8** %56
%58 = tail call i32 @perror(i8* %57)
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %47
%61 = add nsw i32 %53, 1
store i32 %61, i32* @optind
br label %64
62: ; preds = %42
%63 = load i32*, i32** @stdin
br label %64
64: ; preds = %62, %60
%65 = phi i32 [ %61, %60 ], [ %45, %62 ]
%66 = phi i32* [ %51, %60 ], [ %63, %62 ]
%67 = icmp slt i32 %65, %0
br i1 %67, label %68, label %89
68: ; preds = %64
%69 = sext i32 %65 to i64
%70 = getelementptr inbounds i8*, i8** %1, i64 %69
%71 = load i8*, i8** %70
%72 = tail call i64 @strlen(i8* dereferenceable(1) %71)
%73 = add nsw i64 %72, 20
%74 = tail call i64 @malloc(i64 %73)
%75 = inttoptr i64 %74 to i8*
%76 = icmp eq i64 %74, 0
br i1 %76, label %77, label %81
77: ; preds = %68
%78 = load i32, i32* @stderr
%79 = tail call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%80 = tail call i32 @exit(i32 1)
unreachable
81: ; preds = %68
%82 = tail call i32 @strcpy(i8* %75, i8* %71)
%83 = tail call i32 @strcat(i8* %75, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%84 = tail call i32* @fopen(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = tail call i32 @perror(i8* %75)
%88 = tail call i32 @exit(i32 1)
unreachable
89: ; preds = %64
%90 = load i32*, i32** @stdout
br label %91
91: ; preds = %81, %89
%92 = phi i32* [ %84, %81 ], [ %90, %89 ]
%93 = phi i8* [ %71, %81 ], [ null, %89 ]
%94 = phi i8* [ %75, %81 ], [ null, %89 ]
%95 = call i32 @feof(i32* %66)
%96 = icmp eq i32 %95, 0
br i1 %96, label %97, label %105
97: ; preds = %91, %100
%98 = call i32* @fgets(i8* %7, i32 2048, i32* %66)
%99 = icmp eq i32* %98, null
br i1 %99, label %105, label %100
100: ; preds = %97
%101 = call i32 @substitute_line(i8* %7)
%102 = call i32 @fputs(i8* %7, i32* %92)
%103 = call i32 @feof(i32* %66)
%104 = icmp eq i32 %103, 0
br i1 %104, label %97, label %105
105: ; preds = %100, %97, %91
%106 = call i32 @fclose(i32* %66)
%107 = call i32 @fclose(i32* %92)
%108 = icmp eq i8* %93, null
br i1 %108, label %151, label %109
109: ; preds = %105
%110 = bitcast %struct.stat* %6 to i8*
%111 = call i64 @compare_file(i8* %93, i8* %94)
%112 = icmp eq i64 %111, 0
%113 = icmp eq i32 %43, 0
br i1 %112, label %137, label %114
114: ; preds = %109
br i1 %113, label %117, label %115
115: ; preds = %114
%116 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %93)
br label %117
117: ; preds = %115, %114
%118 = icmp eq i32 %44, 0
br i1 %118, label %135, label %119
119: ; preds = %117
%120 = call i64 @stat(i8* %93, %struct.stat* %4)
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %135
122: ; preds = %119
br i1 %113, label %125, label %123
123: ; preds = %122
%124 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %93)
br label %125
125: ; preds = %123, %122
%126 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%127 = load i32, i32* %126
%128 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 1
store i32 %127, i32* %128
%129 = call i32 @time(i32 0)
%130 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %5, i64 0, i32 0
store i32 %129, i32* %130
%131 = call i64 @utime(i8* %93, %struct.utimbuf* %5)
%132 = icmp slt i64 %131, 0
br i1 %132, label %133, label %135
133: ; preds = %125
%134 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %135
135: ; preds = %119, %133, %125, %117
%136 = call i32 @unlink(i8* %94)
br label %142
137: ; preds = %109
br i1 %113, label %140, label %138
138: ; preds = %137
%139 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8* %93)
br label %140
140: ; preds = %138, %137
%141 = call i32 @rename(i8* %94, i8* %93)
br label %142
142: ; preds = %140, %135
%143 = call i64 @stat(i8* %93, %struct.stat* %6)
%144 = icmp eq i64 %143, 0
br i1 %144, label %145, label %150
145: ; preds = %142
%146 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%147 = load i32, i32* %146
%148 = and i32 %147, -147
%149 = call i32 @chmod(i8* %93, i32 %148)
br label %150
150: ; preds = %145, %142
br label %151
151: ; preds = %150, %105
ret i32 0
}