#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*/ buffer;

/* Variables and functions */
int WEXITSTATUS(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ print_test_name(char *, char const *);
int /*<<< orphan*/ printf(char *, int, char const *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int system(char *);
void pipe_write_test(const char *ext) {
  static char buffer[256];
  int retval;
  print_test_name("pipe_write_test", ext);
  snprintf(buffer, sizeof(buffer), "./stdout_test %s | ./stdin_test %s ", ext,
           ext);
  if ((retval = system(buffer))) {
    retval = WEXITSTATUS(retval);
    printf("\n\n     Line %d : pipe test returned error file type \"%s\".\n\n",
           165, ext);
    exit(retval);
  };
  puts("ok");
  return;
}


x86 assembly (clang, -O0):
<pipe_write_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1070 <print_test_name@plt>
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0x2ed5(%rip),%rdi
mov    $0x100,%esi
lea    0xe69(%rip),%rdx
call   1060 <snprintf@plt>
lea    0x2ebd(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11ec <pipe_write_test+0x7c>
mov    -0xc(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xe5a(%rip),%rdi
mov    $0xa5,%esi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1090 <exit@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_write_test>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
call   1070 <print_test_name@plt>
lea    0x2ee3(%rip),%r14
lea    0xe7c(%rip),%rdx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rcx
mov    %rbx,%r8
call   1060 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
test   %eax,%eax
jne    11c3 <pipe_write_test+0x53>
lea    0xeb6(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
mov    %eax,%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,%ebp
lea    0xe61(%rip),%rdi
mov    $0xa5,%esi
mov    %rbx,%rdx
call   1050 <printf@plt>
mov    %ebp,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@pipe_write_test.buffer = internal global [256 x i8] zeroinitializer
@.str = [16 x i8] c"pipe_write_test\00"
@.str.1 = [36 x i8] c"./stdout_test %s | ./stdin_test %s \00"
@.str.2 = [60 x i8] c"\0A\0A Line %d : pipe test returned error file type \22%s\22.\0A\0A\00"
@.str.3 = [3 x i8] c"ok\00"
define void @pipe_write_test(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @print_test_name(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pipe_write_test.buffer, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7)
%9 = call i32 @system(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pipe_write_test.buffer, i64 0, i64 0))
store i32 %9, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i32 @WEXITSTATUS(i32 %12)
store i32 %13, i32* %3
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 165, i8* %14)
%16 = load i32, i32* %3
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@pipe_write_test.buffer = internal global [256 x i8] zeroinitializer
@.str = [16 x i8] c"pipe_write_test\00"
@.str.1 = [36 x i8] c"./stdout_test %s | ./stdin_test %s \00"
@.str.2 = [60 x i8] c"\0A\0A Line %d : pipe test returned error file type \22%s\22.\0A\0A\00"
@.str.3 = [3 x i8] c"ok\00"
define void @pipe_write_test(i8* %0) {
%2 = tail call i32 @print_test_name(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pipe_write_test.buffer, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %0)
%4 = tail call i32 @system(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pipe_write_test.buffer, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i32 @WEXITSTATUS(i32 %4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 165, i8* %0)
%9 = tail call i32 @exit(i32 %7)
unreachable
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}