#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 */
scalar_t__ calloc(scalar_t__, int);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
*prependChar(const char *str, char c) {
  char *string = (char *)calloc(strlen(str) + 2, sizeof(char));
  if (c != '#') {
    string[0] = c;
    strcpy(string + 1, str);
  } else {
    strcpy(string, str);
  }
  return string;
}


x86 assembly (clang, -O0):
<prependChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x2,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
je     118c <prependChar+0x5c>
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1199 <prependChar+0x69>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prependChar>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0x2(%rax),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
cmp    $0x23,%bpl
jne    115a <prependChar+0x2a>
mov    %rbx,%rdi
jmp    1164 <prependChar+0x34>
mov    %bpl,(%rbx)
mov    %rbx,%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32* @prependChar(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = add nsw i64 %7, 2
%9 = call i64 @calloc(i64 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %5
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 35
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i8, i8* %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 %15, i8* %17
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8*, i8** %3
%21 = call i32 @strcpy(i8* %19, i8* %20)
br label %26
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %14
%27 = load i8*, i8** %5
%28 = bitcast i8* %27 to i32*
ret i32* %28
}

LLVM IR (-O2):
define i32* @prependChar(i8* %0, i8 signext %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 2
%5 = tail call i64 @calloc(i64 %4, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i8 %1, 35
br i1 %7, label %11, label %8
8: ; preds = %2
store i8 %1, i8* %6
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = tail call i32 @strcpy(i8* %9, i8* %0)
br label %13
11: ; preds = %2
%12 = tail call i32 @strcpy(i8* %6, i8* %0)
br label %13
13: ; preds = %11, %8
%14 = inttoptr i64 %5 to i32*
ret i32* %14
}