#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*/ memset(char *, char, int);
int /*<<< orphan*/ wFree(char *);
scalar_t__ wMalloc(unsigned int);
scalar_t__ wStackPopNumber();
int /*<<< orphan*/ wStackPushChar(char *, int /*<<< orphan*/);
void wBuiltinSpace() {
  char *string;
  int n;
  n = (int)wStackPopNumber();
  if (n < 0) {
    n = 0;
  }
  string = (char *)wMalloc((unsigned int)n + 1);
  memset(string, ' ', n);
  string[n] = '\0';
  wStackPushChar(string, 0);
  wFree(string);
}


x86 assembly (clang, -O0):
<wBuiltinSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <wStackPopNumber@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1173 <wBuiltinSpace+0x23>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1050 <wMalloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x20,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1070 <wStackPushChar@plt>
mov    -0x8(%rbp),%rdi
call   1060 <wFree@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wBuiltinSpace>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <wStackPopNumber@plt>
mov    %rax,%rbx
test   %ebx,%ebx
cmovs  %ebp,%ebx
lea    0x1(%rbx),%edi
call   1050 <wMalloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x20,%esi
mov    %ebx,%edx
call   1040 <memset@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <wStackPushChar@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <wFree@plt>

LLVM IR (-O0):
define void @wBuiltinSpace() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i64 (...) @wStackPopNumber()
%4 = trunc i64 %3 to i32
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 0, i32* %2
br label %8
8: ; preds = %7, %0
%9 = load i32, i32* %2
%10 = add i32 %9, 1
%11 = call i64 @wMalloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %1
%13 = load i8*, i8** %1
%14 = load i32, i32* %2
%15 = call i32 @memset(i8* %13, i8 signext 32, i32 %14)
%16 = load i8*, i8** %1
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %1
%21 = call i32 @wStackPushChar(i8* %20, i32 0)
%22 = load i8*, i8** %1
%23 = call i32 @wFree(i8* %22)
ret void
}

LLVM IR (-O2):
define void @wBuiltinSpace() {
%1 = tail call i64 (...) @wStackPopNumber()
%2 = trunc i64 %1 to i32
%3 = icmp sgt i32 %2, 0
%4 = select i1 %3, i32 %2, i32 0
%5 = add nuw i32 %4, 1
%6 = tail call i64 @wMalloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @memset(i8* %7, i8 signext 32, i32 %4)
%9 = zext i32 %4 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
store i8 0, i8* %10
%11 = tail call i32 @wStackPushChar(i8* %7, i32 0)
%12 = tail call i32 @wFree(i8* %7)
ret void
}