#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*/ printf(char *, ...);
void printtriangle(char *ch, int base) {
  char c = *ch;
  int i = 1;
  int j = 1;
  for (i = 1; i <= base; i++) {
    for (j = 1; j <= i; j++) {
      printf("%c", c);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printtriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xd(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1198 <printtriangle+0x88>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     117c <printtriangle+0x6c>
movsbl -0xd(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1150 <printtriangle+0x40>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <printtriangle+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printtriangle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1176 <printtriangle+0x66>
mov    %esi,%r14d
movsbl (%rdi),%ebp
add    $0x1,%r14d
mov    $0x2,%r15d
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1150 <printtriangle+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
add    $0x1,%r12d
cmp    %r14d,%r15d
mov    %eax,%r15d
jne    1140 <printtriangle+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @printtriangle(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
%7 = add i32 %1, 1
br label %8
8: ; preds = %4, %15
%9 = phi i32 [ 2, %4 ], [ %17, %15 ]
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 1, %8 ], [ %13, %10 ]
%12 = tail call i32 @putchar(i32 %6)
%13 = add nuw i32 %11, 1
%14 = icmp eq i32 %13, %9
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = tail call i32 @putchar(i32 10)
%17 = add nuw i32 %9, 1
%18 = icmp eq i32 %9, %7
br i1 %18, label %19, label %8
19: ; preds = %15, %2
ret void
}