#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 *char_to_str(char);
char *my_strcat(char *, char *);
char *generate_space(char pad, int width) {
  int i = 0;
  char *ret = "\0", *new_pad = char_to_str(pad);
  for (; i < width; i++) {
    ret = my_strcat(ret, new_pad);
  }
  return ret;
}


x86 assembly (clang, -O0):
<generate_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x1(%rbp),%edi
call   1040 <char_to_str@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    117b <generate_space+0x5b>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <my_strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <generate_space+0x30>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_space>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
call   1040 <char_to_str@plt>
test   %ebx,%ebx
jle    1152 <generate_space+0x32>
mov    %rax,%r14
lea    0xec7(%rip),%rax
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <my_strcat@plt>
add    $0xffffffff,%ebx
jne    1140 <generate_space+0x20>
jmp    1159 <generate_space+0x39>
lea    0xea7(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
define i8* @generate_space(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8 %0, i8* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
%8 = load i8, i8* %3
%9 = call i8* @char_to_str(i8 signext %8)
store i8* %9, i8** %7
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i8* @my_strcat(i8* %15, i8* %16)
store i8* %17, i8** %6
br label %18
18: ; preds = %14
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %10
21: ; preds = %10
%22 = load i8*, i8** %6
ret i8* %22
}

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
define i8* @generate_space(i8 signext %0, i32 %1) {
%3 = tail call i8* @char_to_str(i8 signext %0)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %11
5: ; preds = %2, %5
%6 = phi i32 [ %9, %5 ], [ 0, %2 ]
%7 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%8 = tail call i8* @my_strcat(i8* %7, i8* %3)
%9 = add nuw nsw i32 %6, 1
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %5
11: ; preds = %5, %2
%12 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ], [ %8, %5 ]
ret i8* %12
}