#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 */
scalar_t__ EFBIG;
int /*<<< orphan*/ _PC_PIPE_BUF;
int /*<<< orphan*/ abort();
char *calloc(int, int);
int /*<<< orphan*/ err(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fpathconf(int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int main(void) {
  int pip[2];
  int pipemax;
  char *buf;
  if (pipe(pip) != 0)
    err("pipe");
  pipemax = fpathconf(pip[1], _PC_PIPE_BUF);
  if (pipemax <= 0) {
    fprintf(stderr, "Bad pipemax %d\n", pipemax);
    abort();
  }
  buf = calloc(100 * pipemax, 1);
  if (buf == NULL)
    err("calloc");
  if (write(pip[1], buf, 100 * pipemax) != -1 || errno != EFBIG)
    err("write mucho");
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
je     11be <main+0x2e>
lea    0xe47(%rip),%rdi
call   10a0 <err@plt>
mov    -0x8(%rbp),%edi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
call   1080 <fpathconf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jg     11fb <main+0x6b>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xe16(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
imul   $0x64,-0x10(%rbp),%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1224 <main+0x94>
lea    0xdf6(%rip),%rdi
call   10a0 <err@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
imul   $0x64,-0x10(%rbp),%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1257 <main+0xc7>
mov    0x2d84(%rip),%rax
mov    (%rax),%rax
mov    0x2d9a(%rip),%rcx
cmp    (%rcx),%rax
je     1263 <main+0xd3>
lea    0xdbe(%rip),%rdi
call   10a0 <err@plt>
lea    0xdbe(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsp,%rdi
call   1060 <pipe@plt>
test   %rax,%rax
je     11ac <main+0x1c>
lea    0xe59(%rip),%rdi
call   10a0 <err@plt>
mov    0x4(%rsp),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
call   1080 <fpathconf@plt>
test   %eax,%eax
jg     11e0 <main+0x50>
mov    0x2e07(%rip),%rcx
mov    (%rcx),%edi
lea    0xe33(%rip),%rsi
mov    %eax,%edx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>
imul   $0x64,%eax,%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1203 <main+0x73>
lea    0xe17(%rip),%rdi
call   10a0 <err@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    122c <main+0x9c>
mov    0x2dab(%rip),%rax
mov    (%rax),%rax
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%rax
je     1238 <main+0xa8>
lea    0xde9(%rip),%rdi
call   10a0 <err@plt>
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@_PC_PIPE_BUF = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"Bad pipemax %d\0A\00"
@.str.2 = [7 x i8] c"calloc\00"
@errno = global i64 0
@EFBIG = global i64 0
@.str.3 = [12 x i8] c"write mucho\00"
@.str.4 = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%6 = call i64 @pipe(i32* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11
%13 = load i32, i32* @_PC_PIPE_BUF
%14 = call i32 @fpathconf(i32 %12, i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = load i32, i32* %3
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %10
%23 = load i32, i32* %3
%24 = mul nsw i32 100, %23
%25 = call i8* @calloc(i32 %24, i32 1)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%32 = load i32, i32* %31
%33 = load i8*, i8** %4
%34 = load i32, i32* %3
%35 = mul nsw i32 100, %34
%36 = call i32 @write(i32 %32, i8* %33, i32 %35)
%37 = icmp ne i32 %36, -1
br i1 %37, label %42, label %38
38: ; preds = %30
%39 = load i64, i64* @errno
%40 = load i64, i64* @EFBIG
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38, %30
%43 = call i32 @err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %38
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@_PC_PIPE_BUF = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"Bad pipemax %d\0A\00"
@.str.2 = [7 x i8] c"calloc\00"
@errno = global i64 0
@EFBIG = global i64 0
@.str.3 = [12 x i8] c"write mucho\00"
@str = [5 x i8] c"pass\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i64 @pipe(i32* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = load i32, i32* @_PC_PIPE_BUF
%12 = call i32 @fpathconf(i32 %10, i32 %11)
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %8
%19 = mul nsw i32 %12, 100
%20 = call i8* @calloc(i32 %19, i32 1)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @err(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = load i32, i32* %9
%26 = call i32 @write(i32 %25, i8* %20, i32 %19)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i64, i64* @errno
%30 = load i64, i64* @EFBIG
%31 = icmp eq i64 %29, %30
br i1 %31, label %34, label %32
32: ; preds = %28, %24
%33 = call i32 @err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
}