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

/* Variables and functions */
int /*<<< orphan*/ InitStr(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int write(int, char *, int);
void PipeWrite(int fd[2], int len) {
  int nWirted;
  char text[100];
  if (len < 100) {
    InitStr(text, 70);
  } else {
    printf("PipeWrite Error : len is  too long \n");
    exit(1);
  }
  printf("Write Process :   Wanna input %d characters \n", len);
  close(fd[0]);
  nWirted = write(fd[1], text, len);
  printf("Write Process : Wrote in %d characters ...\n", nWirted);
}


x86 assembly (clang, -O0):
<PipeWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    117f <PipeWrite+0x2f>
lea    -0x80(%rbp),%rdi
mov    $0x46,%esi
call   1030 <InitStr@plt>
jmp    1197 <PipeWrite+0x47>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0xc(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1060 <close@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x80(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PipeWrite>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
cmp    $0x63,%esi
jg     11c3 <PipeWrite+0x63>
mov    %esi,%ebx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x46,%esi
call   1040 <InitStr@plt>
lea    0xe76(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r14),%edi
call   1070 <close@plt>
mov    0x4(%r14),%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <write@plt>
lea    0xe7e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"PipeWrite Error : len is too long \0A\00"
@.str.1 = [46 x i8] c"Write Process : Wanna input %d characters \0A\00"
@.str.2 = [44 x i8] c"Write Process : Wrote in %d characters ...\0A\00"
define void @PipeWrite(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 @InitStr(i8* %10, i32 70)
br label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = call i32 @close(i32 %20)
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%26 = load i32, i32* %4
%27 = call i32 @write(i32 %24, i8* %25, i32 %26)
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str.1 = [46 x i8] c"Write Process : Wanna input %d characters \0A\00"
@.str.2 = [44 x i8] c"Write Process : Wrote in %d characters ...\0A\00"
@str = [36 x i8] c"PipeWrite Error : len is too long \00"
define void @PipeWrite(i32* nocapture %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %1, 100
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = call i32 @InitStr(i8* %4, i32 70)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%9 = load i32, i32* %0
%10 = call i32 @close(i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = call i32 @write(i32 %12, i8* %4, i32 %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret void
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
}