#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 scalar_t__ pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ assert(int);
int errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ remove(char *);
int /*<<< orphan*/ stderr;
scalar_t__ wait(int *);
int destroy_file_namepipe(pid_t mypid, FILE *fp_from, FILE *fp_to) {
  FILE *fp_r = fp_to;
  FILE *fp_w = fp_from;
  pid_t cpid;
  int c_status;
  if (mypid == (pid_t)0) {
    assert(NULL != fp_from);
    assert(NULL != fp_w);
    if (fclose(fp_w) != 0) {
      fprintf(stderr,
              "{ciut} "
              "Fclose failed for %s\n",
              "cuit-io-namedfifo");
      fprintf(stderr,
              "{ciut} "
              "errno is %d\n",
              errno);
      return (-8);
    }
  } else {
    assert(NULL != fp_to);
    assert(NULL != fp_r);
    cpid = wait(&c_status);
    if ((WIFEXITED(c_status) != 0) && (WEXITSTATUS(c_status) != 0)) {
      fprintf(stderr,
              "{ciut} "
              "child %d exited with code %d\n",
              cpid, WEXITSTATUS(c_status));
      return -10;
    }
    assert(NULL != fp_to);
    assert(NULL != fp_r);
    if (fclose(fp_r) != 0) {
      fprintf(stderr,
              "{ciut} "
              "Fclose failed for %s\n",
              "cuit-io-namedfifo");
      fprintf(stderr,
              "{ciut} "
              "errno is %d\n",
              errno);
      return (-8);
    }
    if (remove("cuit-io-namedfifo") != 0) {
      fprintf(stderr,
              "{ciut} "
              "remove failed for %s\n",
              "cuit-io-namedfifo");
      fprintf(stderr,
              "{ciut} "
              "errno is %d\n",
              errno);
      return (-9);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<destroy_file_namepipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1227 <destroy_file_namepipe+0xb7>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1222 <destroy_file_namepipe+0xb2>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
lea    0xe2e(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%edx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    13ab <destroy_file_namepipe+0x23b>
jmp    13a4 <destroy_file_namepipe+0x234>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x3c(%rbp),%rdi
call   1090 <wait@plt>
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     12bc <destroy_file_namepipe+0x14c>
mov    -0x3c(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
cmp    $0x0,%eax
je     12bc <destroy_file_namepipe+0x14c>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    13ab <destroy_file_namepipe+0x23b>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     133f <destroy_file_namepipe+0x1cf>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
lea    0xd11(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
mov    0x2cb5(%rip),%rax
mov    (%rax),%edx
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    13ab <destroy_file_namepipe+0x23b>
lea    0xcd7(%rip),%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
je     139f <destroy_file_namepipe+0x22f>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
lea    0xd03(%rip),%rsi
lea    0xcb1(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
mov    0x2c55(%rip),%rax
mov    (%rax),%edx
lea    0xca3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    13ab <destroy_file_namepipe+0x23b>
jmp    13a4 <destroy_file_namepipe+0x234>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<destroy_file_namepipe>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11f0 <destroy_file_namepipe+0x80>
mov    %rdx,%rbx
xor    %ebp,%ebp
test   %rdx,%rdx
setne  %bpl
mov    %ebp,%edi
call   1050 <assert@plt>
mov    %ebp,%edi
call   1050 <assert@plt>
lea    0xc(%rsp),%rdi
call   1090 <wait@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     121b <destroy_file_namepipe+0xab>
mov    0xc(%rsp),%edi
call   1070 <WEXITSTATUS@plt>
test   %eax,%eax
je     121b <destroy_file_namepipe+0xab>
mov    0x2e1a(%rip),%rax
mov    (%rax),%ebx
mov    0xc(%rsp),%edi
call   1070 <WEXITSTATUS@plt>
lea    0xe6b(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffff6,%eax
jmp    12c5 <destroy_file_namepipe+0x155>
mov    %rsi,%rbp
xor    %ebx,%ebx
test   %rsi,%rsi
setne  %bl
mov    %ebx,%edi
call   1050 <assert@plt>
mov    %ebx,%edi
call   1050 <assert@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    1236 <destroy_file_namepipe+0xc6>
jmp    12c3 <destroy_file_namepipe+0x153>
mov    %ebp,%edi
call   1050 <assert@plt>
mov    %ebp,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1274 <destroy_file_namepipe+0x104>
mov    0x2da3(%rip),%rbx
mov    (%rbx),%edi
lea    0xdba(%rip),%rsi
lea    0xdd0(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffff8,%eax
jmp    12c5 <destroy_file_namepipe+0x155>
lea    0xda2(%rip),%rdi
call   1030 <remove@plt>
test   %rax,%rax
je     12c3 <destroy_file_namepipe+0x153>
mov    0x2d54(%rip),%rbx
mov    (%rbx),%edi
lea    0xdd3(%rip),%rsi
lea    0xd81(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
mov    0x2d2c(%rip),%rax
mov    (%rax),%edx
lea    0xd7a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffff7,%eax
jmp    12c5 <destroy_file_namepipe+0x155>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"{ciut} Fclose failed for %s\0A\00"
@.str.1 = [18 x i8] c"cuit-io-namedfifo\00"
@.str.2 = [20 x i8] c"{ciut} errno is %d\0A\00"
@errno = global i32 0
@.str.3 = [37 x i8] c"{ciut} child %d exited with code %d\0A\00"
@.str.4 = [29 x i8] c"{ciut} remove failed for %s\0A\00"
define i32 @destroy_file_namepipe(i64 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32
store i64 %0, i64* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%12 = load i32*, i32** %7
store i32* %12, i32** %8
%13 = load i32*, i32** %6
store i32* %13, i32** %9
%14 = load i64, i64* %5
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %35
16: ; preds = %3
%17 = load i32*, i32** %6
%18 = icmp ne i32* null, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32*, i32** %9
%22 = icmp ne i32* null, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32*, i32** %9
%26 = call i64 @fclose(i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %16
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = load i32, i32* @errno
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %32)
store i32 -8, i32* %4
br label %87
34: ; preds = %16
br label %86
35: ; preds = %3
%36 = load i32*, i32** %7
%37 = icmp ne i32* null, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i32*, i32** %8
%41 = icmp ne i32* null, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i64 @wait(i32* %11)
store i64 %44, i64* %10
%45 = load i32, i32* %11
%46 = call i64 @WIFEXITED(i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %35
%49 = load i32, i32* %11
%50 = call i32 @WEXITSTATUS(i32 %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = load i64, i64* %10
%55 = load i32, i32* %11
%56 = call i32 @WEXITSTATUS(i32 %55)
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i64 %54, i32 %56)
store i32 -10, i32* %4
br label %87
58: ; preds = %48, %35
%59 = load i32*, i32** %7
%60 = icmp ne i32* null, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i32*, i32** %8
%64 = icmp ne i32* null, %63
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = load i32*, i32** %8
%68 = call i64 @fclose(i32* %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %58
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %74)
store i32 -8, i32* %4
br label %87
76: ; preds = %58
%77 = call i64 @remove(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %85
79: ; preds = %76
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%82 = load i32, i32* @stderr
%83 = load i32, i32* @errno
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %83)
store i32 -9, i32* %4
br label %87
85: ; preds = %76
br label %86
86: ; preds = %85, %34
store i32 0, i32* %4
br label %87
87: ; preds = %86, %79, %70, %52, %28
%88 = load i32, i32* %4
ret i32 %88
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"{ciut} Fclose failed for %s\0A\00"
@.str.1 = [18 x i8] c"cuit-io-namedfifo\00"
@.str.2 = [20 x i8] c"{ciut} errno is %d\0A\00"
@errno = global i32 0
@.str.3 = [37 x i8] c"{ciut} child %d exited with code %d\0A\00"
@.str.4 = [29 x i8] c"{ciut} remove failed for %s\0A\00"
define i32 @destroy_file_namepipe(i64 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i64 %0, 0
br i1 %6, label %7, label %20
7: ; preds = %3
%8 = icmp ne i32* %1, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @assert(i32 %9)
%12 = tail call i64 @fclose(i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %58, label %14
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %58
20: ; preds = %3
%21 = icmp ne i32* %2, null
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i32 @assert(i32 %22)
%25 = call i64 @wait(i32* %4)
%26 = load i32, i32* %4
%27 = call i64 @WIFEXITED(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %20
%30 = load i32, i32* %4
%31 = call i32 @WEXITSTATUS(i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i32, i32* %4
%36 = call i32 @WEXITSTATUS(i32 %35)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i64 %25, i32 %36)
br label %58
38: ; preds = %29, %20
%39 = call i32 @assert(i32 %22)
%40 = call i32 @assert(i32 %22)
%41 = call i64 @fclose(i32* %2)
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @stderr
%47 = load i32, i32* @errno
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %58
49: ; preds = %38
%50 = call i64 @remove(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = load i32, i32* @errno
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %7, %49, %52, %43, %33, %14
%59 = phi i32 [ -8, %14 ], [ -10, %33 ], [ -8, %43 ], [ -9, %52 ], [ 0, %49 ], [ 0, %7 ]
ret i32 %59
}