#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 */
char *UTIL_mallocStr(int);
char *strdup(char *);
char *OC_mkWS(int size) {
  int i;
  char *text;
  if (size > 0) {
    text = UTIL_mallocStr(size);
    for (i = 0; i < size; i++)
      text[i] = ' ';
    text[size] = '\0';
  } else
    text = strdup(" ");
  return text;
}


x86 assembly (clang, -O0):
<OC_mkWS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    117f <OC_mkWS+0x5f>
mov    -0x4(%rbp),%edi
call   1030 <UTIL_mallocStr@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116e <OC_mkWS+0x4e>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1148 <OC_mkWS+0x28>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    118f <OC_mkWS+0x6f>
lea    0xe7a(%rip),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OC_mkWS>:
test   %edi,%edi
jle    1164 <OC_mkWS+0x34>
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1040 <UTIL_mallocStr@plt>
mov    %rax,%r14
mov    %ebx,%ebx
mov    %rax,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe95(%rip),%rdi
jmp    1050 <strdup@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i8* @OC_mkWS(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i8* @UTIL_mallocStr(i32 %8)
store i8* %9, i8** %4
store i32 0, i32* %3
br label %10
10: ; preds = %19, %7
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 32, i8* %18
br label %19
19: ; preds = %14
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = load i8*, i8** %4
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
br label %29
27: ; preds = %1
%28 = call i8* @strdup(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %4
br label %29
29: ; preds = %27, %22
%30 = load i8*, i8** %4
ret i8* %30
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i8* @OC_mkWS(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = tail call i8* @UTIL_mallocStr(i32 %0)
%5 = zext i32 %0 to i64
%6 = zext i32 %0 to i64
%7 = getelementptr inbounds i8, i8* %4, i64 %6
store i8 0, i8* %7
br label %10
8: ; preds = %1
%9 = tail call dereferenceable_or_null(2) i8* @strdup(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
%11 = phi i8* [ %4, %3 ], [ %9, %8 ]
ret i8* %11
}