#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*/ free(char *);
char *rmalloc(int);
int /*<<< orphan*/ writestr(char *);
void padout(int padleng) {
  int i;
  char *pstr;
  if (padleng <= 0)
    return;
  pstr = rmalloc(padleng + 1);
  for (i = 0; i < padleng; i++)
    pstr[i] = ' ';
  pstr[padleng] = 0;
  writestr(pstr);
  free(pstr);
}


x86 assembly (clang, -O0):
<padout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     114a <padout+0x1a>
jmp    11a4 <padout+0x74>
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1040 <rmalloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1186 <padout+0x56>
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    1160 <padout+0x30>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1050 <writestr@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<padout>:
test   %edi,%edi
jle    1183 <padout+0x43>
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x1(%rbx),%edi
call   1050 <rmalloc@plt>
mov    %rax,%r14
mov    %ebx,%ebx
mov    %rax,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
call   1060 <writestr@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
ret

LLVM IR (-O0):
define void @padout(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %33
8: ; preds = %1
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
%11 = call i8* @rmalloc(i32 %10)
store i8* %11, i8** %4
store i32 0, i32* %3
br label %12
12: ; preds = %21, %8
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 32, i8* %20
br label %21
21: ; preds = %16
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %12
24: ; preds = %12
%25 = load i8*, i8** %4
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 0, i8* %28
%29 = load i8*, i8** %4
%30 = call i32 @writestr(i8* %29)
%31 = load i8*, i8** %4
%32 = call i32 @free(i8* %31)
br label %33
33: ; preds = %24, %7
ret void
}

LLVM IR (-O2):
define void @padout(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = add nuw nsw i32 %0, 1
%5 = tail call i8* @rmalloc(i32 %4)
%6 = zext i32 %0 to i64
%7 = zext i32 %0 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
store i8 0, i8* %8
%9 = tail call i32 @writestr(i8* %5)
%10 = tail call i32 @free(i8* %5)
br label %11
11: ; preds = %1, %3
ret void
}