#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 stat {
  long st_size;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ encode(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fstat(int const, struct stat *);
int /*<<< orphan*/ ftruncate(int const, long);
long getpos(int const, char *);
int /*<<< orphan*/ lseek(int const, long, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int read(int const, char *, int);
int /*<<< orphan*/ recoverpos(int const, long);
int /*<<< orphan*/ savepos(int const, long, long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
int write(int const, char *, int);
void _edit(const int fd, int op, char *user) {
  char buf[1024], buf2[1024], tbuf[1024], *p;
  int nread, nread2, nwritn, is_first, len;
  long set_pos, save_pos, size;
  struct stat sb;
  len = 0;
  save_pos = 0;
  *buf2 = *tbuf = 0;
  ;
  set_pos = getpos(fd, user);
  if (op & 0x4 && set_pos != -1) {
    fprintf(stderr, "Exist same user %s.\n", user);
    exit(EXIT_FAILURE);
  } else if ((op & (0x2 | 0x8)) && set_pos < 0) {
    fprintf(stderr, "User %s does not exist.\n", user);
    exit(EXIT_FAILURE);
  };
  if (fstat(fd, &sb) == -1) {
    perror("fstat error: ");
    exit(EXIT_FAILURE);
  }
  size = sb.st_size;
  is_first = 1;
  lseek(fd, set_pos, SEEK_SET);
  nread = read(fd, buf, 1024);
  do {
    *(buf + nread) = 0;
    if (is_first) {
      if ((p = strchr(buf, '\n')) != NULL) {
        *p = 0;
        len = strlen(buf);
        if (op & 0x8) {
          encode(user);
          strcat(tbuf, user);
          strcat(tbuf, p + 1);
        } else if (op & 0x2) {
          strcat(tbuf, p + 1);
        }
        nread2 = read(fd, buf2, 1024);
        savepos(fd, set_pos, save_pos);
        nwritn = write(fd, tbuf, strlen(tbuf));
        recoverpos(fd, save_pos);
        memcpy(buf, buf2, 1024);
        nread = nread2;
        is_first = 0;
      } else {
        fprintf(stderr, "File format is incorrect.\n");
        exit(EXIT_FAILURE);
      }
    } else {
      set_pos += nwritn;
      nread2 = read(fd, buf2, 1024);
      savepos(fd, set_pos, save_pos);
      nwritn = write(fd, tbuf, strlen(tbuf));
      recoverpos(fd, save_pos);
      memcpy(buf, buf2, 1024);
      nread = nread2;
    }
  } while (nread > 0);
  if (op & 0x2)
    ftruncate(fd, size - len - 1);
}


x86 assembly (clang, -O0):
<_edit>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0xc2c(%rbp)
movq   $0x0,-0xc40(%rbp)
movb   $0x0,-0xc10(%rbp)
movb   $0x0,-0x810(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10d0 <getpos@plt>
mov    %rax,-0xc38(%rbp)
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1291 <_edit+0x91>
cmpq   $0xffffffffffffffff,-0xc38(%rbp)
ff
je     1291 <_edit+0x91>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x8(%rbp),%eax
and    $0xa,%eax
cmp    $0x0,%eax
je     12d7 <_edit+0xd7>
cmpq   $0x0,-0xc38(%rbp)
jge    12d7 <_edit+0xd7>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    12dc <_edit+0xdc>
mov    -0x4(%rbp),%edi
lea    -0xc50(%rbp),%rsi
call   1120 <fstat@plt>
cmp    $0xffffffff,%eax
jne    130e <_edit+0x10e>
lea    0xd33(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0xc50(%rbp),%rax
mov    %rax,-0xc48(%rbp)
movl   $0x1,-0xc28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc38(%rbp),%rsi
mov    0x2ca1(%rip),%rax
mov    (%rax),%edx
call   1080 <lseek@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0xc1c(%rbp)
movslq -0xc1c(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
cmpl   $0x0,-0xc28(%rbp)
je     14fa <_edit+0x2fa>
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,-0xc18(%rbp)
cmp    $0x0,%rax
je     14d0 <_edit+0x2d0>
mov    -0xc18(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc2c(%rbp)
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     13f6 <_edit+0x1f6>
mov    -0x10(%rbp),%rdi
call   1030 <encode@plt>
lea    -0xc10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1100 <strcat@plt>
lea    -0xc10(%rbp),%rdi
mov    -0xc18(%rbp),%rsi
add    $0x1,%rsi
call   1100 <strcat@plt>
jmp    1421 <_edit+0x221>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     141c <_edit+0x21c>
lea    -0xc10(%rbp),%rdi
mov    -0xc18(%rbp),%rsi
add    $0x1,%rsi
call   1100 <strcat@plt>
jmp    1421 <_edit+0x221>
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0xc20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc38(%rbp),%rsi
mov    -0xc40(%rbp),%rdx
call   10c0 <savepos@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc5c(%rbp)
lea    -0xc10(%rbp),%rax
mov    %rax,-0xc58(%rbp)
lea    -0xc10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xc5c(%rbp),%edi
mov    -0xc58(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0xc24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc40(%rbp),%rsi
call   10f0 <recoverpos@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <memcpy@plt>
mov    -0xc20(%rbp),%eax
mov    %eax,-0xc1c(%rbp)
movl   $0x0,-0xc28(%rbp)
jmp    14f5 <_edit+0x2f5>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
lea    0xb5c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
jmp    15af <_edit+0x3af>
movslq -0xc24(%rbp),%rax
add    -0xc38(%rbp),%rax
mov    %rax,-0xc38(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0xc20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc38(%rbp),%rsi
mov    -0xc40(%rbp),%rdx
call   10c0 <savepos@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc6c(%rbp)
lea    -0xc10(%rbp),%rax
mov    %rax,-0xc68(%rbp)
lea    -0xc10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xc6c(%rbp),%edi
mov    -0xc68(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0xc24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc40(%rbp),%rsi
call   10f0 <recoverpos@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <memcpy@plt>
mov    -0xc20(%rbp),%eax
mov    %eax,-0xc1c(%rbp)
jmp    15b4 <_edit+0x3b4>
cmpl   $0x0,-0xc1c(%rbp)
jg     1358 <_edit+0x158>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     15ed <_edit+0x3ed>
mov    -0x4(%rbp),%edi
mov    -0xc48(%rbp),%rsi
movslq -0xc2c(%rbp),%rax
sub    %rax,%rsi
sub    $0x1,%rsi
call   1070 <ftruncate@plt>
add    $0xc70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_edit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc28,%rsp
mov    %rdx,%r13
mov    %esi,%r14d
mov    %edi,%r15d
movb   $0x0,0x420(%rsp)
movb   $0x0,0x820(%rsp)
mov    %rdx,%rsi
call   10d0 <getpos@plt>
mov    %rax,%rbp
test   $0x4,%r14b
je     1245 <_edit+0x45>
cmp    $0xffffffffffffffff,%rbp
jne    1425 <_edit+0x225>
test   $0xa,%r14b
je     1254 <_edit+0x54>
test   %rbp,%rbp
js     1437 <_edit+0x237>
lea    0x18(%rsp),%rsi
mov    %r15d,%edi
call   1120 <fstat@plt>
cmp    $0xffffffff,%eax
je     1453 <_edit+0x253>
mov    0x18(%rsp),%r12
mov    0x2d62(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    %rbp,%rsi
call   1080 <lseek@plt>
lea    0x20(%rsp),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
cltq
movb   $0x0,0x20(%rsp,%rax,1)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1461 <_edit+0x261>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x20(%rsp),%rdi
call   1050 <strlen@plt>
test   $0x8,%r14b
mov    %r14d,0xc(%rsp)
mov    %r12,0x10(%rsp)
mov    %eax,0x8(%rsp)
jne    12e1 <_edit+0xe1>
test   $0x2,%r14b
jne    12f9 <_edit+0xf9>
jmp    130d <_edit+0x10d>
mov    %r13,%rdi
call   1030 <encode@plt>
lea    0x420(%rsp),%rdi
mov    %r13,%rsi
call   1100 <strcat@plt>
add    $0x1,%rbx
lea    0x420(%rsp),%rdi
mov    %rbx,%rsi
call   1100 <strcat@plt>
lea    0x820(%rsp),%r12
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
call   10c0 <savepos@plt>
lea    0x420(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,%r14d
mov    %r15d,%edi
xor    %esi,%esi
call   10f0 <recoverpos@plt>
lea    0x20(%rsp),%rdi
mov    %r12,%rsi
mov    $0x400,%edx
call   10b0 <memcpy@plt>
test   %ebx,%ebx
jle    13f4 <_edit+0x1f4>
lea    0x820(%rsp),%r13
lea    0x420(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
movb   $0x0,0x20(%rsp,%rax,1)
movslq %r14d,%rax
add    %rax,%rbp
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
call   10c0 <savepos@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,%r14d
mov    %r15d,%edi
xor    %esi,%esi
call   10f0 <recoverpos@plt>
lea    0x20(%rsp),%rdi
mov    %r13,%rsi
mov    $0x400,%edx
call   10b0 <memcpy@plt>
test   %ebx,%ebx
jg     1390 <_edit+0x190>
testb  $0x2,0xc(%rsp)
je     1413 <_edit+0x213>
mov    0x8(%rsp),%eax
not    %eax
cltq
mov    0x10(%rsp),%rsi
add    %rax,%rsi
mov    %r15d,%edi
call   1070 <ftruncate@plt>
add    $0xc28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
lea    0xbcb(%rip),%rsi
jmp    1447 <_edit+0x247>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
lea    0xbce(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1478 <_edit+0x278>
lea    0xbd4(%rip),%rdi
call   10e0 <perror@plt>
jmp    1478 <_edit+0x278>
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
lea    0xbcb(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2b51(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [21 x i8] c"Exist same user %s.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [25 x i8] c"User %s does not exist.\0A\00"
@.str.2 = [14 x i8] c"fstat error: \00"
@SEEK_SET = global i32 0
@.str.3 = [27 x i8] c"File format is incorrect.\0A\00"
define void @_edit(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca %struct.stat
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %15
store i64 0, i64* %17
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8 0, i8* %20
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8 0, i8* %21
%22 = load i32, i32* %4
%23 = load i8*, i8** %6
%24 = call i64 @getpos(i32 %22, i8* %23)
store i64 %24, i64* %16
%25 = load i32, i32* %5
%26 = and i32 %25, 4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %3
%29 = load i64, i64* %16
%30 = icmp ne i64 %29, -1
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %6
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %28, %3
%38 = load i32, i32* %5
%39 = and i32 %38, 10
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i64, i64* %16
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load i8*, i8** %6
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %41, %37
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = call i32 @fstat(i32 %52, %struct.stat* %19)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %51
%60 = getelementptr inbounds %struct.stat, %struct.stat* %19, i32 0, i32 0
%61 = load i64, i64* %60
store i64 %61, i64* %18
store i32 1, i32* %14
%62 = load i32, i32* %4
%63 = load i64, i64* %16
%64 = load i32, i32* @SEEK_SET
%65 = call i32 @lseek(i32 %62, i64 %63, i32 %64)
%66 = load i32, i32* %4
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%68 = call i32 @read(i32 %66, i8* %67, i32 1024)
store i32 %68, i32* %11
br label %69
69: ; preds = %158, %59
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%71 = load i32, i32* %11
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
store i8 0, i8* %73
%74 = load i32, i32* %14
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %133
76: ; preds = %69
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%78 = call i8* @strchr(i8* %77, i8 signext 10)
store i8* %78, i8** %10
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %127
80: ; preds = %76
%81 = load i8*, i8** %10
store i8 0, i8* %81
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
store i32 %83, i32* %15
%84 = load i32, i32* %5
%85 = and i32 %84, 8
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %97
87: ; preds = %80
%88 = load i8*, i8** %6
%89 = call i32 @encode(i8* %88)
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%91 = load i8*, i8** %6
%92 = call i32 @strcat(i8* %90, i8* %91)
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%94 = load i8*, i8** %10
%95 = getelementptr inbounds i8, i8* %94, i64 1
%96 = call i32 @strcat(i8* %93, i8* %95)
br label %107
97: ; preds = %80
%98 = load i32, i32* %5
%99 = and i32 %98, 2
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %97
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%103 = load i8*, i8** %10
%104 = getelementptr inbounds i8, i8* %103, i64 1
%105 = call i32 @strcat(i8* %102, i8* %104)
br label %106
106: ; preds = %101, %97
br label %107
107: ; preds = %106, %87
%108 = load i32, i32* %4
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%110 = call i32 @read(i32 %108, i8* %109, i32 1024)
store i32 %110, i32* %12
%111 = load i32, i32* %4
%112 = load i64, i64* %16
%113 = load i64, i64* %17
%114 = call i32 @savepos(i32 %111, i64 %112, i64 %113)
%115 = load i32, i32* %4
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%117 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%118 = call i32 @strlen(i8* %117)
%119 = call i32 @write(i32 %115, i8* %116, i32 %118)
store i32 %119, i32* %13
%120 = load i32, i32* %4
%121 = load i64, i64* %17
%122 = call i32 @recoverpos(i32 %120, i64 %121)
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%125 = call i32 @memcpy(i8* %123, i8* %124, i32 1024)
%126 = load i32, i32* %12
store i32 %126, i32* %11
store i32 0, i32* %14
br label %132
127: ; preds = %76
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %107
br label %157
133: ; preds = %69
%134 = load i32, i32* %13
%135 = sext i32 %134 to i64
%136 = load i64, i64* %16
%137 = add nsw i64 %136, %135
store i64 %137, i64* %16
%138 = load i32, i32* %4
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%140 = call i32 @read(i32 %138, i8* %139, i32 1024)
store i32 %140, i32* %12
%141 = load i32, i32* %4
%142 = load i64, i64* %16
%143 = load i64, i64* %17
%144 = call i32 @savepos(i32 %141, i64 %142, i64 %143)
%145 = load i32, i32* %4
%146 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%147 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%148 = call i32 @strlen(i8* %147)
%149 = call i32 @write(i32 %145, i8* %146, i32 %148)
store i32 %149, i32* %13
%150 = load i32, i32* %4
%151 = load i64, i64* %17
%152 = call i32 @recoverpos(i32 %150, i64 %151)
%153 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%154 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%155 = call i32 @memcpy(i8* %153, i8* %154, i32 1024)
%156 = load i32, i32* %12
store i32 %156, i32* %11
br label %157
157: ; preds = %133, %132
br label %158
158: ; preds = %157
%159 = load i32, i32* %11
%160 = icmp sgt i32 %159, 0
br i1 %160, label %69, label %161
161: ; preds = %158
%162 = load i32, i32* %5
%163 = and i32 %162, 2
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %173
165: ; preds = %161
%166 = load i32, i32* %4
%167 = load i64, i64* %18
%168 = load i32, i32* %15
%169 = sext i32 %168 to i64
%170 = sub nsw i64 %167, %169
%171 = sub nsw i64 %170, 1
%172 = call i32 @ftruncate(i32 %166, i64 %171)
br label %173
173: ; preds = %165, %161
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@stderr = global i32 0
@.str = [21 x i8] c"Exist same user %s.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [25 x i8] c"User %s does not exist.\0A\00"
@.str.2 = [14 x i8] c"fstat error: \00"
@SEEK_SET = global i32 0
@.str.3 = [27 x i8] c"File format is incorrect.\0A\00"
define void @_edit(i32 %0, i32 %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca %struct.stat
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = bitcast %struct.stat* %7 to i8*
store i8 0, i8* %10
store i8 0, i8* %9
%12 = tail call i64 @getpos(i32 %0, i8* %2)
%13 = and i32 %1, 4
%14 = icmp ne i32 %13, 0
%15 = icmp ne i64 %12, -1
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %2)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %3
%23 = and i32 %1, 10
%24 = icmp ne i32 %23, 0
%25 = icmp slt i64 %12, 0
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = call i32 @fstat(i32 %0, %struct.stat* %7)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @exit(i32 %37)
unreachable
39: ; preds = %32
%40 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%41 = load i64, i64* %40
%42 = load i32, i32* @SEEK_SET
%43 = tail call i32 @lseek(i32 %0, i64 %12, i32 %42)
%44 = call i32 @read(i32 %0, i8* %8, i32 1024)
%45 = and i32 %1, 2
%46 = icmp eq i32 %45, 0
%47 = sext i32 %44 to i64
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %47
store i8 0, i8* %48
%49 = call i8* @strchr(i8* %8, i8 signext 10)
%50 = icmp eq i8* %49, null
br i1 %50, label %72, label %51
51: ; preds = %39
%52 = and i32 %1, 8
%53 = icmp eq i32 %52, 0
store i8 0, i8* %49
%54 = call i32 @strlen(i8* %8)
br i1 %53, label %58, label %55
55: ; preds = %51
%56 = call i32 @encode(i8* %2)
%57 = call i32 @strcat(i8* %10, i8* %2)
br label %59
58: ; preds = %51
br i1 %46, label %62, label %59
59: ; preds = %58, %55
%60 = getelementptr inbounds i8, i8* %49, i64 1
%61 = call i32 @strcat(i8* %10, i8* %60)
br label %62
62: ; preds = %59, %58
%63 = call i32 @read(i32 %0, i8* %9, i32 1024)
%64 = call i32 @savepos(i32 %0, i64 %12, i64 0)
%65 = call i32 @strlen(i8* %10)
%66 = call i32 @write(i32 %0, i8* %10, i32 %65)
%67 = call i32 @recoverpos(i32 %0, i64 0)
%68 = call i32 @memcpy(i8* %8, i8* %9, i32 1024)
%69 = xor i32 %54, -1
%70 = sext i32 %69 to i64
%71 = icmp sgt i32 %63, 0
br i1 %71, label %77, label %92
72: ; preds = %39
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %62, %77
%78 = phi i32 [ %88, %77 ], [ %66, %62 ]
%79 = phi i64 [ %84, %77 ], [ %12, %62 ]
%80 = phi i32 [ %85, %77 ], [ %63, %62 ]
%81 = zext i32 %80 to i64
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %81
store i8 0, i8* %82
%83 = sext i32 %78 to i64
%84 = add nsw i64 %79, %83
%85 = call i32 @read(i32 %0, i8* %9, i32 1024)
%86 = call i32 @savepos(i32 %0, i64 %84, i64 0)
%87 = call i32 @strlen(i8* %10)
%88 = call i32 @write(i32 %0, i8* %10, i32 %87)
%89 = call i32 @recoverpos(i32 %0, i64 0)
%90 = call i32 @memcpy(i8* %8, i8* %9, i32 1024)
%91 = icmp sgt i32 %85, 0
br i1 %91, label %77, label %92
92: ; preds = %77, %62
br i1 %46, label %96, label %93
93: ; preds = %92
%94 = add i64 %41, %70
%95 = call i32 @ftruncate(i32 %0, i64 %94)
br label %96
96: ; preds = %93, %92
ret void
}