main(argc, argv) char **argv;
{
  static int buf[256];
  int fold, fnew, n;
  register char *p1, *p2, *bp;
  int mode;
  if (argc != 3) {
    write(1, "Usage: cp oldfile newfile\n", 26);
    exit(1);
  }
  if ((fold = open(argv[1], 0)) < 0) {
    write(1, "Cannot open old file.\n", 22);
    exit(1);
  }
  fstat(fold, buf);
  mode = buf[2];
  if (stat(argv[2], buf + 50) >= 0 && (buf[52] & 060000) == 040000) {
    p1 = argv[1];
    p2 = argv[2];
    bp = buf + 100;
    while (*bp++ = *p2++)
      ;
    bp[-1] = '/';
    p2 = bp;
    while (*bp = *p1++)
      if (*bp++ == '/')
        bp = p2;
    argv[2] = buf + 100;
  }
  if (stat(argv[2], buf + 50) >= 0) {
    if (buf[0] == buf[50] && buf[1] == buf[51]) {
      write(1, "Copying file to itself.\n", 24);
      exit(1);
    }
  }
  if ((fnew = creat(argv[2], mode)) < 0) {
    write(1, "Can't create new file.\n", 23);
    exit(1);
  }
  while (n = read(fold, buf, 512)) {
    if (n < 0) {
      write(1, "Read error\n", 11);
      exit(1);
    } else if (write(fnew, buf, n) != n) {
      write(1, "Write error.\n", 13);
      exit(1);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b2 <main+0x42>
mov    $0x1,%edi
lea    0xe64(%rip),%rsi
mov    $0x1a,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11f1 <main+0x81>
mov    $0x1,%edi
lea    0xe40(%rip),%rsi
mov    $0x16,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x14(%rbp),%edi
lea    0x2e75(%rip),%rsi
mov    $0x0,%al
call   1090 <fstat@plt>
mov    0x2e70(%rip),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x2e56(%rip),%rsi
add    $0xc8,%rsi
mov    $0x0,%al
call   1050 <stat@plt>
cmp    $0x0,%eax
jl     130c <main+0x19c>
mov    0x2f09(%rip),%eax
and    $0x6000,%eax
cmp    $0x4000,%eax
jne    130c <main+0x19c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
lea    0x2e0a(%rip),%rax
add    $0x190,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%al
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     129f <main+0x12f>
jmp    1270 <main+0x100>
mov    -0x38(%rbp),%rax
movb   $0x2f,-0x1(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%al
mov    -0x38(%rbp),%rcx
mov    %al,(%rcx)
cmp    $0x0,%al
je     12f6 <main+0x186>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12f1 <main+0x181>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    12af <main+0x13f>
mov    -0x10(%rbp),%rax
lea    0x2d6f(%rip),%rcx
add    $0x190,%rcx
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0x2d55(%rip),%rsi
add    $0xc8,%rsi
mov    $0x0,%al
call   1050 <stat@plt>
cmp    $0x0,%eax
jl     137d <main+0x20d>
mov    0x2d38(%rip),%eax
cmp    0x2dfa(%rip),%eax
jne    1378 <main+0x208>
mov    0x2d2a(%rip),%eax
cmp    0x2dec(%rip),%eax
jne    1378 <main+0x208>
mov    $0x1,%edi
lea    0xcd0(%rip),%rsi
mov    $0x18,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    137d <main+0x20d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x3c(%rbp),%esi
mov    $0x0,%al
call   1070 <creat@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13bd <main+0x24d>
mov    $0x1,%edi
lea    0xca4(%rip),%rsi
mov    $0x17,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    13c2 <main+0x252>
mov    -0x14(%rbp),%edi
lea    0x2ca4(%rip),%rsi
mov    $0x200,%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     1459 <main+0x2e9>
cmpl   $0x0,-0x1c(%rbp)
jge    1410 <main+0x2a0>
mov    $0x1,%edi
lea    0xc69(%rip),%rsi
mov    $0xb,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%edx
lea    0x2c53(%rip),%rsi
mov    $0x0,%al
call   1030 <write@plt>
cmp    -0x1c(%rbp),%eax
je     144f <main+0x2df>
mov    $0x1,%edi
lea    0xc36(%rip),%rsi
mov    $0xd,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1454 <main+0x2e4>
jmp    13c2 <main+0x252>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11a3 <main+0x33>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <open@plt>
test   %eax,%eax
jns    11c5 <main+0x55>
lea    0xe84(%rip),%rsi
mov    $0x1,%edi
mov    $0x16,%edx
jmp    11b4 <main+0x44>
lea    0xe56(%rip),%rsi
mov    $0x1,%edi
mov    $0x1a,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    %eax,%r15d
lea    0x2ea1(%rip),%rsi
mov    %eax,%edi
xor    %eax,%eax
call   1090 <fstat@plt>
mov    0x2e9a(%rip),%ebp
mov    0x10(%r14),%rdi
lea    0x2f4f(%rip),%rsi
xor    %eax,%eax
call   1050 <stat@plt>
test   %eax,%eax
js     1273 <main+0x103>
mov    $0x6000,%eax
and    0x2f41(%rip),%eax
cmp    $0x4000,%eax
jne    1273 <main+0x103>
mov    0x8(%r14),%rax
mov    0x10(%r14),%rdx
lea    0x2feb(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rdx),%ebx
add    $0x1,%rdx
mov    %bl,(%rcx)
add    $0x1,%rcx
test   %bl,%bl
jne    1220 <main+0xb0>
movb   $0x2f,-0x1(%rcx)
mov    (%rax),%dl
mov    %dl,(%rcx)
test   %dl,%dl
je     1268 <main+0xf8>
add    $0x1,%rax
mov    %rcx,%rsi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rsi
cmp    $0x2f,%dl
cmove  %rcx,%rsi
movzbl (%rax),%edx
mov    %dl,(%rsi)
add    $0x1,%rax
test   %dl,%dl
jne    1250 <main+0xe0>
lea    0x2f91(%rip),%rax
mov    %rax,0x10(%r14)
mov    0x10(%r14),%rdi
lea    0x2eba(%rip),%rsi
xor    %eax,%eax
call   1050 <stat@plt>
test   %eax,%eax
js     12bb <main+0x14b>
mov    0x2de1(%rip),%eax
cmp    0x2ea3(%rip),%eax
jne    12bb <main+0x14b>
mov    0x2dd7(%rip),%eax
cmp    0x2e99(%rip),%eax
jne    12bb <main+0x14b>
lea    0xd86(%rip),%rsi
mov    $0x1,%edi
mov    $0x18,%edx
jmp    11b4 <main+0x44>
mov    0x10(%r14),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <creat@plt>
test   %eax,%eax
jns    12e2 <main+0x172>
lea    0xd78(%rip),%rsi
mov    $0x1,%edi
mov    $0x17,%edx
jmp    11b4 <main+0x44>
mov    %eax,%r14d
lea    0x2d84(%rip),%rbx
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
xor    %eax,%eax
call   1040 <read@plt>
test   %eax,%eax
je     1333 <main+0x1c3>
js     133a <main+0x1ca>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <write@plt>
cmp    %ebp,%eax
je     12f0 <main+0x180>
lea    0xd4b(%rip),%rsi
mov    $0x1,%edi
mov    $0xd,%edx
jmp    11b4 <main+0x44>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xd22(%rip),%rsi
mov    $0x1,%edi
mov    $0xb,%edx
jmp    11b4 <main+0x44>

LLVM IR (-O0):
@main.buf = internal global [256 x i32] zeroinitializer
@.str = [27 x i8] c"Usage: cp oldfile newfile\0A\00"
@.str.1 = [23 x i8] c"Cannot open old file.\0A\00"
@.str.2 = [25 x i8] c"Copying file to itself.\0A\00"
@.str.3 = [24 x i8] c"Can't create new file.\0A\00"
@.str.4 = [12 x i8] c"Read error\0A\00"
@.str.5 = [14 x i8] c"Write error.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %20, i32 0)
store i32 %21, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 22)
unreachable
25: ; preds = %17
%26 = load i32, i32* %6
%27 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @fstat to i32 (i32, i32*, ...)*)(i32 %26, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0))
%28 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 2)
store i32 %28, i32* %12
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @stat to i32 (i8*, i32*, ...)*)(i8* %31, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50))
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %75
34: ; preds = %25
%35 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 52)
%36 = and i32 %35, 24576
%37 = icmp eq i32 %36, 16384
br i1 %37, label %38, label %75
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
store i8* %41, i8** %9
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
store i8* %44, i8** %10
store i8* bitcast (i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 100) to i8*), i8** %11
br label %45
45: ; preds = %52, %38
%46 = load i8*, i8** %10
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %10
%48 = load i8, i8* %46
%49 = load i8*, i8** %11
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %11
store i8 %48, i8* %49
%51 = icmp ne i8 %48, 0
br i1 %51, label %52, label %53
52: ; preds = %45
br label %45
53: ; preds = %45
%54 = load i8*, i8** %11
%55 = getelementptr inbounds i8, i8* %54, i64 -1
store i8 47, i8* %55
%56 = load i8*, i8** %11
store i8* %56, i8** %10
br label %57
57: ; preds = %71, %53
%58 = load i8*, i8** %9
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %9
%60 = load i8, i8* %58
%61 = load i8*, i8** %11
store i8 %60, i8* %61
%62 = icmp ne i8 %60, 0
br i1 %62, label %63, label %72
63: ; preds = %57
%64 = load i8*, i8** %11
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %11
%66 = load i8, i8* %64
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 47
br i1 %68, label %69, label %71
69: ; preds = %63
%70 = load i8*, i8** %10
store i8* %70, i8** %11
br label %71
71: ; preds = %69, %63
br label %57
72: ; preds = %57
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
store i8* bitcast (i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 100) to i8*), i8** %74
br label %75
75: ; preds = %72, %34, %25
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 2
%78 = load i8*, i8** %77
%79 = call i32 (i8*, i32*, ...) bitcast (i32 (...)* @stat to i32 (i8*, i32*, ...)*)(i8* %78, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50))
%80 = icmp sge i32 %79, 0
br i1 %80, label %81, label %92
81: ; preds = %75
%82 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0)
%83 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50)
%84 = icmp eq i32 %82, %83
br i1 %84, label %85, label %91
85: ; preds = %81
%86 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 1)
%87 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 51)
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %91
89: ; preds = %85
%90 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 24)
unreachable
91: ; preds = %85, %81
br label %92
92: ; preds = %91, %75
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 2
%95 = load i8*, i8** %94
%96 = load i32, i32* %12
%97 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @creat to i32 (i8*, i32, ...)*)(i8* %95, i32 %96)
store i32 %97, i32* %7
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %92
%100 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 23)
unreachable
101: ; preds = %92
br label %102
102: ; preds = %120, %101
%103 = load i32, i32* %6
%104 = call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i32*, i32, ...)*)(i32 %103, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0), i32 512)
store i32 %104, i32* %8
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %121
106: ; preds = %102
%107 = load i32, i32* %8
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %106
%110 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
unreachable
111: ; preds = %106
%112 = load i32, i32* %7
%113 = load i32, i32* %8
%114 = call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i32*, i32, ...)*)(i32 %112, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0), i32 %113)
%115 = load i32, i32* %8
%116 = icmp ne i32 %114, %115
br i1 %116, label %117, label %119
117: ; preds = %111
%118 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 13)
unreachable
119: ; preds = %111
br label %120
120: ; preds = %119
br label %102
121: ; preds = %102
unreachable
}

