#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 cgi_content_length();
char **cgi_parse_string(char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stdin;
char **cgi_parse_stdin(void) {
  char **form = NULL;
  char *buff;
  int len;
  len = cgi_content_length();
  if (!len)
    return (NULL);
  buff = (char *)malloc(len + 1);
  buff[len] = '\0';
  fread(buff, 1, len, stdin);
  form = cgi_parse_string(buff);
  free(buff);
  return (form);
}


x86 assembly (clang, -O0):
<cgi_parse_stdin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <cgi_content_length@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1181 <cgi_parse_stdin+0x31>
movq   $0x0,-0x8(%rbp)
jmp    11d4 <cgi_parse_stdin+0x84>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    0x2e3e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1060 <cgi_parse_string@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgi_parse_stdin>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <cgi_content_length@plt>
test   %eax,%eax
je     11a4 <cgi_parse_stdin+0x54>
mov    %eax,%ebx
lea    0x1(%rbx),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
movslq %ebx,%rax
movb   $0x0,(%r14,%rax,1)
mov    0x2e6d(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1050 <fread@plt>
mov    %r14,%rdi
call   1060 <cgi_parse_string@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
jmp    11a6 <cgi_parse_stdin+0x56>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define i8** @cgi_parse_stdin() {
%1 = alloca i8**
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32
store i8** null, i8*** %2
%5 = call i32 (...) @cgi_content_length()
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %0
store i8** null, i8*** %1
br label %27
9: ; preds = %0
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = load i32, i32* @stdin
%21 = call i32 @fread(i8* %18, i32 1, i32 %19, i32 %20)
%22 = load i8*, i8** %3
%23 = call i8** @cgi_parse_string(i8* %22)
store i8** %23, i8*** %2
%24 = load i8*, i8** %3
%25 = call i32 @free(i8* %24)
%26 = load i8**, i8*** %2
store i8** %26, i8*** %1
br label %27
27: ; preds = %9, %8
%28 = load i8**, i8*** %1
ret i8** %28
}

LLVM IR (-O2):
@stdin = global i32 0
define i8** @cgi_parse_stdin() {
%1 = tail call i32 (...) @cgi_content_length()
%2 = icmp eq i32 %1, 0
br i1 %2, label %13, label %3
3: ; preds = %0
%4 = add nsw i32 %1, 1
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i8, i8* %6, i64 %7
store i8 0, i8* %8
%9 = load i32, i32* @stdin
%10 = tail call i32 @fread(i8* %6, i32 1, i32 %1, i32 %9)
%11 = tail call i8** @cgi_parse_string(i8* %6)
%12 = tail call i32 @free(i8* %6)
br label %13
13: ; preds = %0, %3
%14 = phi i8** [ %11, %3 ], [ null, %0 ]
ret i8** %14
}