#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*/ path;
typedef int /*<<< orphan*/ cmd;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int errno;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int strlen(char *);
int write_record(int, char *, int, char *);
int import_logfile(char *in_dirname, char *out_filename) {
  char buf[4096 * 8];
  char cmd[256];
  int out_fd;
  FILE *names;
  snprintf(cmd, sizeof(cmd), "find '%s' -type f -name '[0-9]*[0-9]' | sort -n",
           in_dirname);
  names = popen(cmd, "r");
  if (!names) {
    printf("cannot popen command '%s', errno = %d\n", cmd, errno);
    return -errno;
  }
  out_fd = creat(out_filename, 0600);
  if (out_fd < 0) {
    printf("cannot open output file '%s', errno = %d\n", out_filename, errno);
    return -errno;
  }
  for (;;) {
    char path[1024];
    int len;
    int in_fd;
    int status;
    if (!fgets(path, sizeof(path), names)) {
      break;
    }
    len = strlen(path);
    if (len <= 1)
      continue;
    if (path[len - 1] == '\n')
      path[len - 1] = '\0';
    in_fd = open(path, O_RDONLY);
    if (in_fd < 0) {
      printf("cannot open input file '%s', errno = %d\n", path, errno);
      return -errno;
    }
    status = read(in_fd, buf, sizeof(buf));
    if (status < 0) {
      printf("cannot read from input file '%s', errno = %d\n", path, errno);
      return -errno;
    }
    close(in_fd);
    if (status >= sizeof(buf)) {
      printf("input file '%s' contains a too long record\n", path);
      return -EINVAL;
    }
    printf("record '%s' len = %d\n", path, status);
    status = write_record(out_fd, buf, status, path);
    if (status < 0)
      break;
  }
  close(out_fd);
  pclose(names);
  return 0;
}


