#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ memset(char *, char, unsigned int);
int /*<<< orphan*/ stderr;
char *get_repeated_spaces(unsigned n) {
  char *str = (char *)malloc(n + 1);
  if (str == NULL) {
    fprintf(stderr, "Could not allocate memory for space indentation");
    exit(EXIT_FAILURE);
  }
  memset(str, ' ', n);
  str[n] = '\0';
  return str;
}


x86 assembly (clang, -O0):
<get_repeated_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1188 <get_repeated_spaces+0x48>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0x20,%esi
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_repeated_spaces>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x1(%r14),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     117a <get_repeated_spaces+0x3a>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x20,%esi
mov    %r14d,%edx
call   1030 <memset@plt>
mov    %r14d,%eax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [48 x i8] c"Could not allocate memory for space indentation\00"
@EXIT_FAILURE = global i32 0
define i8* @get_repeated_spaces(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = add i32 %4, 1
%6 = call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = load i32, i32* %2
%18 = call i32 @memset(i8* %16, i8 signext 32, i32 %17)
%19 = load i8*, i8** %3
%20 = load i32, i32* %2
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [48 x i8] c"Could not allocate memory for space indentation\00"
@EXIT_FAILURE = global i32 0
define i8* @get_repeated_spaces(i32 %0) {
%2 = add i32 %0, 1
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = tail call i32 @memset(i8* %4, i8 signext 32, i32 %0)
%13 = zext i32 %0 to i64
%14 = getelementptr inbounds i8, i8* %4, i64 %13
store i8 0, i8* %14
ret i8* %4
}