#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void strrepeat(char *buf, char *chr, int count) {
  int i;
  char indentation[30] = "";
  if (count == 0) {
    indentation[0] = '\0';
  } else {
    for (i = 0; i < count; i++) {
      if (i == 0) {
        strcpy(indentation, chr);
      } else {
        strcat(indentation, chr);
      }
    }
  }
  strcat(buf, indentation);
}


x86 assembly (clang, -O0):
<strrepeat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1166 <strrepeat+0x36>
movb   $0x0,-0x40(%rbp)
jmp    11ba <strrepeat+0x8a>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <strrepeat+0x85>
cmpl   $0x0,-0x18(%rbp)
jne    1195 <strrepeat+0x65>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a2 <strrepeat+0x72>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
jmp    11a7 <strrepeat+0x77>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116d <strrepeat+0x3d>
jmp    11ba <strrepeat+0x8a>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strrepeat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movups %xmm0,0xe(%rsp)
movaps %xmm0,(%rsp)
test   %edx,%edx
jle    1170 <strrepeat+0x50>
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rsp,%rdi
call   1030 <strcpy@plt>
cmp    $0x1,%ebp
je     1170 <strrepeat+0x50>
add    $0xffffffff,%ebp
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%ebp
jne    1160 <strrepeat+0x40>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @strrepeat(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [30 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = bitcast [30 x i8]* %8 to i8*
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
store i8 0, i8* %13
br label %35
14: ; preds = %3
store i32 0, i32* %7
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%24 = load i8*, i8** %5
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %30
26: ; preds = %19
%27 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%28 = load i8*, i8** %5
%29 = call i32 @strcat(i8* %27, i8* %28)
br label %30
30: ; preds = %26, %22
br label %31
31: ; preds = %30
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %15
34: ; preds = %15
br label %35
35: ; preds = %34, %12
%36 = load i8*, i8** %4
%37 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
ret void
}

LLVM IR (-O2):
define void @strrepeat(i8* %0, i8* %1, i32 %2) {
%4 = alloca [30 x i8]
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %15
7: ; preds = %3
%8 = call i32 @strcpy(i8* %5, i8* %1)
%9 = icmp eq i32 %2, 1
br i1 %9, label %15, label %10
10: ; preds = %7, %10
%11 = phi i32 [ %13, %10 ], [ 1, %7 ]
%12 = call i32 @strcat(i8* %5, i8* %1)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %2
br i1 %14, label %15, label %10
15: ; preds = %10, %3, %7
%16 = call i32 @strcat(i8* %0, i8* %5)
ret void
}