LLVM IR (-O2):
@main.buf = internal global [256 x i32] zeroinitializer
@.str = [27 x i8] c"Usage: cp oldfile newfile\0A\00"
@.str.1 = [23 x i8] c"Cannot open old file.\0A\00"
@.str.2 = [25 x i8] c"Copying file to itself.\0A\00"
@.str.3 = [24 x i8] c"Can't create new file.\0A\00"
@.str.4 = [12 x i8] c"Read error\0A\00"
@.str.5 = [14 x i8] c"Write error.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26)
tail call void @exit(i32 1)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %8, i32 0)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 22)
tail call void @exit(i32 1)
unreachable
13: ; preds = %6
%14 = tail call i32 (i32, i32*, ...) bitcast (i32 (...)* @fstat to i32 (i32, i32*, ...)*)(i32 %9, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0))
%15 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 2)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32 (i8*, i32*, ...) bitcast (i32 (...)* @stat to i32 (i8*, i32*, ...)*)(i8* %17, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50))
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %48
20: ; preds = %13
%21 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 52)
%22 = and i32 %21, 24576
%23 = icmp eq i32 %22, 16384
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = load i8*, i8** %16
br label %27
27: ; preds = %27, %24
%28 = phi i8* [ %26, %24 ], [ %30, %27 ]
%29 = phi i8* [ bitcast (i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 100) to i8*), %24 ], [ %32, %27 ]
%30 = getelementptr inbounds i8, i8* %28, i64 1
%31 = load i8, i8* %28
%32 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %31, i8* %29
%33 = icmp eq i8 %31, 0
br i1 %33, label %34, label %27
34: ; preds = %27
store i8 47, i8* %29
%35 = load i8, i8* %25
store i8 %35, i8* %32
%36 = icmp eq i8 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %34, %37
%38 = phi i8 [ %45, %37 ], [ %35, %34 ]
%39 = phi i8* [ %41, %37 ], [ %25, %34 ]
%40 = phi i8* [ %44, %37 ], [ %32, %34 ]
%41 = getelementptr inbounds i8, i8* %39, i64 1
%42 = getelementptr inbounds i8, i8* %40, i64 1
%43 = icmp eq i8 %38, 47
%44 = select i1 %43, i8* %32, i8* %42
%45 = load i8, i8* %41
store i8 %45, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %37
47: ; preds = %37, %34
store i8* bitcast (i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 100) to i8*), i8** %16
br label %48
48: ; preds = %47, %20, %13
%49 = load i8*, i8** %16
%50 = tail call i32 (i8*, i32*, ...) bitcast (i32 (...)* @stat to i32 (i8*, i32*, ...)*)(i8* %49, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50))
%51 = icmp sgt i32 %50, -1
br i1 %51, label %52, label %62
52: ; preds = %48
%53 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0)
%54 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 50)
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %62
56: ; preds = %52
%57 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 1)
%58 = load i32, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 51)
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 24)
tail call void @exit(i32 1)
unreachable
62: ; preds = %52, %56, %48
%63 = load i8*, i8** %16
%64 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @creat to i32 (i8*, i32, ...)*)(i8* %63, i32 %15)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 23)
tail call void @exit(i32 1)
unreachable
68: ; preds = %62, %75
%69 = tail call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i32*, i32, ...)*)(i32 %9, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0), i32 512)
%70 = icmp eq i32 %69, 0
br i1 %70, label %80, label %71
71: ; preds = %68
%72 = icmp slt i32 %69, 0
br i1 %72, label %73, label %75
73: ; preds = %71
%74 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
tail call void @exit(i32 1)
unreachable
75: ; preds = %71
%76 = tail call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i32*, i32, ...)*)(i32 %64, i32* getelementptr inbounds ([256 x i32], [256 x i32]* @main.buf, i64 0, i64 0), i32 %69)
%77 = icmp eq i32 %76, %69
br i1 %77, label %68, label %78
78: ; preds = %75
%79 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 13)
tail call void @exit(i32 1)
unreachable
80: ; preds = %68
tail call void @exit(i32 0)
unreachable
}