#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*/ draw_roof(int, int, char **, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
void merge_roof(int floor, int column, char **output, int shift) {
  int row = floor * 2;
  int small_column = column * 4 + shift;
  memcpy(output[row] + small_column - 2, "/   \\", sizeof(char) * 5);
  memcpy(output[row - 1] + small_column - 1, "   ", sizeof(char) * 3);
  if (output[row - 2][small_column] == '/') {
    output[row - 2][small_column] = ' ';
  }
  draw_roof(floor + 1, column, output, shift - 2);
}


x86 assembly (clang, -O0):
<merge_roof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe98(%rip),%rsi
mov    $0x5,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
lea    0xe71(%rip),%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11da <merge_roof+0xba>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
call   1030 <draw_roof@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_roof>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,%r15d
mov    %edi,%r13d
lea    0x0(%r13,%r13,1),%eax
lea    (%r14,%r15,4),%ecx
movslq %eax,%rbp
mov    (%rdx,%rbp,8),%rax
movslq %ecx,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xea7(%rip),%rsi
mov    $0x5,%edx
call   1040 <memcpy@plt>
mov    -0x8(%r12,%rbp,8),%rax
lea    (%rax,%rbx,1),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xe8f(%rip),%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
mov    -0x10(%r12,%rbp,8),%rax
cmpb   $0x2f,(%rax,%rbx,1)
jne    1190 <merge_roof+0x70>
movb   $0x20,(%rax,%rbx,1)
add    $0x1,%r13d
add    $0xfffffffe,%r14d
mov    %r13d,%edi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <draw_roof@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"/ \\\00"
@.str.1 = [4 x i8] c" \00"
define void @merge_roof(i32 %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%11 = load i32, i32* %5
%12 = mul nsw i32 %11, 2
store i32 %12, i32* %9
%13 = load i32, i32* %6
%14 = mul nsw i32 %13, 4
%15 = load i32, i32* %8
%16 = add nsw i32 %14, %15
store i32 %16, i32* %10
%17 = load i8**, i8*** %7
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 -2
%26 = call i32 @memcpy(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%27 = load i8**, i8*** %7
%28 = load i32, i32* %9
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = getelementptr inbounds i8, i8* %35, i64 -1
%37 = call i32 @memcpy(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%38 = load i8**, i8*** %7
%39 = load i32, i32* %9
%40 = sub nsw i32 %39, 2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %38, i64 %41
%43 = load i8*, i8** %42
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 47
br i1 %49, label %50, label %60
50: ; preds = %4
%51 = load i8**, i8*** %7
%52 = load i32, i32* %9
%53 = sub nsw i32 %52, 2
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %51, i64 %54
%56 = load i8*, i8** %55
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 32, i8* %59
br label %60
60: ; preds = %50, %4
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %6
%64 = load i8**, i8*** %7
%65 = load i32, i32* %8
%66 = sub nsw i32 %65, 2
%67 = call i32 @draw_roof(i32 %62, i32 %63, i8** %64, i32 %66)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"/ \\\00"
@.str.1 = [4 x i8] c" \00"
define void @merge_roof(i32 %0, i32 %1, i8** %2, i32 %3) {
%5 = shl nsw i32 %0, 1
%6 = shl nsw i32 %1, 2
%7 = add nsw i32 %6, %3
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8*, i8** %2, i64 %8
%10 = load i8*, i8** %9
%11 = sext i32 %7 to i64
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -2
%14 = tail call i32 @memcpy(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%15 = add nsw i32 %5, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %2, i64 %16
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i64 %11
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = tail call i32 @memcpy(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%22 = add nsw i32 %5, -2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %2, i64 %23
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 %11
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 47
br i1 %28, label %29, label %30
29: ; preds = %4
store i8 32, i8* %26
br label %30
30: ; preds = %29, %4
%31 = add nsw i32 %0, 1
%32 = add nsw i32 %3, -2
%33 = tail call i32 @draw_roof(i32 %31, i32 %1, i8** %2, i32 %32)
ret void
}