#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 EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ addevent(char *, char *, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ die(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char *strcpy(char *, char *);
int strlen(char *);
scalar_t__ strpbrk(char *, char *);
int /*<<< orphan*/ strtok_r(char *, char const *, char **);
int strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *tmpfile();
void moveevent(char *event, char *database, int status, int errno) {
  int eventid = -1;
  char *saveptr = NULL;
  char *time = NULL;
  FILE *fd, *fd_temp;
  int nread;
  char *buffer = NULL;
  int pos = 1;
  size_t len = 0;
  char *desc = NULL;
  if (!(strpbrk(event, "|"))) {
    die(EXIT_FAILURE, 12);
  }
  eventid = strtol(strtok_r(event, (const char *)"|", &saveptr), NULL, 10);
  time = malloc(strlen(saveptr) + 1);
  time = strcpy(time, saveptr);
  assert(database != NULL);
  fd = fopen(database, "r");
  fd_temp = tmpfile();
  while ((nread = getline(&buffer, &len, fd)) != -1) {
    if (eventid != pos && buffer != NULL) {
      fprintf(fd_temp, "%s", buffer);
    } else if (eventid == pos) {
      strtok_r(buffer, "|", &saveptr);
      if (strpbrk(saveptr, "|")) {
        strtok_r(NULL, "|", &saveptr);
      }
      desc = malloc(strlen(saveptr) + 1);
      desc = strcpy(desc, saveptr);
    }
    pos++;
  }
  free(buffer);
  fclose(fd);
  fseek(fd_temp, 0, SEEK_SET);
  fd = fopen(database, "w+");
  buffer = (char *)malloc(1024);
  pos = ftell(fd_temp);
  while ((nread = getline(&buffer, &len, fd_temp)) != -1) {
    fprintf(fd, "%s", buffer);
  }
  free(buffer);
  fclose(fd_temp);
  fclose(fd);
  event = malloc(strlen(time) + strlen(desc) + 2);
  sprintf(event,
          "%s"
          "|"
          "%s",
          time, desc);
  free(desc);
  free(time);
  addevent(event, database, EXIT_SUCCESS, 0);
  die(status, errno);
}


