#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 /*<<< orphan*/ st_atime;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
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) {
    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);
    }
  }
  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    0xd4f(%rip),%rdx
call   1150 <getopt@plt>
mov    %eax,-0x814(%rbp)
mov    0x2d15(%rip),%rcx
cmp    (%rcx),%eax
je     13b9 <main+0x159>
mov    -0x814(%rbp),%eax
mov    %eax,-0x854(%rbp)
sub    $0x66,%eax
je     130d <main+0xad>
jmp    12e5 <main+0x85>
mov    -0x854(%rbp),%eax
sub    $0x74,%eax
je     136e <main+0x10e>
jmp    12f9 <main+0x99>
mov    -0x854(%rbp),%eax
sub    $0x76,%eax
je     1382 <main+0x122>
jmp    1396 <main+0x136>
mov    0x2ce4(%rip),%rax
mov    (%rax),%rdi
lea    0xce7(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
jne    1351 <main+0xf1>
mov    0x2cb9(%rip),%rax
mov    (%rax),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x820(%rbp),%rdi
call   1180 <parse_config_file@plt>
mov    -0x820(%rbp),%rdi
call   1060 <fclose@plt>
jmp    13b4 <main+0x154>
mov    -0x840(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x840(%rbp)
jmp    13b4 <main+0x154>
mov    -0x83c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x83c(%rbp)
jmp    13b4 <main+0x154>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    12a3 <main+0x43>
mov    0x2c10(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1439 <main+0x1d9>
mov    -0x10(%rbp),%rax
mov    0x2bfa(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc21(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
jne    141f <main+0x1bf>
mov    -0x10(%rbp),%rax
mov    0x2bc7(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2baa(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2b9e(%rip),%rax
mov    %ecx,(%rax)
jmp    144a <main+0x1ea>
mov    0x2ba0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x820(%rbp)
mov    0x2b7f(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    152c <main+0x2cc>
mov    -0x10(%rbp),%rax
mov    0x2b69(%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    14c3 <main+0x263>
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
lea    0xb72(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x838(%rbp),%rdi
lea    0xb59(%rip),%rsi
call   1160 <strcat@plt>
mov    -0x838(%rbp),%rdi
lea    0xb49(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1527 <main+0x2c7>
mov    -0x838(%rbp),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    1548 <main+0x2e8>
mov    0x2a85(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x828(%rbp)
movq   $0x0,-0x830(%rbp)
jmp    154d <main+0x2ed>
mov    -0x820(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    156e <main+0x30e>
jmp    15b9 <main+0x359>
lea    -0x810(%rbp),%rdi
mov    -0x820(%rbp),%rdx
mov    $0x800,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
jne    1595 <main+0x335>
jmp    15b9 <main+0x359>
lea    -0x810(%rbp),%rdi
call   1110 <substitute_line@plt>
lea    -0x810(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   1090 <fputs@plt>
jmp    154d <main+0x2ed>
mov    -0x820(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x828(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x830(%rbp)
je     16fb <main+0x49b>
mov    -0x830(%rbp),%rdi
mov    -0x838(%rbp),%rsi
call   10f0 <compare_file@plt>
cmp    $0x0,%rax
je     16c3 <main+0x463>
cmpl   $0x0,-0x83c(%rbp)
je     161c <main+0x3bc>
mov    -0x830(%rbp),%rsi
lea    0xa2b(%rip),%rdi
call   1080 <printf@plt>
cmpl   $0x0,-0x840(%rbp)
je     16b2 <main+0x452>
mov    -0x830(%rbp),%rdi
lea    -0x848(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
jne    16ad <main+0x44d>
cmpl   $0x0,-0x83c(%rbp)
je     1666 <main+0x406>
mov    -0x830(%rbp),%rsi
lea    0x9f9(%rip),%rdi
call   1080 <printf@plt>
mov    -0x848(%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    16a8 <main+0x448>
lea    0x9d0(%rip),%rdi
call   1130 <perror@plt>
jmp    16ad <main+0x44d>
jmp    16b2 <main+0x452>
mov    -0x838(%rbp),%rdi
call   1040 <unlink@plt>
jmp    16f6 <main+0x496>
cmpl   $0x0,-0x83c(%rbp)
je     16e3 <main+0x483>
mov    -0x830(%rbp),%rsi
lea    0x99b(%rip),%rdi
call   1080 <printf@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1140 <rename@plt>
jmp    16fb <main+0x49b>
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    0xd82(%rip),%rdx
call   1150 <getopt@plt>
mov    0x2d4e(%rip),%rbx
xor    %r12d,%r12d
movl   $0x0,0x8(%rsp)
cmp    (%rbx),%eax
jne    12f7 <main+0x97>
mov    %r12d,0xc(%rsp)
mov    0x2d2b(%rip),%rbp
mov    0x0(%rbp),%eax
cmp    %r13d,%eax
jge    13af <main+0x14f>
cltq
mov    (%r14,%rax,8),%rdi
lea    0xd47(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%r15
movslq 0x0(%rbp),%rax
test   %r15,%r15
je     155b <main+0x2fb>
add    $0x1,%eax
mov    %eax,0x0(%rbp)
cmp    %r13d,%eax
jl     13c2 <main+0x162>
mov    0x2ccf(%rip),%rax
mov    (%rax),%rbp
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    141a <main+0x1ba>
lea    0xd02(%rip),%rbp
movl   $0x0,0x8(%rsp)
xor    %r12d,%r12d
jmp    132a <main+0xca>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    %r13d,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1150 <getopt@plt>
cmp    (%rbx),%eax
je     1299 <main+0x39>
cmp    $0x76,%eax
je     1310 <main+0xb0>
cmp    $0x74,%eax
je     1380 <main+0x120>
cmp    $0x66,%eax
jne    1390 <main+0x130>
mov    %rbp,%r15
mov    0x2cb5(%rip),%rax
mov    (%rax),%rdi
lea    0xcb8(%rip),%rsi
call   1120 <fopen@plt>
test   %rax,%rax
je     1542 <main+0x2e2>
mov    %rax,%rbp
mov    %rax,%rdi
call   1180 <parse_config_file@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r15,%rbp
jmp    1314 <main+0xb4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addl   $0x1,0x8(%rsp)
jmp    1314 <main+0xb4>
nopw   0x0(%rax,%rax,1)
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc64(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1314 <main+0xb4>
mov    0x2c2a(%rip),%rcx
mov    (%rcx),%r15
cmp    %r13d,%eax
jge    12e2 <main+0x82>
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     1561 <main+0x301>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r13,%rsi
call   1050 <strcpy@plt>
lea    0xc46(%rip),%rsi
mov    %r14,%rdi
call   1160 <strcat@plt>
lea    0xc3a(%rip),%rsi
mov    %r14,%rdi
call   1120 <fopen@plt>
test   %rax,%rax
je     1582 <main+0x322>
mov    %rax,%rbp
mov    %r15,%rdi
call   10c0 <feof@plt>
test   %eax,%eax
jne    1464 <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     1464 <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     1430 <main+0x1d0>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
test   %r13,%r13
je     1520 <main+0x2c0>
mov    %r13,%rdi
mov    %r14,%rsi
call   10f0 <compare_file@plt>
test   %rax,%rax
je     14ff <main+0x29f>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     14a4 <main+0x244>
lea    0xba6(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
cmpl   $0x0,0x8(%rsp)
je     14f5 <main+0x295>
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   10d0 <stat@plt>
test   %rax,%rax
jne    14f5 <main+0x295>
test   %ebx,%ebx
je     14d0 <main+0x270>
lea    0xb92(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
mov    0x10(%rsp),%eax
mov    %eax,0x1c(%rsp)
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,0x18(%rsp)
lea    0x18(%rsp),%rsi
mov    %r13,%rdi
call   1030 <utime@plt>
test   %rax,%rax
js     1534 <main+0x2d4>
mov    %r14,%rdi
call   1040 <unlink@plt>
jmp    1520 <main+0x2c0>
cmpl   $0x0,0xc(%rsp)
je     1515 <main+0x2b5>
lea    0xb6c(%rip),%rdi
mov    %r13,%rsi
call   1080 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1140 <rename@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb38(%rip),%rdi
call   1130 <perror@plt>
jmp    14f5 <main+0x295>
mov    0x2aaf(%rip),%rax
mov    (%rax),%rdi
call   1130 <perror@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    (%r14,%rax,8),%rdi
jmp    154c <main+0x2ec>
mov    0x2a58(%rip),%rax
mov    (%rax),%edi
lea    0xab3(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    %r14,%rdi
jmp    154c <main+0x2ec>

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

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