#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 drawTriangle(int n, char c) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n - i - 1; j++) {
      printf(" ");
    }
    for (j = 0; j < i + 1 + i; j++) {
      printf("%c", c);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<drawTriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c2 <drawTriangle+0xb2>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    116b <drawTriangle+0x5b>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <drawTriangle+0x2b>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11a6 <drawTriangle+0x96>
movsbl -0x5(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <drawTriangle+0x62>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <drawTriangle+0x18>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawTriangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    119f <drawTriangle+0x8f>
mov    %edi,%r14d
movsbl %sil,%ebp
xor    %r15d,%r15d
mov    $0x1,%r12d
mov    %edi,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%eax
not    %eax
add    %r14d,%eax
test   %eax,%eax
jle    1172 <drawTriangle+0x62>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    1160 <drawTriangle+0x50>
add    $0xffffffff,%r13d
add    $0x1,%r15d
mov    %r12d,%ebx
nopl   (%rax)
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1180 <drawTriangle+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x2,%r12d
cmp    %r14d,%r15d
jne    1140 <drawTriangle+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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 @drawTriangle(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 0, i32* %5
br label %7
7: ; preds = %41, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %21, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = sub nsw i32 %14, %15
%17 = sub nsw i32 %16, 1
%18 = icmp slt i32 %13, %17
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %12
24: ; preds = %12
store i32 0, i32* %6
br label %25
25: ; preds = %36, %24
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %5
%30 = add nsw i32 %28, %29
%31 = icmp slt i32 %26, %30
br i1 %31, label %32, label %39
32: ; preds = %25
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %25
39: ; preds = %25
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %7
44: ; preds = %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

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