x86 assembly (clang, -O0):
<moveevent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   10f0 <strpbrk@plt>
cmp    $0x0,%rax
jne    1299 <moveevent+0x79>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    $0xc,%esi
call   1120 <die@plt>
mov    -0x8(%rbp),%rdi
lea    0xd5c(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <strtok_r@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1090 <tmpfile@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdx
lea    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1130 <getline@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     13ef <moveevent+0x1cf>
mov    -0x1c(%rbp),%eax
cmp    -0x54(%rbp),%eax
je     1366 <moveevent+0x146>
cmpq   $0x0,-0x50(%rbp)
je     1366 <moveevent+0x146>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xcae(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    13e1 <moveevent+0x1c1>
mov    -0x1c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jne    13dc <moveevent+0x1bc>
mov    -0x50(%rbp),%rdi
lea    0xc83(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <strtok_r@plt>
mov    -0x28(%rbp),%rdi
lea    0xc6f(%rip),%rsi
call   10f0 <strpbrk@plt>
cmp    $0x0,%rax
je     13b4 <moveevent+0x194>
xor    %eax,%eax
mov    %eax,%edi
lea    0xc55(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <strtok_r@plt>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x68(%rbp)
jmp    13e1 <moveevent+0x1c1>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1319 <moveevent+0xf9>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
mov    0x2bd4(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1100 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    0xbe4(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    $0x400,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdx
lea    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1130 <getline@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     1479 <moveevent+0x259>
mov    -0x38(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xb9b(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    1443 <moveevent+0x223>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x6c(%rbp),%edi
add    %eax,%edi
add    $0x2,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x68(%rbp),%rcx
lea    0xb3a(%rip),%rsi
call   1140 <sprintf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2add(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1070 <addevent@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1120 <die@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moveevent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,0x24(%rsp)
mov    %edx,0x20(%rsp)
mov    %rsi,%rbp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xda3(%rip),%rsi
call   10f0 <strpbrk@plt>
test   %rax,%rax
jne    127a <moveevent+0x5a>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    $0xc,%esi
call   1120 <die@plt>
lea    0xd7f(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1090 <strtok_r@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    $0xa,%edx
call   10d0 <strtol@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   10e0 <malloc@plt>
mov    0x8(%rsp),%rsi
mov    %rax,0x28(%rsp)
mov    %rax,%rdi
call   1040 <strcpy@plt>
xor    %edi,%edi
test   %rbp,%rbp
setne  %dil
call   10b0 <assert@plt>
lea    0xd2a(%rip),%rsi
mov    %rbp,0x30(%rsp)
mov    %rbp,%rdi
xor    %eax,%eax
mov    %rax,0x18(%rsp)
call   1110 <fopen@plt>
mov    %rax,%r15
xor    %eax,%eax
call   10a0 <tmpfile@plt>
mov    %rax,%r12
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    %r15,%rdx
call   1130 <getline@plt>
cmp    $0xffffffff,%eax
je     13c5 <moveevent+0x1a5>
add    $0xffffffff,%r14d
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    %rsp,%r13
lea    0x10(%rsp),%rbp
jmp    134b <moveevent+0x12b>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rsi
call   1070 <fputs@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1130 <getline@plt>
cmp    $0xffffffff,%eax
je     13c5 <moveevent+0x1a5>
mov    %r14d,%eax
mov    (%rsp),%rdi
add    $0xffffffff,%r14d
jae    135d <moveevent+0x13d>
test   %rdi,%rdi
jne    1330 <moveevent+0x110>
test   %eax,%eax
jne    1338 <moveevent+0x118>
lea    0xc98(%rip),%rbp
mov    %rbp,%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdx
call   1090 <strtok_r@plt>
mov    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   10f0 <strpbrk@plt>
test   %rax,%rax
je     1397 <moveevent+0x177>
xor    %edi,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1090 <strtok_r@plt>
mov    0x8(%rsp),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   10e0 <malloc@plt>
mov    0x8(%rsp),%rsi
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rbp
jmp    1338 <moveevent+0x118>
mov    0x18(%rsp),%r13
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1100 <fseek@plt>
lea    0xc0f(%rip),%rsi
mov    0x30(%rsp),%r15
mov    %r15,%rdi
call   1110 <fopen@plt>
mov    %rax,%rbx
mov    $0x400,%edi
call   10e0 <malloc@plt>
mov    %rax,(%rsp)
mov    %r12,%rdi
call   10c0 <ftell@plt>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    %r12,%rdx
call   1130 <getline@plt>
cmp    $0xffffffff,%eax
je     145f <moveevent+0x23f>
mov    %rsp,%r14
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1070 <fputs@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1130 <getline@plt>
cmp    $0xffffffff,%eax
jne    1440 <moveevent+0x220>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x28(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    (%r14,%rax,1),%edi
add    $0x2,%edi
call   10e0 <malloc@plt>
mov    %rax,%r14
lea    0xb61(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r13,%rcx
call   1140 <sprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x2b05(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %ecx,%ecx
call   1080 <addevent@plt>
mov    0x20(%rsp),%edi
mov    0x24(%rsp),%esi
call   1120 <die@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [6 x i8] c"%s|%s\00"
@EXIT_SUCCESS = global i32 0
define void @moveevent(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i64
%18 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 -1, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %15
store i32 1, i32* %16
store i64 0, i64* %17
store i8* null, i8** %18
%19 = load i8*, i8** %5
%20 = call i64 @strpbrk(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %4
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @die(i32 %23, i32 12)
br label %25
25: ; preds = %22, %4
%26 = load i8*, i8** %5
%27 = call i32 @strtok_r(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
%28 = call i32 @strtol(i32 %27, i32* null, i32 10)
store i32 %28, i32* %9
%29 = load i8*, i8** %10
%30 = call i32 @strlen(i8* %29)
%31 = add nsw i32 %30, 1
%32 = call i8* @malloc(i32 %31)
store i8* %32, i8** %11
%33 = load i8*, i8** %11
%34 = load i8*, i8** %10
%35 = call i8* @strcpy(i8* %33, i8* %34)
store i8* %35, i8** %11
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i8*, i8** %6
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %12
%42 = call i32* (...) @tmpfile()
store i32* %42, i32** %13
br label %43
43: ; preds = %79, %25
%44 = load i32*, i32** %12
%45 = call i32 @getline(i8** %15, i64* %17, i32* %44)
store i32 %45, i32* %14
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %82
47: ; preds = %43
%48 = load i32, i32* %9
%49 = load i32, i32* %16
%50 = icmp ne i32 %48, %49
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load i8*, i8** %15
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i32*, i32** %13
%56 = load i8*, i8** %15
%57 = call i32 @fprintf(i32* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %56)
br label %79
58: ; preds = %51, %47
%59 = load i32, i32* %9
%60 = load i32, i32* %16
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %78
62: ; preds = %58
%63 = load i8*, i8** %15
%64 = call i32 @strtok_r(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
%65 = load i8*, i8** %10
%66 = call i64 @strpbrk(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %62
%69 = call i32 @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %10)
br label %70
70: ; preds = %68, %62
%71 = load i8*, i8** %10
%72 = call i32 @strlen(i8* %71)
%73 = add nsw i32 %72, 1
%74 = call i8* @malloc(i32 %73)
store i8* %74, i8** %18
%75 = load i8*, i8** %18
%76 = load i8*, i8** %10
%77 = call i8* @strcpy(i8* %75, i8* %76)
store i8* %77, i8** %18
br label %78
78: ; preds = %70, %58
br label %79
79: ; preds = %78, %54
%80 = load i32, i32* %16
%81 = add nsw i32 %80, 1
store i32 %81, i32* %16
br label %43
82: ; preds = %43
%83 = load i8*, i8** %15
%84 = call i32 @free(i8* %83)
%85 = load i32*, i32** %12
%86 = call i32 @fclose(i32* %85)
%87 = load i32*, i32** %13
%88 = load i32, i32* @SEEK_SET
%89 = call i32 @fseek(i32* %87, i32 0, i32 %88)
%90 = load i8*, i8** %6
%91 = call i32* @fopen(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %91, i32** %12
%92 = call i8* @malloc(i32 1024)
store i8* %92, i8** %15
%93 = load i32*, i32** %13
%94 = call i32 @ftell(i32* %93)
store i32 %94, i32* %16
br label %95
95: ; preds = %99, %82
%96 = load i32*, i32** %13
%97 = call i32 @getline(i8** %15, i64* %17, i32* %96)
store i32 %97, i32* %14
%98 = icmp ne i32 %97, -1
br i1 %98, label %99, label %103
99: ; preds = %95
%100 = load i32*, i32** %12
%101 = load i8*, i8** %15
%102 = call i32 @fprintf(i32* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %101)
br label %95
103: ; preds = %95
%104 = load i8*, i8** %15
%105 = call i32 @free(i8* %104)
%106 = load i32*, i32** %13
%107 = call i32 @fclose(i32* %106)
%108 = load i32*, i32** %12
%109 = call i32 @fclose(i32* %108)
%110 = load i8*, i8** %11
%111 = call i32 @strlen(i8* %110)
%112 = load i8*, i8** %18
%113 = call i32 @strlen(i8* %112)
%114 = add nsw i32 %111, %113
%115 = add nsw i32 %114, 2
%116 = call i8* @malloc(i32 %115)
store i8* %116, i8** %5
%117 = load i8*, i8** %5
%118 = load i8*, i8** %11
%119 = load i8*, i8** %18
%120 = call i32 @sprintf(i8* %117, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %118, i8* %119)
%121 = load i8*, i8** %18
%122 = call i32 @free(i8* %121)
%123 = load i8*, i8** %11
%124 = call i32 @free(i8* %123)
%125 = load i8*, i8** %5
%126 = load i8*, i8** %6
%127 = load i32, i32* @EXIT_SUCCESS
%128 = call i32 @addevent(i8* %125, i8* %126, i32 %127, i32 0)
%129 = load i32, i32* %7
%130 = load i32, i32* %8
%131 = call i32 @die(i32 %129, i32 %130)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"|\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [6 x i8] c"%s|%s\00"
@EXIT_SUCCESS = global i32 0
define void @moveevent(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%9 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%10 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%11 = tail call i64 @strpbrk(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @die(i32 %14, i32 12)
br label %16
16: ; preds = %13, %4
%17 = call i32 @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
%18 = call i32 @strtol(i32 %17, i32* null, i32 10)
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %20, 1
%22 = call i8* @malloc(i32 %21)
%23 = load i8*, i8** %5
%24 = call i8* @strcpy(i8* dereferenceable(1) %22, i8* dereferenceable(1) %23)
%25 = icmp ne i8* %1, null
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32* (...) @tmpfile()
%30 = call i32 @getline(i8** %6, i64* %7, i32* %28)
%31 = icmp eq i32 %30, -1
br i1 %31, label %62, label %32
32: ; preds = %16, %57
%33 = phi i8* [ %58, %57 ], [ null, %16 ]
%34 = phi i32 [ %59, %57 ], [ 1, %16 ]
%35 = icmp ne i32 %18, %34
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @fputs(i8* %36, i32* %29)
br label %57
41: ; preds = %32
%42 = icmp eq i32 %18, %34
br i1 %42, label %43, label %57
43: ; preds = %41
%44 = call i32 @strtok_r(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
%45 = load i8*, i8** %5
%46 = call i64 @strpbrk(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %43
%49 = call i32 @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
br label %50
50: ; preds = %48, %43
%51 = load i8*, i8** %5
%52 = call i32 @strlen(i8* %51)
%53 = add nsw i32 %52, 1
%54 = call i8* @malloc(i32 %53)
%55 = load i8*, i8** %5
%56 = call i8* @strcpy(i8* dereferenceable(1) %54, i8* dereferenceable(1) %55)
br label %57
57: ; preds = %41, %50, %39
%58 = phi i8* [ %33, %39 ], [ %54, %50 ], [ %33, %41 ]
%59 = add nuw nsw i32 %34, 1
%60 = call i32 @getline(i8** %6, i64* %7, i32* %28)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %32
62: ; preds = %57, %16
%63 = phi i8* [ null, %16 ], [ %58, %57 ]
%64 = load i8*, i8** %6
%65 = call i32 @free(i8* %64)
%66 = call i32 @fclose(i32* %28)
%67 = load i32, i32* @SEEK_SET
%68 = call i32 @fseek(i32* %29, i32 0, i32 %67)
%69 = call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%70 = call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
store i8* %70, i8** %6
%71 = call i32 @ftell(i32* %29)
%72 = call i32 @getline(i8** %6, i64* %7, i32* %29)
%73 = icmp eq i32 %72, -1
br i1 %73, label %79, label %74
74: ; preds = %62, %74
%75 = load i8*, i8** %6
%76 = call i32 @fputs(i8* %75, i32* %69)
%77 = call i32 @getline(i8** %6, i64* %7, i32* %29)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %74
79: ; preds = %74, %62
%80 = load i8*, i8** %6
%81 = call i32 @free(i8* %80)
%82 = call i32 @fclose(i32* %29)
%83 = call i32 @fclose(i32* %69)
%84 = call i32 @strlen(i8* %22)
%85 = call i32 @strlen(i8* %63)
%86 = add i32 %84, 2
%87 = add i32 %86, %85
%88 = call i8* @malloc(i32 %87)
%89 = call i32 @sprintf(i8* dereferenceable(1) %88, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %22, i8* %63)
%90 = call i32 @free(i8* %63)
%91 = call i32 @free(i8* %22)
%92 = load i32, i32* @EXIT_SUCCESS
%93 = call i32 @addevent(i8* %88, i8* %1, i32 %92, i32 0)
%94 = call i32 @die(i32 %2, i32 %3)
ret void
}