#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 uid_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_temp_fd();
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int read(int, char *, int);
int recv_fd(int /*<<< orphan*/, int *, int (*)(int, char *, int));
int send_fd(int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int write(int, char *, int);
int main(void) {
  uid_t uid;
  int ret, fdin, fdout, n, int1, int2;
  char line[128];
  while (1) {
    fdin = recv_fd(STDIN_FILENO, &uid, write);
    if (fdin < 0) {
      fprintf(stderr, "recv_fd failed, error %d\n", fdin);
      return -1;
    }
    fprintf(stderr, "recv fd %d, uid %d, position %u\n", fdin, uid,
            lseek(fdin, 0, SEEK_CUR));
    fdout = get_temp_fd();
    if (fdout < 0) {
      fprintf(stderr, "get temp fd failed\n");
      return -1;
    }
    n = read(fdin, line, 128);
    if (n > 0) {
      line[n] = 0;
      fprintf(stderr, "source: %s\n", line);
      if (sscanf(line, "%d%d", &int1, &int2) == 2) {
        sprintf(line, "%d\n", int1 + int2);
        n = strlen(line);
        if (write(fdout, line, n) != n) {
          fprintf(stderr, "write error\n");
          return 0;
        }
      } else {
        if (write(fdout, "invalid args\n", 13) != 13) {
          fprintf(stderr, "write msg error\n");
          return 0;
        }
      }
      if (lseek(fdout, 0, SEEK_SET) < 0)
        fprintf(stderr, "seek to begin failed\n");
      else
        fprintf(stderr, "seek to head\n");
      ret = send_fd(STDOUT_FILENO, fdout);
      if (ret < 0) {
        fprintf(stderr, "send fd to peer failed, error %d\n", ret);
        return -1;
      }
      fprintf(stderr, "send fd %d\n", fdout);
    } else
      fprintf(stderr, "no more data\n");
    close(fdin);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
mov    0x2dfa(%rip),%rdx
call   1090 <recv_fd@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11fe <main+0x5e>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <main+0x2e2>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x10(%rbp),%edi
mov    0x2db7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%edx
mov    -0xa4(%rbp),%ecx
mov    %rax,%r8
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   10a0 <get_temp_fd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    128c <main+0xec>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <main+0x2e2>
mov    -0x10(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1070 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    145e <main+0x2be>
movslq -0x18(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rdx
lea    0xd7f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd76(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
jne    1366 <main+0x1c6>
lea    -0xa0(%rbp),%rdi
mov    -0x1c(%rbp),%edx
add    -0x20(%rbp),%edx
lea    0xdcb(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   10d0 <write@plt>
cmp    -0x18(%rbp),%eax
je     1361 <main+0x1c1>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1482 <main+0x2e2>
jmp    13ab <main+0x20b>
mov    -0x14(%rbp),%edi
lea    0xcfd(%rip),%rsi
mov    $0xd,%edx
call   10d0 <write@plt>
cmp    $0xd,%eax
je     13a6 <main+0x206>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1482 <main+0x2e2>
jmp    13ab <main+0x20b>
mov    -0x14(%rbp),%edi
mov    0x2c13(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0x0,%rax
jge    13e4 <main+0x244>
mov    0x2c01(%rip),%rax
mov    (%rax),%edi
lea    0xcb4(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13fb <main+0x25b>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xcae(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2bee(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1040 <send_fd@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    143f <main+0x29f>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xc84(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1482 <main+0x2e2>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xc80(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1475 <main+0x2d5>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%edi
call   1060 <close@plt>
jmp    11b2 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x2dff(%rip),%rdx
lea    0x4(%rsp),%rsi
call   1090 <recv_fd@plt>
mov    %eax,%r13d
test   %eax,%eax
js     137d <main+0x1dd>
mov    0x2df3(%rip),%r14
lea    0x10(%rsp),%r15
jmp    122e <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edi
lea    0xee4(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13d,%edi
call   1060 <close@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rsp),%rsi
mov    0x2da2(%rip),%rdx
call   1090 <recv_fd@plt>
mov    %eax,%r13d
test   %eax,%eax
js     137d <main+0x1dd>
mov    (%r14),%ebp
mov    0x4(%rsp),%ebx
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %ebp,%edi
lea    0xdc9(%rip),%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10a0 <get_temp_fd@plt>
test   %eax,%eax
js     1399 <main+0x1f9>
mov    %eax,%r12d
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x80,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    11f0 <main+0x50>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    (%r14),%edi
lea    0xdb4(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
lea    0xdac(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
jne    1300 <main+0x160>
mov    0x8(%rsp),%edx
add    0xc(%rsp),%edx
mov    %r15,%rdi
lea    0xe05(%rip),%rsi
call   10c0 <sprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <write@plt>
cmp    %ebx,%eax
je     131d <main+0x17d>
jmp    13ce <main+0x22e>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
lea    0xd63(%rip),%rsi
mov    $0xd,%edx
call   10d0 <write@plt>
cmp    $0xd,%eax
jne    13da <main+0x23a>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
test   %rax,%rax
mov    (%r14),%edi
lea    0xd65(%rip),%rsi
lea    0xd48(%rip),%rax
cmovs  %rax,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
mov    %r12d,%esi
call   1040 <send_fd@plt>
mov    (%r14),%edi
test   %eax,%eax
js     13c3 <main+0x223>
lea    0xd64(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1201 <main+0x61>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13aa <main+0x20a>
mov    (%r14),%edi
lea    0xc98(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce6(%rip),%rsi
mov    %eax,%edx
jmp    1390 <main+0x1f0>
mov    (%r14),%edi
lea    0xc88(%rip),%rsi
jmp    13e4 <main+0x244>
mov    (%r14),%edi
lea    0xc97(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13af <main+0x20f>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"recv_fd failed, error %d\0A\00"
@.str.1 = [33 x i8] c"recv fd %d, uid %d, position %u\0A\00"
@SEEK_CUR = global i32 0
@.str.2 = [20 x i8] c"get temp fd failed\0A\00"
@.str.3 = [12 x i8] c"source: %s\0A\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [13 x i8] c"write error\0A\00"
@.str.7 = [14 x i8] c"invalid args\0A\00"
@.str.8 = [17 x i8] c"write msg error\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [22 x i8] c"seek to begin failed\0A\00"
@.str.10 = [14 x i8] c"seek to head\0A\00"
@STDOUT_FILENO = global i32 0
@.str.11 = [34 x i8] c"send fd to peer failed, error %d\0A\00"
@.str.12 = [12 x i8] c"send fd %d\0A\00"
@.str.13 = [14 x i8] c"no more data\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [128 x i8]
store i32 0, i32* %1
br label %10
10: ; preds = %0, %103
%11 = load i32, i32* @STDIN_FILENO
%12 = call i32 @recv_fd(i32 %11, i32* %2, i32 (i32, i8*, i32)* @write)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i32, i32* %4
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 -1, i32* %1
br label %106
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = load i32, i32* @SEEK_CUR
%25 = call i64 @lseek(i32 %23, i32 0, i32 %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i64 %25)
%27 = call i32 (...) @get_temp_fd()
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %106
33: ; preds = %19
%34 = load i32, i32* %4
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%36 = call i32 @read(i32 %34, i8* %35, i32 128)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %100
39: ; preds = %33
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %41
store i8 0, i8* %42
%43 = load i32, i32* @stderr
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%47 = call i32 @sscanf(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8)
%48 = icmp eq i32 %47, 2
br i1 %48, label %49, label %67
49: ; preds = %39
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = add nsw i32 %51, %52
%54 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%56 = call i32 @strlen(i8* %55)
store i32 %56, i32* %6
%57 = load i32, i32* %5
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%59 = load i32, i32* %6
%60 = call i32 @write(i32 %57, i8* %58, i32 %59)
%61 = load i32, i32* %6
%62 = icmp ne i32 %60, %61
br i1 %62, label %63, label %66
63: ; preds = %49
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %106
66: ; preds = %49
br label %75
67: ; preds = %39
%68 = load i32, i32* %5
%69 = call i32 @write(i32 %68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 13)
%70 = icmp ne i32 %69, 13
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load i32, i32* @stderr
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %106
74: ; preds = %67
br label %75
75: ; preds = %74, %66
%76 = load i32, i32* %5
%77 = load i32, i32* @SEEK_SET
%78 = call i64 @lseek(i32 %76, i32 0, i32 %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %75
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
br label %86
83: ; preds = %75
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %86
86: ; preds = %83, %80
%87 = load i32, i32* @STDOUT_FILENO
%88 = load i32, i32* %5
%89 = call i32 @send_fd(i32 %87, i32 %88)
store i32 %89, i32* %3
%90 = load i32, i32* %3
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %86
%93 = load i32, i32* @stderr
%94 = load i32, i32* %3
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %94)
store i32 -1, i32* %1
br label %106
96: ; preds = %86
%97 = load i32, i32* @stderr
%98 = load i32, i32* %5
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %98)
br label %103
100: ; preds = %33
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
br label %103
103: ; preds = %100, %96
%104 = load i32, i32* %4
%105 = call i32 @close(i32 %104)
br label %10
106: ; preds = %92, %71, %63, %30, %15
%107 = load i32, i32* %1
ret i32 %107
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"recv_fd failed, error %d\0A\00"
@.str.1 = [33 x i8] c"recv fd %d, uid %d, position %u\0A\00"
@SEEK_CUR = global i32 0
@.str.2 = [20 x i8] c"get temp fd failed\0A\00"
@.str.3 = [12 x i8] c"source: %s\0A\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [13 x i8] c"write error\0A\00"
@.str.7 = [14 x i8] c"invalid args\0A\00"
@.str.8 = [17 x i8] c"write msg error\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [22 x i8] c"seek to begin failed\0A\00"
@.str.10 = [14 x i8] c"seek to head\0A\00"
@STDOUT_FILENO = global i32 0
@.str.11 = [34 x i8] c"send fd to peer failed, error %d\0A\00"
@.str.12 = [12 x i8] c"send fd %d\0A\00"
@.str.13 = [14 x i8] c"no more data\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @STDIN_FILENO
%10 = call i32 @recv_fd(i32 %9, i32* %1, i32 (i32, i8*, i32)* @write)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %73, %0
%13 = phi i32 [ %10, %0 ], [ %76, %73 ]
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %78
16: ; preds = %0, %73
%17 = phi i32 [ %76, %73 ], [ %10, %0 ]
%18 = load i32, i32* @stderr
%19 = load i32, i32* %1
%20 = load i32, i32* @SEEK_CUR
%21 = call i64 @lseek(i32 %17, i32 0, i32 %20)
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %19, i64 %21)
%23 = call i32 (...) @get_temp_fd()
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %78
28: ; preds = %16
%29 = call i32 @read(i32 %17, i8* %8, i32 128)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %70
31: ; preds = %28
%32 = zext i32 %29 to i64
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %32
store i8 0, i8* %33
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%36 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3)
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %49
38: ; preds = %31
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = add nsw i32 %40, %39
%42 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %41)
%43 = call i32 @strlen(i8* %8)
%44 = call i32 @write(i32 %23, i8* %8, i32 %43)
%45 = icmp eq i32 %44, %43
br i1 %45, label %55, label %46
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %78
49: ; preds = %31
%50 = call i32 @write(i32 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 13)
%51 = icmp eq i32 %50, 13
br i1 %51, label %55, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %78
55: ; preds = %49, %38
%56 = load i32, i32* @SEEK_SET
%57 = call i64 @lseek(i32 %23, i32 0, i32 %56)
%58 = icmp slt i64 %57, 0
%59 = load i32, i32* @stderr
%60 = select i1 %58, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0)
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* %60)
%62 = load i32, i32* @STDOUT_FILENO
%63 = call i32 @send_fd(i32 %62, i32 %23)
%64 = icmp slt i32 %63, 0
%65 = load i32, i32* @stderr
br i1 %64, label %66, label %68
66: ; preds = %55
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %63)
br label %78
68: ; preds = %55
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %23)
br label %73
70: ; preds = %28
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
br label %73
73: ; preds = %70, %68
%74 = call i32 @close(i32 %17)
%75 = load i32, i32* @STDIN_FILENO
%76 = call i32 @recv_fd(i32 %75, i32* %1, i32 (i32, i8*, i32)* @write)
%77 = icmp slt i32 %76, 0
br i1 %77, label %12, label %16
78: ; preds = %66, %52, %46, %25, %12
%79 = phi i32 [ -1, %12 ], [ -1, %25 ], [ 0, %46 ], [ -1, %66 ], [ 0, %52 ]
ret i32 %79
}