x86 assembly (clang, -O0):
<import_logfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8540,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x8120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xe26(%rip),%rdx
call   1070 <snprintf@plt>
lea    -0x8120(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   10c0 <popen@plt>
mov    %rax,-0x8130(%rbp)
cmpq   $0x0,-0x8130(%rbp)
jne    1238 <import_logfile+0x88>
lea    -0x8120(%rbp),%rsi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2daa(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <import_logfile+0x2c4>
mov    -0x18(%rbp),%rdi
mov    $0x180,%esi
call   10d0 <creat@plt>
mov    %eax,-0x8124(%rbp)
cmpl   $0x0,-0x8124(%rbp)
jge    1287 <import_logfile+0xd7>
mov    -0x18(%rbp),%rsi
mov    0x2d74(%rip),%rax
mov    (%rax),%edx
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2d5b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <import_logfile+0x2c4>
jmp    128c <import_logfile+0xdc>
lea    -0x8530(%rbp),%rdi
mov    -0x8130(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    12b2 <import_logfile+0x102>
jmp    1456 <import_logfile+0x2a6>
lea    -0x8530(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x8534(%rbp)
cmpl   $0x1,-0x8534(%rbp)
jg     12d6 <import_logfile+0x126>
jmp    128c <import_logfile+0xdc>
mov    -0x8534(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x8530(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1305 <import_logfile+0x155>
mov    -0x8534(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x8530(%rbp,%rax,1)
lea    -0x8530(%rbp),%rdi
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x8538(%rbp)
cmpl   $0x0,-0x8538(%rbp)
jge    135e <import_logfile+0x1ae>
lea    -0x8530(%rbp),%rsi
mov    0x2c9d(%rip),%rax
mov    (%rax),%edx
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2c84(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <import_logfile+0x2c4>
mov    -0x8538(%rbp),%edi
lea    -0x8020(%rbp),%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
mov    %eax,-0x853c(%rbp)
cmpl   $0x0,-0x853c(%rbp)
jge    13b9 <import_logfile+0x209>
lea    -0x8530(%rbp),%rsi
mov    0x2c42(%rip),%rax
mov    (%rax),%edx
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2c29(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <import_logfile+0x2c4>
mov    -0x8538(%rbp),%edi
call   1080 <close@plt>
movslq -0x853c(%rbp),%rax
cmp    $0x8000,%rax
jb     13ff <import_logfile+0x24f>
lea    -0x8530(%rbp),%rsi
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2bdb(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1474 <import_logfile+0x2c4>
lea    -0x8530(%rbp),%rsi
mov    -0x853c(%rbp),%edx
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8124(%rbp),%edi
lea    -0x8020(%rbp),%rsi
mov    -0x853c(%rbp),%edx
lea    -0x8530(%rbp),%rcx
call   1030 <write_record@plt>
mov    %eax,-0x853c(%rbp)
cmpl   $0x0,-0x853c(%rbp)
jge    1451 <import_logfile+0x2a1>
jmp    1456 <import_logfile+0x2a6>
jmp    128c <import_logfile+0xdc>
mov    -0x8124(%rbp),%edi
call   1080 <close@plt>
mov    -0x8130(%rbp),%rdi
call   1060 <pclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8540,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<import_logfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8508,%rsp
mov    %rsi,%rbp
mov    %rdi,%rcx
lea    0xe32(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <snprintf@plt>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <popen@plt>
test   %rax,%rax
je     1305 <import_logfile+0x155>
mov    %rax,%r13
mov    %rbp,%rdi
mov    $0x180,%esi
call   10d0 <creat@plt>
test   %eax,%eax
js     1324 <import_logfile+0x174>
mov    %eax,%r14d
lea    0x100(%rsp),%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
je     12ee <import_logfile+0x13e>
lea    0x100(%rsp),%rbp
lea    0x500(%rsp),%r15
jmp    1258 <import_logfile+0xa8>
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
je     12ee <import_logfile+0x13e>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1240 <import_logfile+0x90>
add    $0xffffffff,%eax
cmpb   $0xa,0x100(%rsp,%rax,1)
0a
jne    127a <import_logfile+0xca>
movb   $0x0,0x100(%rsp,%rax,1)
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     1346 <import_logfile+0x196>
mov    %eax,%r12d
mov    %eax,%edi
mov    %r15,%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
test   %eax,%eax
js     1359 <import_logfile+0x1a9>
mov    %eax,%ebx
mov    %r12d,%edi
call   1080 <close@plt>
cmp    $0x8000,%ebx
jae    137b <import_logfile+0x1cb>
lea    0xe3c(%rip),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
call   1030 <write_record@plt>
test   %eax,%eax
jns    1240 <import_logfile+0x90>
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r13,%rdi
call   1060 <pclose@plt>
xor    %ebx,%ebx
jmp    139d <import_logfile+0x1ed>
mov    0x2ccc(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xd1c(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    139a <import_logfile+0x1ea>
mov    0x2cad(%rip),%r14
mov    (%r14),%edx
lea    0xd24(%rip),%rdi
xor    %ebx,%ebx
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
sub    (%r14),%ebx
jmp    139d <import_logfile+0x1ed>
mov    0x2c8b(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xd2c(%rip),%rdi
jmp    136a <import_logfile+0x1ba>
mov    0x2c78(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xd42(%rip),%rdi
lea    0x100(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1398 <import_logfile+0x1e8>
lea    0xd58(%rip),%rdi
lea    0x100(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c38(%rip),%rbp
xor    %ebx,%ebx
sub    0x0(%rbp),%ebx
mov    %ebx,%eax
add    $0x8508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"find '%s' -type f -name '[0-9]*[0-9]' | sort -n\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"cannot popen command '%s', errno = %d\0A\00"
@errno = global i32 0
@.str.3 = [42 x i8] c"cannot open output file '%s', errno = %d\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [41 x i8] c"cannot open input file '%s', errno = %d\0A\00"
@.str.5 = [46 x i8] c"cannot read from input file '%s', errno = %d\0A\00"
@.str.6 = [44 x i8] c"input file '%s' contains a too long record\0A\00"
@EINVAL = global i32 0
@.str.7 = [22 x i8] c"record '%s' len = %d\0A\00"
define i32 @import_logfile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [32768 x i8]
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @snprintf(i8* %14, i32 256, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = call i32* @popen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = icmp ne i32* %19, null
br i1 %20, label %27, label %21
21: ; preds = %2
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* @errno
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %23)
%25 = load i32, i32* @errno
%26 = sub nsw i32 0, %25
store i32 %26, i32* %3
br label %117
27: ; preds = %2
%28 = load i8*, i8** %5
%29 = call i32 @creat(i8* %28, i32 384)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = load i8*, i8** %5
%34 = load i32, i32* @errno
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i32, i32* @errno
%37 = sub nsw i32 0, %36
store i32 %37, i32* %3
br label %117
38: ; preds = %27
br label %39
39: ; preds = %111, %50, %38
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%41 = load i32*, i32** %9
%42 = call i32 @fgets(i8* %40, i32 1024, i32* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %39
br label %112
45: ; preds = %39
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
store i32 %47, i32* %11
%48 = load i32, i32* %11
%49 = icmp sle i32 %48, 1
br i1 %49, label %50, label %51
50: ; preds = %45
br label %39
51: ; preds = %45
%52 = load i32, i32* %11
%53 = sub nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %64
59: ; preds = %51
%60 = load i32, i32* %11
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %62
store i8 0, i8* %63
br label %64
64: ; preds = %59, %51
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%66 = load i32, i32* @O_RDONLY
%67 = call i32 @open(i8* %65, i32 %66)
store i32 %67, i32* %12
%68 = load i32, i32* %12
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%72 = load i32, i32* @errno
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %71, i32 %72)
%74 = load i32, i32* @errno
%75 = sub nsw i32 0, %74
store i32 %75, i32* %3
br label %117
76: ; preds = %64
%77 = load i32, i32* %12
%78 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%79 = call i32 @read(i32 %77, i8* %78, i32 32768)
store i32 %79, i32* %13
%80 = load i32, i32* %13
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %76
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%84 = load i32, i32* @errno
%85 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* %83, i32 %84)
%86 = load i32, i32* @errno
%87 = sub nsw i32 0, %86
store i32 %87, i32* %3
br label %117
88: ; preds = %76
%89 = load i32, i32* %12
%90 = call i32 @close(i32 %89)
%91 = load i32, i32* %13
%92 = sext i32 %91 to i64
%93 = icmp uge i64 %92, 32768
br i1 %93, label %94, label %99
94: ; preds = %88
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%96 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %95)
%97 = load i32, i32* @EINVAL
%98 = sub nsw i32 0, %97
store i32 %98, i32* %3
br label %117
99: ; preds = %88
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%101 = load i32, i32* %13
%102 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %100, i32 %101)
%103 = load i32, i32* %8
%104 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%105 = load i32, i32* %13
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%107 = call i32 @write_record(i32 %103, i8* %104, i32 %105, i8* %106)
store i32 %107, i32* %13
%108 = load i32, i32* %13
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %99
br label %112
111: ; preds = %99
br label %39
112: ; preds = %110, %44
%113 = load i32, i32* %8
%114 = call i32 @close(i32 %113)
%115 = load i32*, i32** %9
%116 = call i32 @pclose(i32* %115)
store i32 0, i32* %3
br label %117
117: ; preds = %112, %94, %82, %70, %32, %21
%118 = load i32, i32* %3
ret i32 %118
}

LLVM IR (-O2):
@.str = [48 x i8] c"find '%s' -type f -name '[0-9]*[0-9]' | sort -n\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"cannot popen command '%s', errno = %d\0A\00"
@errno = global i32 0
@.str.3 = [42 x i8] c"cannot open output file '%s', errno = %d\0A\00"
@O_RDONLY = global i32 0
@.str.4 = [41 x i8] c"cannot open input file '%s', errno = %d\0A\00"
@.str.5 = [46 x i8] c"cannot read from input file '%s', errno = %d\0A\00"
@.str.6 = [44 x i8] c"input file '%s' contains a too long record\0A\00"
@EINVAL = global i32 0
@.str.7 = [22 x i8] c"record '%s' len = %d\0A\00"
define i32 @import_logfile(i8* %0, i8* %1) {
%3 = alloca [32768 x i8]
%4 = alloca [256 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [32768 x i8], [32768 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %7, i32 %12)
%14 = load i32, i32* @errno
%15 = sub nsw i32 0, %14
br label %70
16: ; preds = %2
%17 = call i32 @creat(i8* %1, i32 384)
%18 = icmp slt i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = call i32 @fgets(i8* %20, i32 1024, i32* %9)
%22 = icmp eq i32 %21, 0
br i1 %22, label %67, label %28
23: ; preds = %16
%24 = load i32, i32* @errno
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %24)
%26 = load i32, i32* @errno
%27 = sub nsw i32 0, %26
br label %70
28: ; preds = %19, %64
%29 = call i32 @strlen(i8* %20)
%30 = icmp slt i32 %29, 2
br i1 %30, label %64, label %31
31: ; preds = %28
%32 = add nsw i32 %29, -1
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 10
br i1 %36, label %37, label %38
37: ; preds = %31
store i8 0, i8* %34
br label %38
38: ; preds = %37, %31
%39 = load i32, i32* @O_RDONLY
%40 = call i32 @open(i8* %20, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* @errno
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %20, i32 %43)
br label %60
45: ; preds = %38
%46 = call i32 @read(i32 %40, i8* %6, i32 32768)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* @errno
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* %20, i32 %49)
br label %60
51: ; preds = %45
%52 = call i32 @close(i32 %40)
%53 = icmp ugt i32 %46, 32767
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %20)
br label %60
56: ; preds = %51
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %20, i32 %46)
%58 = call i32 @write_record(i32 %17, i8* %6, i32 %46, i8* %20)
%59 = icmp slt i32 %58, 0
br i1 %59, label %67, label %64
60: ; preds = %42, %48, %54
%61 = phi i32* [ @EINVAL, %54 ], [ @errno, %48 ], [ @errno, %42 ]
%62 = load i32, i32* %61
%63 = sub nsw i32 0, %62
br label %70
64: ; preds = %56, %28
%65 = call i32 @fgets(i8* %20, i32 1024, i32* %9)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %28
67: ; preds = %64, %56, %19
%68 = call i32 @close(i32 %17)
%69 = call i32 @pclose(i32* %9)
br label %70
70: ; preds = %60, %67, %23, %11
%71 = phi i32 [ %27, %23 ], [ 0, %67 ], [ %15, %11 ], [ %63, %60 ]
ret i32 %71
}