#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*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int mkstemp(char *);
int parse_app_opts(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int unlink(char *);
int /*<<< orphan*/ write(int, char *, int);
int update_file(char query_type, int frontend_answer, char *app_path,
                char *md5hash) {
  char line[4096], permissions[4096];
  int temp_fd, retval;
  FILE *daemon_file, *temp_file;
  int opts, has_updated = 0;
  char temp_file_path[400];
  if ((daemon_file = fopen("/etc/daemon.conf", "r")) == NULL) {
    printf("      OOPS. Could not open daemon_conf\n");
    return -1;
  }
  strcpy(temp_file_path, "/tmp/tuxtmpXXXXXXXX");
  temp_fd = mkstemp(temp_file_path);
  if (temp_fd == -1) {
    printf("      OOPS. Could not open temporary file while updating %s \n",
           "/etc/daemon.conf");
    return -1;
  }
  if ((temp_file = fdopen(temp_fd, "r")) == NULL) {
    printf("      OOPS. Could not stream-open the temporary file\n");
    return -1;
  }
  permissions[0] = '\0';
  switch (query_type) {
  case 0:
    if (frontend_answer == 0)
      strcat(permissions, "PERMIT_APP ");
    else
      strcat(permissions, "DENY_APP ");
    break;
  case 4:
    if (frontend_answer == 0)
      strcat(permissions, "PERMIT_SERVER ");
    else
      strcat(permissions, "DENY_SERVER ");
    break;
  default:
    printf("      Trying to update file with unknown permissions (%d)!\n",
           frontend_answer);
    return 3;
  }
  while (1) {
    fgets(line, 4096, daemon_file);
    if (feof(daemon_file))
      break;
    line[strlen(line) - 1] = '\0';
    if (!strcmp(line, app_path)) {
      write(temp_fd, line, strlen(line));
      write(temp_fd, "\n", 1);
      fgets(line, 4096, daemon_file);
      write(temp_fd, line, strlen(line));
      fgets(line, 4096, daemon_file);
      line[strlen(line) - 1] = '\0';
      opts = parse_app_opts(line, 0);
      line[0] = '\0';
      if ((opts & 4))
        if ((opts & 1)) {
          strcat(line, "PERMIT_APP ");
        } else {
          strcat(line, "DENY_APP ");
        }
      if ((opts & 8))
        if ((opts & 2)) {
          strcat(line, "PERMIT_SERVER ");
        } else {
          strcat(line, "DENY_SERVER ");
        }
      strcat(line, permissions);
      has_updated = 1;
    }
    write(temp_fd, line, strlen(line));
    write(temp_fd, "\n", 1);
  }
  if (!has_updated) {
    write(temp_fd, app_path, strlen(app_path));
    write(temp_fd, "\n", 1);
    write(temp_fd, md5hash, strlen(md5hash));
    write(temp_fd, "\n", 1);
    write(temp_fd, permissions, strlen(permissions));
    write(temp_fd, "\n", 1);
  }
  fclose(daemon_file);
  retval = unlink("/etc/daemon.conf");
  if (retval == -1) {
    perror("      Error while unlinking daemon_conf (update error) ");
    return -1;
  }
  if ((daemon_file = fopen("/etc/daemon.conf", "w+")) == NULL) {
    printf("      OOPS. Could not create the new daemon_conf (update error)\n");
    return -1;
  }
  retval = fseek(temp_file, 0, SEEK_SET);
  if (retval == -1) {
    printf("      OOPS. Could not reposition stream (update error)\n");
    return -1;
  }
  while (1) {
    fgets(line, 400, temp_file);
    if (feof(temp_file))
      break;
    line[strlen(line) - 1] = '\0';
    fwrite(line, sizeof(char), strlen(line), daemon_file);
    fwrite("\n", sizeof(char), 1, daemon_file);
  }
  close(temp_fd);
  fclose(temp_file);
  fclose(daemon_file);
  retval = unlink(temp_file_path);
  if (retval == -1) {
    perror("      Error while unlinking the temporary file (update error) ");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<update_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2240,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2040(%rbp)
lea    0xdb3(%rip),%rdi
lea    0xdbd(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
jne    1284 <update_file+0x64>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
lea    -0x21d0(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x21d0(%rbp),%rdi
call   10e0 <mkstemp@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0xffffffff,-0x2024(%rbp)
jne    12d7 <update_file+0xb7>
lea    0xd92(%rip),%rdi
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
mov    -0x2024(%rbp),%edi
lea    0xd2d(%rip),%rsi
call   1100 <fdopen@plt>
mov    %rax,-0x2038(%rbp)
cmp    $0x0,%rax
jne    1314 <update_file+0xf4>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
movb   $0x0,-0x2020(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x21d4(%rbp)
test   %eax,%eax
je     1346 <update_file+0x126>
jmp    1332 <update_file+0x112>
mov    -0x21d4(%rbp),%eax
sub    $0x4,%eax
je     1380 <update_file+0x160>
jmp    13ba <update_file+0x19a>
cmpl   $0x0,-0xc(%rbp)
jne    1368 <update_file+0x148>
lea    -0x2020(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1130 <strcat@plt>
jmp    137b <update_file+0x15b>
lea    -0x2020(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   1130 <strcat@plt>
jmp    13d7 <update_file+0x1b7>
cmpl   $0x0,-0xc(%rbp)
jne    13a2 <update_file+0x182>
lea    -0x2020(%rbp),%rdi
lea    0xd41(%rip),%rsi
call   1130 <strcat@plt>
jmp    13b5 <update_file+0x195>
lea    -0x2020(%rbp),%rdi
lea    0xd38(%rip),%rsi
call   1130 <strcat@plt>
jmp    13d7 <update_file+0x1b7>
mov    -0xc(%rbp),%esi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
jmp    13dc <update_file+0x1bc>
lea    -0x1020(%rbp),%rdi
mov    -0x2030(%rbp),%rdx
mov    $0x1000,%esi
call   10b0 <fgets@plt>
mov    -0x2030(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%rax
je     140f <update_file+0x1ef>
jmp    164b <update_file+0x42b>
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    15f5 <update_file+0x3d5>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x21f4(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x21f0(%rbp)
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x21f4(%rbp),%edi
mov    -0x21f0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%edi
lea    0xc03(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x2030(%rbp),%rdx
mov    $0x1000,%esi
call   10b0 <fgets@plt>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x21e4(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x21e0(%rbp)
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x21e4(%rbp),%edi
mov    -0x21e0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x2030(%rbp),%rdx
mov    $0x1000,%esi
call   10b0 <fgets@plt>
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
call   10a0 <parse_app_opts@plt>
mov    %eax,-0x203c(%rbp)
movb   $0x0,-0x1020(%rbp)
mov    -0x203c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1584 <update_file+0x364>
mov    -0x203c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     156c <update_file+0x34c>
lea    -0x1020(%rbp),%rdi
lea    0xb61(%rip),%rsi
call   1130 <strcat@plt>
jmp    157f <update_file+0x35f>
lea    -0x1020(%rbp),%rdi
lea    0xb55(%rip),%rsi
call   1130 <strcat@plt>
jmp    1584 <update_file+0x364>
mov    -0x203c(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     15d8 <update_file+0x3b8>
mov    -0x203c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     15c0 <update_file+0x3a0>
lea    -0x1020(%rbp),%rdi
lea    0xb23(%rip),%rsi
call   1130 <strcat@plt>
jmp    15d3 <update_file+0x3b3>
lea    -0x1020(%rbp),%rdi
lea    0xb1a(%rip),%rsi
call   1130 <strcat@plt>
jmp    15d8 <update_file+0x3b8>
lea    -0x1020(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
call   1130 <strcat@plt>
movl   $0x1,-0x2040(%rbp)
mov    -0x2024(%rbp),%eax
mov    %eax,-0x2204(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x2200(%rbp)
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2204(%rbp),%edi
mov    -0x2200(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%edi
lea    0xa4f(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
jmp    13dc <update_file+0x1bc>
cmpl   $0x0,-0x2040(%rbp)
jne    173f <update_file+0x51f>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x2234(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x2230(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2234(%rbp),%edi
mov    -0x2230(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%edi
lea    0x9f2(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x2224(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x2220(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2224(%rbp),%edi
mov    -0x2220(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%edi
lea    0x9a7(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x2214(%rbp)
lea    -0x2020(%rbp),%rax
mov    %rax,-0x2210(%rbp)
lea    -0x2020(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2214(%rbp),%edi
mov    -0x2210(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x2024(%rbp),%edi
lea    0x956(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x2030(%rbp),%rdi
call   1060 <fclose@plt>
lea    0x8ae(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x2028(%rbp)
cmpl   $0xffffffff,-0x2028(%rbp)
jne    1782 <update_file+0x562>
lea    0x9c0(%rip),%rdi
call   1120 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
lea    0x877(%rip),%rdi
lea    0x9d9(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
jne    17c0 <update_file+0x5a0>
lea    0x9bf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
mov    -0x2038(%rbp),%rdi
mov    0x2812(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %eax,-0x2028(%rbp)
cmpl   $0xffffffff,-0x2028(%rbp)
jne    1804 <update_file+0x5e4>
lea    0x9bc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
jmp    1809 <update_file+0x5e9>
lea    -0x1020(%rbp),%rdi
mov    -0x2038(%rbp),%rdx
mov    $0x190,%esi
call   10b0 <fgets@plt>
mov    -0x2038(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%rax
je     183c <update_file+0x61c>
jmp    18a8 <update_file+0x688>
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x2240(%rbp)
lea    -0x1020(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x2240(%rbp),%rdi
mov    %eax,%edx
mov    -0x2030(%rbp),%rcx
mov    $0x1,%esi
call   1140 <fwrite@plt>
mov    -0x2030(%rbp),%rcx
lea    0x7f4(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1140 <fwrite@plt>
jmp    1809 <update_file+0x5e9>
mov    -0x2024(%rbp),%edi
call   1090 <close@plt>
mov    -0x2038(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x2030(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x21d0(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x2028(%rbp)
cmpl   $0xffffffff,-0x2028(%rbp)
jne    1902 <update_file+0x6e2>
lea    0x8f4(%rip),%rdi
call   1120 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1909 <update_file+0x6e9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x21a8,%rsp
mov    %rcx,%rbp
mov    %rdx,%r12
mov    %esi,%r15d
mov    %edi,%r14d
lea    0xd9c(%rip),%rdi
lea    0xda6(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     12e4 <update_file+0xa4>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
lea    0xd8f(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1100 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     12f5 <update_file+0xb5>
mov    %eax,%r13d
lea    0xd69(%rip),%rsi
mov    %eax,%edi
call   1120 <fdopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     130f <update_file+0xcf>
movb   $0x0,0x1a0(%rsp)
movsbl %r14b,%eax
cmp    $0x4,%eax
je     1320 <update_file+0xe0>
test   %eax,%eax
jne    13f3 <update_file+0x1b3>
test   %r15d,%r15d
lea    0xd8a(%rip),%rax
lea    0xd8f(%rip),%rsi
jmp    1331 <update_file+0xf1>
lea    0xf0e(%rip),%rdi
call   1050 <puts@plt>
jmp    1691 <update_file+0x451>
lea    0xd2b(%rip),%rdi
lea    0xcfd(%rip),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1691 <update_file+0x451>
lea    0xeae(%rip),%rdi
call   1050 <puts@plt>
jmp    1691 <update_file+0x451>
test   %r15d,%r15d
lea    0xd51(%rip),%rax
lea    0xd59(%rip),%rsi
cmove  %rax,%rsi
lea    0x1a0(%rsp),%rdi
call   1150 <strcat@plt>
lea    0x11a0(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
je     140e <update_file+0x1ce>
mov    %r12,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xcdc(%rip),%r14
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
lea    0x1a0(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
jmp    1572 <update_file+0x332>
lea    0xc9d(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x3,%eax
jmp    1696 <update_file+0x456>
xor    %r14d,%r14d
lea    0xc4b(%rip),%r15
jmp    147c <update_file+0x23c>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0x1a0(%rsp),%rsi
call   1150 <strcat@plt>
mov    $0x1,%r14d
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
jne    1569 <update_file+0x329>
mov    %rbp,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
mov    %r12,%rsi
call   10e0 <strcmp@plt>
test   %eax,%eax
jne    1436 <update_file+0x1f6>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <parse_app_opts@plt>
mov    %eax,%r14d
movb   $0x0,0x11a0(%rsp)
test   $0x4,%r14b
je     153c <update_file+0x2fc>
test   $0x1,%r14b
lea    0xb3c(%rip),%rsi
lea    0xb41(%rip),%rax
cmove  %rax,%rsi
mov    %rbp,%rdi
call   1150 <strcat@plt>
test   $0x8,%r14b
je     1420 <update_file+0x1e0>
test   $0x2,%r14b
lea    0xb2a(%rip),%rsi
lea    0xb32(%rip),%rax
cmove  %rax,%rsi
mov    %rbp,%rdi
call   1150 <strcat@plt>
jmp    1420 <update_file+0x1e0>
test   %r14d,%r14d
je     136b <update_file+0x12b>
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xa7f(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     1685 <update_file+0x445>
lea    0xa6a(%rip),%rdi
lea    0xb6e(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     1669 <update_file+0x429>
mov    %rax,%r14
mov    0x2a2b(%rip),%rax
mov    (%rax),%edx
mov    (%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1110 <fseek@plt>
cmp    $0xffffffff,%eax
je     1677 <update_file+0x437>
lea    0x11a0(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x190,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
mov    %rbx,%rdi
call   10f0 <feof@plt>
test   %rax,%rax
jne    1635 <update_file+0x3f5>
mov    %rbp,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   1160 <fwrite@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10b0 <fputc@plt>
jmp    15e0 <update_file+0x3a0>
mov    %r13d,%edi
call   10a0 <close@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
lea    0x10(%rsp),%rdi
call   1030 <unlink@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    1696 <update_file+0x456>
lea    0xaa7(%rip),%rdi
jmp    168c <update_file+0x44c>
lea    0xb14(%rip),%rdi
call   1050 <puts@plt>
jmp    1691 <update_file+0x451>
lea    0xacf(%rip),%rdi
call   1050 <puts@plt>
jmp    1691 <update_file+0x451>
lea    0xa47(%rip),%rdi
call   1140 <perror@plt>
mov    $0xffffffff,%eax
add    $0x21a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"/etc/daemon.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [40 x i8] c" OOPS. Could not open daemon_conf\0A\00"
@.str.3 = [20 x i8] c"/tmp/tuxtmpXXXXXXXX\00"
@.str.4 = [62 x i8] c" OOPS. Could not open temporary file while updating %s \0A\00"
@.str.5 = [54 x i8] c" OOPS. Could not stream-open the temporary file\0A\00"
@.str.6 = [12 x i8] c"PERMIT_APP \00"
@.str.7 = [10 x i8] c"DENY_APP \00"
@.str.8 = [15 x i8] c"PERMIT_SERVER \00"
@.str.9 = [13 x i8] c"DENY_SERVER \00"
@.str.10 = [60 x i8] c" Trying to update file with unknown permissions (%d)!\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [56 x i8] c" Error while unlinking daemon_conf (update error) \00"
@.str.13 = [3 x i8] c"w+\00"
@.str.14 = [65 x i8] c" OOPS. Could not create the new daemon_conf (update error)\0A\00"
@SEEK_SET = global i32 0
@.str.15 = [56 x i8] c" OOPS. Could not reposition stream (update error)\0A\00"
@.str.16 = [63 x i8] c" Error while unlinking the temporary file (update error) \00"
define i32 @update_file(i8 signext %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [4096 x i8]
%11 = alloca [4096 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca [400 x i8]
store i8 %0, i8* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 0, i32* %17
%19 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %14
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
23: ; preds = %4
%24 = getelementptr inbounds [400 x i8], [400 x i8]* %18, i64 0, i64 0
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds [400 x i8], [400 x i8]* %18, i64 0, i64 0
%27 = call i32 @mkstemp(i8* %26)
store i32 %27, i32* %12
%28 = load i32, i32* %12
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
32: ; preds = %23
%33 = load i32, i32* %12
%34 = call i32* @fdopen(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %15
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
38: ; preds = %32
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8 0, i8* %39
%40 = load i8, i8* %6
%41 = sext i8 %40 to i32
switch i32 %41, label %62 [
i32 0, label %42
i32 4, label %52
]
42: ; preds = %38
%43 = load i32, i32* %7
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %51
48: ; preds = %42
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %48, %45
br label %65
52: ; preds = %38
%53 = load i32, i32* %7
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %61
58: ; preds = %52
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%60 = call i32 @strcat(i8* %59, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %61
61: ; preds = %58, %55
br label %65
62: ; preds = %38
%63 = load i32, i32* %7
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.10, i64 0, i64 0), i32 %63)
store i32 3, i32* %5
br label %234
65: ; preds = %61, %51
br label %66
66: ; preds = %65, %144
%67 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%68 = load i32*, i32** %14
%69 = call i32 @fgets(i8* %67, i32 4096, i32* %68)
%70 = load i32*, i32** %14
%71 = call i64 @feof(i32* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %66
br label %152
74: ; preds = %66
%75 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = sub nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 %78
store i8 0, i8* %79
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%81 = load i8*, i8** %8
%82 = call i32 @strcmp(i8* %80, i8* %81)
%83 = icmp ne i32 %82, 0
br i1 %83, label %144, label %84
84: ; preds = %74
%85 = load i32, i32* %12
%86 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%88 = call i32 @strlen(i8* %87)
%89 = call i32 @write(i32 %85, i8* %86, i32 %88)
%90 = load i32, i32* %12
%91 = call i32 @write(i32 %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%93 = load i32*, i32** %14
%94 = call i32 @fgets(i8* %92, i32 4096, i32* %93)
%95 = load i32, i32* %12
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%98 = call i32 @strlen(i8* %97)
%99 = call i32 @write(i32 %95, i8* %96, i32 %98)
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%101 = load i32*, i32** %14
%102 = call i32 @fgets(i8* %100, i32 4096, i32* %101)
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%104 = call i32 @strlen(i8* %103)
%105 = sub nsw i32 %104, 1
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 %106
store i8 0, i8* %107
%108 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%109 = call i32 @parse_app_opts(i8* %108, i32 0)
store i32 %109, i32* %16
%110 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
store i8 0, i8* %110
%111 = load i32, i32* %16
%112 = and i32 %111, 4
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %125
114: ; preds = %84
%115 = load i32, i32* %16
%116 = and i32 %115, 1
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %114
%119 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%120 = call i32 @strcat(i8* %119, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %124
121: ; preds = %114
%122 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%123 = call i32 @strcat(i8* %122, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %124
124: ; preds = %121, %118
br label %125
125: ; preds = %124, %84
%126 = load i32, i32* %16
%127 = and i32 %126, 8
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %140
129: ; preds = %125
%130 = load i32, i32* %16
%131 = and i32 %130, 2
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %129
%134 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%135 = call i32 @strcat(i8* %134, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %139
136: ; preds = %129
%137 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%138 = call i32 @strcat(i8* %137, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %139
139: ; preds = %136, %133
br label %140
140: ; preds = %139, %125
%141 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%142 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%143 = call i32 @strcat(i8* %141, i8* %142)
store i32 1, i32* %17
br label %144
144: ; preds = %140, %74
%145 = load i32, i32* %12
%146 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%147 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%148 = call i32 @strlen(i8* %147)
%149 = call i32 @write(i32 %145, i8* %146, i32 %148)
%150 = load i32, i32* %12
%151 = call i32 @write(i32 %150, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
br label %66
152: ; preds = %73
%153 = load i32, i32* %17
%154 = icmp ne i32 %153, 0
br i1 %154, label %177, label %155
155: ; preds = %152
%156 = load i32, i32* %12
%157 = load i8*, i8** %8
%158 = load i8*, i8** %8
%159 = call i32 @strlen(i8* %158)
%160 = call i32 @write(i32 %156, i8* %157, i32 %159)
%161 = load i32, i32* %12
%162 = call i32 @write(i32 %161, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%163 = load i32, i32* %12
%164 = load i8*, i8** %9
%165 = load i8*, i8** %9
%166 = call i32 @strlen(i8* %165)
%167 = call i32 @write(i32 %163, i8* %164, i32 %166)
%168 = load i32, i32* %12
%169 = call i32 @write(i32 %168, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%170 = load i32, i32* %12
%171 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%172 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%173 = call i32 @strlen(i8* %172)
%174 = call i32 @write(i32 %170, i8* %171, i32 %173)
%175 = load i32, i32* %12
%176 = call i32 @write(i32 %175, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
br label %177
177: ; preds = %155, %152
%178 = load i32*, i32** %14
%179 = call i32 @fclose(i32* %178)
%180 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %180, i32* %13
%181 = load i32, i32* %13
%182 = icmp eq i32 %181, -1
br i1 %182, label %183, label %185
183: ; preds = %177
%184 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
185: ; preds = %177
%186 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
store i32* %186, i32** %14
%187 = icmp eq i32* %186, null
br i1 %187, label %188, label %190
188: ; preds = %185
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.14, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
190: ; preds = %185
%191 = load i32*, i32** %15
%192 = load i32, i32* @SEEK_SET
%193 = call i32 @fseek(i32* %191, i32 0, i32 %192)
store i32 %193, i32* %13
%194 = load i32, i32* %13
%195 = icmp eq i32 %194, -1
br i1 %195, label %196, label %198
196: ; preds = %190
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.15, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
198: ; preds = %190
br label %199
199: ; preds = %198, %207
%200 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%201 = load i32*, i32** %15
%202 = call i32 @fgets(i8* %200, i32 400, i32* %201)
%203 = load i32*, i32** %15
%204 = call i64 @feof(i32* %203)
%205 = icmp ne i64 %204, 0
br i1 %205, label %206, label %207
206: ; preds = %199
br label %220
207: ; preds = %199
%208 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%209 = call i32 @strlen(i8* %208)
%210 = sub nsw i32 %209, 1
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 %211
store i8 0, i8* %212
%213 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%214 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%215 = call i32 @strlen(i8* %214)
%216 = load i32*, i32** %14
%217 = call i32 @fwrite(i8* %213, i32 1, i32 %215, i32* %216)
%218 = load i32*, i32** %14
%219 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1, i32 1, i32* %218)
br label %199
220: ; preds = %206
%221 = load i32, i32* %12
%222 = call i32 @close(i32 %221)
%223 = load i32*, i32** %15
%224 = call i32 @fclose(i32* %223)
%225 = load i32*, i32** %14
%226 = call i32 @fclose(i32* %225)
%227 = getelementptr inbounds [400 x i8], [400 x i8]* %18, i64 0, i64 0
%228 = call i32 @unlink(i8* %227)
store i32 %228, i32* %13
%229 = load i32, i32* %13
%230 = icmp eq i32 %229, -1
br i1 %230, label %231, label %233
231: ; preds = %220
%232 = call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.16, i64 0, i64 0))
store i32 -1, i32* %5
br label %234
233: ; preds = %220
store i32 0, i32* %5
br label %234
234: ; preds = %233, %231, %196, %188, %183, %62, %36, %30, %21
%235 = load i32, i32* %5
ret i32 %235
}

LLVM IR (-O2):
@.str = [17 x i8] c"/etc/daemon.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [20 x i8] c"/tmp/tuxtmpXXXXXXXX\00"
@.str.4 = [62 x i8] c" OOPS. Could not open temporary file while updating %s \0A\00"
@.str.6 = [12 x i8] c"PERMIT_APP \00"
@.str.7 = [10 x i8] c"DENY_APP \00"
@.str.8 = [15 x i8] c"PERMIT_SERVER \00"
@.str.9 = [13 x i8] c"DENY_SERVER \00"
@.str.10 = [60 x i8] c" Trying to update file with unknown permissions (%d)!\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [56 x i8] c" Error while unlinking daemon_conf (update error) \00"
@.str.13 = [3 x i8] c"w+\00"
@SEEK_SET = global i32 0
@.str.16 = [63 x i8] c" Error while unlinking the temporary file (update error) \00"
@str = [55 x i8] c" OOPS. Could not reposition stream (update error)\00"
@str.17 = [64 x i8] c" OOPS. Could not create the new daemon_conf (update error)\00"
@str.18 = [53 x i8] c" OOPS. Could not stream-open the temporary file\00"
@str.19 = [39 x i8] c" OOPS. Could not open daemon_conf\00"
define i32 @update_file(i8 signext %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = alloca [400 x i8]
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [400 x i8], [400 x i8]* %7, i64 0, i64 0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.19, i64 0, i64 0))
br label %140
15: ; preds = %4
%16 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @mkstemp(i8* %10)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %140
21: ; preds = %15
%22 = call i32* @fdopen(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.18, i64 0, i64 0))
br label %140
26: ; preds = %21
store i8 0, i8* %9
%27 = sext i8 %0 to i32
switch i32 %27, label %34 [
i32 0, label %28
i32 4, label %31
]
28: ; preds = %26
%29 = icmp eq i32 %1, 0
%30 = select i1 %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0)
br label %36
31: ; preds = %26
%32 = icmp eq i32 %1, 0
%33 = select i1 %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0)
br label %36
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.10, i64 0, i64 0), i32 %1)
br label %140
36: ; preds = %31, %28
%37 = phi i8* [ %30, %28 ], [ %33, %31 ]
%38 = call i32 @strcat(i8* %9, i8* %37)
%39 = call i32 @fgets(i8* %8, i32 4096, i32* %11)
%40 = call i64 @feof(i32* %11)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %90
42: ; preds = %36, %80
%43 = phi i32 [ %81, %80 ], [ 0, %36 ]
%44 = call i32 @strlen(i8* %8)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %46
store i8 0, i8* %47
%48 = call i32 @strcmp(i8* %8, i8* dereferenceable(1) %2)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %80
50: ; preds = %42
%51 = call i32 @strlen(i8* %8)
%52 = call i32 @write(i32 %17, i8* %8, i32 %51)
%53 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%54 = call i32 @fgets(i8* %8, i32 4096, i32* %11)
%55 = call i32 @strlen(i8* %8)
%56 = call i32 @write(i32 %17, i8* %8, i32 %55)
%57 = call i32 @fgets(i8* %8, i32 4096, i32* %11)
%58 = call i32 @strlen(i8* %8)
%59 = add nsw i32 %58, -1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %60
store i8 0, i8* %61
%62 = call i32 @parse_app_opts(i8* %8, i32 0)
store i8 0, i8* %8
%63 = and i32 %62, 4
%64 = icmp eq i32 %63, 0
br i1 %64, label %70, label %65
65: ; preds = %50
%66 = and i32 %62, 1
%67 = icmp eq i32 %66, 0
%68 = select i1 %67, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0)
%69 = call i32 @strcat(i8* %8, i8* %68)
br label %70
70: ; preds = %65, %50
%71 = and i32 %62, 8
%72 = icmp eq i32 %71, 0
br i1 %72, label %78, label %73
73: ; preds = %70
%74 = and i32 %62, 2
%75 = icmp eq i32 %74, 0
%76 = select i1 %75, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0)
%77 = call i32 @strcat(i8* %8, i8* %76)
br label %78
78: ; preds = %73, %70
%79 = call i32 @strcat(i8* %8, i8* %9)
br label %80
80: ; preds = %78, %42
%81 = phi i32 [ %43, %42 ], [ 1, %78 ]
%82 = call i32 @strlen(i8* %8)
%83 = call i32 @write(i32 %17, i8* %8, i32 %82)
%84 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%85 = call i32 @fgets(i8* %8, i32 4096, i32* %11)
%86 = call i64 @feof(i32* %11)
%87 = icmp eq i64 %86, 0
br i1 %87, label %42, label %88
88: ; preds = %80
%89 = icmp eq i32 %81, 0
br i1 %89, label %90, label %100
90: ; preds = %36, %88
%91 = call i32 @strlen(i8* %2)
%92 = call i32 @write(i32 %17, i8* %2, i32 %91)
%93 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%94 = call i32 @strlen(i8* %3)
%95 = call i32 @write(i32 %17, i8* %3, i32 %94)
%96 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%97 = call i32 @strlen(i8* %9)
%98 = call i32 @write(i32 %17, i8* %9, i32 %97)
%99 = call i32 @write(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
br label %100
100: ; preds = %90, %88
%101 = call i32 @fclose(i32* %11)
%102 = call i32 @unlink(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %100
%105 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
br label %140
106: ; preds = %100
%107 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%108 = icmp eq i32* %107, null
br i1 %108, label %109, label %111
109: ; preds = %106
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.17, i64 0, i64 0))
br label %140
111: ; preds = %106
%112 = load i32, i32* @SEEK_SET
%113 = call i32 @fseek(i32* %22, i32 0, i32 %112)
%114 = icmp eq i32 %113, -1
br i1 %114, label %119, label %115
115: ; preds = %111
%116 = call i32 @fgets(i8* %8, i32 400, i32* %22)
%117 = call i64 @feof(i32* %22)
%118 = icmp eq i64 %117, 0
br i1 %118, label %121, label %132
119: ; preds = %111
%120 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
br label %140
121: ; preds = %115, %121
%122 = call i32 @strlen(i8* %8)
%123 = add nsw i32 %122, -1
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 %124
store i8 0, i8* %125
%126 = call i32 @strlen(i8* %8)
%127 = call i32 @fwrite(i8* %8, i32 1, i32 %126, i32* %107)
%128 = call i32 @fputc(i32 10, i32* %107)
%129 = call i32 @fgets(i8* %8, i32 400, i32* %22)
%130 = call i64 @feof(i32* %22)
%131 = icmp eq i64 %130, 0
br i1 %131, label %121, label %132
132: ; preds = %121, %115
%133 = call i32 @close(i32 %17)
%134 = call i32 @fclose(i32* %22)
%135 = call i32 @fclose(i32* %107)
%136 = call i32 @unlink(i8* %10)
%137 = icmp eq i32 %136, -1
br i1 %137, label %138, label %140
138: ; preds = %132
%139 = call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.16, i64 0, i64 0))
br label %140
140: ; preds = %132, %138, %119, %109, %104, %34, %24, %19, %13
%141 = phi i32 [ -1, %13 ], [ -1, %19 ], [ -1, %24 ], [ 3, %34 ], [ -1, %104 ], [ -1, %109 ], [ -1, %119 ], [ -1, %138 ], [ 0, %132 ]
ret i32 %141
}