#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 rightAngledTriangleRight(int n, char ch) {
  int row;
  int col;
  for (row = 1; row <= n; row++) {
    for (col = 1; col <= n - row; col++)
      printf(" ");
    for (col = 1; col <= row; col++)
      printf("%c", ch);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<rightAngledTriangleRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b7 <rightAngledTriangleRight+0xa7>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jg     1168 <rightAngledTriangleRight+0x58>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <rightAngledTriangleRight+0x2b>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     119b <rightAngledTriangleRight+0x8b>
movsbl -0x5(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <rightAngledTriangleRight+0x5f>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <rightAngledTriangleRight+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rightAngledTriangleRight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1197 <rightAngledTriangleRight+0x87>
mov    %edi,%r15d
movsbl %sil,%ebp
lea    0x1(%r15),%r14d
mov    $0x1,%r13d
mov    $0x2,%r12d
cs nopw 0x0(%rax,%rax,1)
cmp    %r15d,%r13d
jge    1162 <rightAngledTriangleRight+0x52>
mov    %r15d,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    %ebx,%r13d
jne    1150 <rightAngledTriangleRight+0x40>
mov    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1170 <rightAngledTriangleRight+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
lea    0x1(%r12),%eax
cmp    %r14d,%r12d
mov    %eax,%r12d
jne    1140 <rightAngledTriangleRight+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @rightAngledTriangleRight(i32 %0, i8 signext %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %29, label %4
4: ; preds = %2
%5 = sext i8 %1 to i32
%6 = add i32 %0, 1
br label %7
7: ; preds = %4, %23
%8 = phi i32 [ 2, %4 ], [ %27, %23 ]
%9 = phi i32 [ %0, %4 ], [ %26, %23 ]
%10 = phi i32 [ 1, %4 ], [ %25, %23 ]
%11 = icmp slt i32 %10, %0
br i1 %11, label %12, label %17
12: ; preds = %7, %12
%13 = phi i32 [ %15, %12 ], [ 1, %7 ]
%14 = tail call i32 @putchar(i32 32)
%15 = add nuw i32 %13, 1
%16 = icmp eq i32 %15, %9
br i1 %16, label %17, label %12
17: ; preds = %12, %7
br label %18
18: ; preds = %17, %18
%19 = phi i32 [ %21, %18 ], [ 1, %17 ]
%20 = tail call i32 @putchar(i32 %5)
%21 = add nuw i32 %19, 1
%22 = icmp eq i32 %21, %8
br i1 %22, label %23, label %18
23: ; preds = %18
%24 = tail call i32 @putchar(i32 10)
%25 = add nuw nsw i32 %10, 1
%26 = add i32 %9, -1
%27 = add nuw i32 %8, 1
%28 = icmp eq i32 %8, %6
br i1 %28, label %29, label %7
29: ; preds = %23, %2
ret void
}