#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 triangles_in_the_term(int h, int n) {
  int height;
  int space;
  int star;
  int ncopy;
  for (ncopy = 1; ncopy <= n; ncopy++) {
    for (height = 1; height <= h; height++) {
      for (space = h - height; space > 0; space--) {
        printf(" ");
      }
      for (star = 1; star <= height * 2 - 1; star++) {
        printf("*");
      }
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<triangles_in_the_term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d3 <triangles_in_the_term+0xc3>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c0 <triangles_in_the_term+0xb0>
mov    -0x4(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1171 <triangles_in_the_term+0x61>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <triangles_in_the_term+0x3d>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11a6 <triangles_in_the_term+0x96>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <triangles_in_the_term+0x68>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <triangles_in_the_term+0x28>
jmp    11c5 <triangles_in_the_term+0xb5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1125 <triangles_in_the_term+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangles_in_the_term>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    11d1 <triangles_in_the_term+0xc1>
mov    %edi,%r14d
mov    $0x1,%r15d
jmp    1152 <triangles_in_the_term+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%r15),%eax
cmp    0x4(%rsp),%r15d
mov    %eax,%r15d
je     11d1 <triangles_in_the_term+0xc1>
test   %r14d,%r14d
jle    1140 <triangles_in_the_term+0x30>
mov    $0x1,%ebx
mov    %r14d,%r12d
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r13d,%r14d
jle    1192 <triangles_in_the_term+0x82>
mov    %r12d,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1180 <triangles_in_the_term+0x70>
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11a0 <triangles_in_the_term+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%eax
add    $0xffffffff,%r12d
add    $0x2,%ebx
cmp    %r14d,%r13d
mov    %eax,%r13d
jne    1170 <triangles_in_the_term+0x60>
jmp    1140 <triangles_in_the_term+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 = [2 x i8] c"*\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @triangles_in_the_term(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, i32* %8
br label %9
9: ; preds = %48, %2
%10 = load i32, i32* %8
%11 = load i32, i32* %4
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %51
13: ; preds = %9
store i32 1, i32* %5
br label %14
14: ; preds = %44, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
store i32 %21, i32* %6
br label %22
22: ; preds = %27, %18
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %22
30: ; preds = %22
store i32 1, i32* %7
br label %31
31: ; preds = %39, %30
%32 = load i32, i32* %7
%33 = load i32, i32* %5
%34 = mul nsw i32 %33, 2
%35 = sub nsw i32 %34, 1
%36 = icmp sle i32 %32, %35
br i1 %36, label %37, label %42
37: ; preds = %31
%38 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %31
42: ; preds = %31
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %14
47: ; preds = %14
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %9
51: ; preds = %9
ret void
}

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