#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 fillLines(char *, int);
int /*<<< orphan*/ fillSpaces(int, int);
void initInstructions() {
  char *lines[7] = {" New to gedit? Here are some tips...",
                    "    -> Tab to enter/exit writeMode",
                    "        In writeMode",
                    "         |",
                    "         |-> wasd to navigate",
                    "         |-> c to clear screen",
                    "         |-> q to quit"};
  char *line1 = " New to gedit? Here are some tips...";
  char *line2 = "    -> Tab to enter/exit writeMode";
  char *line3 = "        In writeMode";
  char *line4 = "         |";
  char *line5 = "         |-> wasd to navigate";
  char *line6 = "         |-> c to clear screen";
  char *line7 = "         |-> q to quit";
  for (int i = 0; i < 7; i++) {
    int cantChars = fillLines(lines[i], i);
    fillSpaces(i, cantChars);
  }
}


x86 assembly (clang, -O0):
<initInstructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x40(%rbp),%rdi
lea    0x2c9a(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    0xea9(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xee5(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xee5(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xef8(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xf0c(%rip),%rax
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
cmpl   $0x7,-0x7c(%rbp)
jge    11db <initInstructions+0xab>
movslq -0x7c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
mov    -0x7c(%rbp),%esi
call   1030 <fillLines@plt>
mov    %eax,-0x80(%rbp)
mov    -0x7c(%rbp),%edi
mov    -0x80(%rbp),%esi
call   1050 <fillSpaces@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11a4 <initInstructions+0x74>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initInstructions>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %esi,%esi
call   1030 <fillLines@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xee6(%rip),%rdi
mov    $0x1,%esi
call   1030 <fillLines@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xeec(%rip),%rdi
mov    $0x2,%esi
call   1030 <fillLines@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xee4(%rip),%rdi
mov    $0x3,%esi
call   1030 <fillLines@plt>
mov    $0x3,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xed2(%rip),%rdi
mov    $0x4,%esi
call   1030 <fillLines@plt>
mov    $0x4,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xed3(%rip),%rdi
mov    $0x5,%esi
call   1030 <fillLines@plt>
mov    $0x5,%edi
mov    %eax,%esi
call   1040 <fillSpaces@plt>
lea    0xed5(%rip),%rdi
mov    $0x6,%esi
call   1030 <fillLines@plt>
mov    $0x6,%edi
mov    %eax,%esi
pop    %rax
jmp    1040 <fillSpaces@plt>

LLVM IR (-O0):
@.str = [37 x i8] c" New to gedit? Here are some tips...\00"
@.str.1 = [35 x i8] c" -> Tab to enter/exit writeMode\00"
@.str.2 = [21 x i8] c" In writeMode\00"
@.str.3 = [11 x i8] c" |\00"
@.str.4 = [30 x i8] c" |-> wasd to navigate\00"
@.str.5 = [31 x i8] c" |-> c to clear screen\00"
@.str.6 = [23 x i8] c" |-> q to quit\00"
@__const.initInstructions.lines = [7 x i8*] [i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i32 0, i32 0)]
define void @initInstructions() {
%1 = alloca [7 x i8*]
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = bitcast [7 x i8*]* %1 to i8*
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8** %8
store i32 0, i32* %9
br label %12
12: ; preds = %25, %0
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 7
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [7 x i8*], [7 x i8*]* %1, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = load i32, i32* %9
%21 = call i32 @fillLines(i8* %19, i32 %20)
store i32 %21, i32* %10
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = call i32 @fillSpaces(i32 %22, i32 %23)
br label %25
25: ; preds = %15
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %12
28: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c" New to gedit? Here are some tips...\00"
@.str.1 = [35 x i8] c" -> Tab to enter/exit writeMode\00"
@.str.2 = [21 x i8] c" In writeMode\00"
@.str.3 = [11 x i8] c" |\00"
@.str.4 = [30 x i8] c" |-> wasd to navigate\00"
@.str.5 = [31 x i8] c" |-> c to clear screen\00"
@.str.6 = [23 x i8] c" |-> q to quit\00"
define void @initInstructions() {
%1 = tail call i32 @fillLines(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 @fillSpaces(i32 0, i32 %1)
%3 = tail call i32 @fillLines(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @fillSpaces(i32 1, i32 %3)
%5 = tail call i32 @fillLines(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 2)
%6 = tail call i32 @fillSpaces(i32 2, i32 %5)
%7 = tail call i32 @fillLines(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 3)
%8 = tail call i32 @fillSpaces(i32 3, i32 %7)
%9 = tail call i32 @fillLines(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 4)
%10 = tail call i32 @fillSpaces(i32 4, i32 %9)
%11 = tail call i32 @fillLines(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 5)
%12 = tail call i32 @fillSpaces(i32 5, i32 %11)
%13 = tail call i32 @fillLines(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 6)
%14 = tail call i32 @fillSpaces(i32 6, i32 %13)
ret void
}