#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void draw_triangle(int base, int offset, int length) {
  int i, i1, i2;
  for (i = (base % 2) ? 1 : 2; i <= base; i += 2) {
    for (i2 = 0; i2 != length; i2++) {
      for (i1 = 1; i1 <= ((base - i) / 2) + offset; i1++)
        fputc(' ', stdout);
      for (i1 = 1; i1 <= i; i1++)
        fputc('X', stdout);
      for (i1 = 1; i1 <= (base - i) / 2; i1++)
        fputc(' ', stdout);
    }
    fputc('\n', stdout);
  }
}


x86 assembly (clang, -O0):
<draw_triangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x2,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     125b <draw_triangle+0x14b>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     123a <draw_triangle+0x12a>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     11aa <draw_triangle+0x9a>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <draw_triangle+0x55>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11de <draw_triangle+0xce>
mov    0x2e1c(%rip),%rax
mov    (%rax),%esi
mov    $0x58,%edi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <draw_triangle+0xa1>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jg     1227 <draw_triangle+0x117>
mov    0x2dd3(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e5 <draw_triangle+0xd5>
jmp    122c <draw_triangle+0x11c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <draw_triangle+0x42>
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <draw_triangle+0x2f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_triangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %edi,%eax
and    $0x1,%eax
mov    $0x2,%r13d
sub    %eax,%r13d
mov    %edi,0xc(%rsp)
cmp    %edi,%r13d
jle    114d <draw_triangle+0x3d>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e8c(%rip),%rbx
jmp    1177 <draw_triangle+0x67>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x2,%r13d
cmp    0xc(%rsp),%r13d
jg     113e <draw_triangle+0x2e>
cmpl   $0x0,0x10(%rsp)
je     1160 <draw_triangle+0x50>
mov    0xc(%rsp),%eax
sub    %r13d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
mov    %eax,0x14(%rsp)
add    %eax,%ecx
sar    %ecx
mov    0x18(%rsp),%rax
mov    %rcx,0x20(%rsp)
lea    (%rcx,%rax,1),%r14d
xor    %r12d,%r12d
jmp    11bb <draw_triangle+0xab>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12d
cmp    0x10(%rsp),%r12d
je     1160 <draw_triangle+0x50>
mov    %r14d,%r15d
mov    %r13d,%ebp
test   %r14d,%r14d
jle    11f0 <draw_triangle+0xe0>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
add    $0xffffffff,%r15d
jne    11d0 <draw_triangle+0xc0>
mov    %r13d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%esi
mov    $0x58,%edi
call   1030 <fputc@plt>
add    $0xffffffff,%ebp
jne    11f0 <draw_triangle+0xe0>
mov    0x20(%rsp),%rax
mov    %eax,%ebp
cmpl   $0x2,0x14(%rsp)
jl     11b0 <draw_triangle+0xa0>
nop
mov    (%rbx),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
add    $0xffffffff,%ebp
jne    1210 <draw_triangle+0x100>
jmp    11b0 <draw_triangle+0xa0>

LLVM IR (-O0):
@stdout = global i32 0
define void @draw_triangle(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 1, i32 2
store i32 %14, i32* %7
br label %15
15: ; preds = %72, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %75
19: ; preds = %15
store i32 0, i32* %9
br label %20
20: ; preds = %66, %19
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %69
24: ; preds = %20
store i32 1, i32* %8
br label %25
25: ; preds = %37, %24
%26 = load i32, i32* %8
%27 = load i32, i32* %4
%28 = load i32, i32* %7
%29 = sub nsw i32 %27, %28
%30 = sdiv i32 %29, 2
%31 = load i32, i32* %5
%32 = add nsw i32 %30, %31
%33 = icmp sle i32 %26, %32
br i1 %33, label %34, label %40
34: ; preds = %25
%35 = load i32, i32* @stdout
%36 = call i32 @fputc(i8 signext 32, i32 %35)
br label %37
37: ; preds = %34
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %25
40: ; preds = %25
store i32 1, i32* %8
br label %41
41: ; preds = %48, %40
%42 = load i32, i32* %8
%43 = load i32, i32* %7
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i32, i32* @stdout
%47 = call i32 @fputc(i8 signext 88, i32 %46)
br label %48
48: ; preds = %45
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %41
51: ; preds = %41
store i32 1, i32* %8
br label %52
52: ; preds = %62, %51
%53 = load i32, i32* %8
%54 = load i32, i32* %4
%55 = load i32, i32* %7
%56 = sub nsw i32 %54, %55
%57 = sdiv i32 %56, 2
%58 = icmp sle i32 %53, %57
br i1 %58, label %59, label %65
59: ; preds = %52
%60 = load i32, i32* @stdout
%61 = call i32 @fputc(i8 signext 32, i32 %60)
br label %62
62: ; preds = %59
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %52
65: ; preds = %52
br label %66
66: ; preds = %65
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %20
69: ; preds = %20
%70 = load i32, i32* @stdout
%71 = call i32 @fputc(i8 signext 10, i32 %70)
br label %72
72: ; preds = %69
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 2
store i32 %74, i32* %7
br label %15
75: ; preds = %15
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @draw_triangle(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i32 2, i32 1
%7 = icmp sgt i32 %6, %0
br i1 %7, label %50, label %8
8: ; preds = %3
%9 = icmp eq i32 %2, 0
%10 = add i32 %1, 1
br label %11
11: ; preds = %8, %45
%12 = phi i32 [ %6, %8 ], [ %48, %45 ]
br i1 %9, label %45, label %13
13: ; preds = %11
%14 = sub nsw i32 %0, %12
%15 = sdiv i32 %14, 2
%16 = add nsw i32 %15, %1
%17 = icmp slt i32 %16, 1
%18 = icmp slt i32 %14, 2
%19 = add i32 %10, %15
br label %20
20: ; preds = %13, %42
%21 = phi i32 [ 0, %13 ], [ %43, %42 ]
br i1 %17, label %22, label %23
22: ; preds = %23, %20
br label %30
23: ; preds = %20, %23
%24 = phi i32 [ %27, %23 ], [ 1, %20 ]
%25 = load i32, i32* @stdout
%26 = tail call i32 @fputc(i8 signext 32, i32 %25)
%27 = add nuw i32 %24, 1
%28 = icmp eq i32 %27, %19
br i1 %28, label %22, label %23
29: ; preds = %30
br i1 %18, label %42, label %36
30: ; preds = %22, %30
%31 = phi i32 [ %34, %30 ], [ 1, %22 ]
%32 = load i32, i32* @stdout
%33 = tail call i32 @fputc(i8 signext 88, i32 %32)
%34 = add nuw i32 %31, 1
%35 = icmp eq i32 %31, %12
br i1 %35, label %29, label %30
36: ; preds = %29, %36
%37 = phi i32 [ %40, %36 ], [ 1, %29 ]
%38 = load i32, i32* @stdout
%39 = tail call i32 @fputc(i8 signext 32, i32 %38)
%40 = add nuw nsw i32 %37, 1
%41 = icmp eq i32 %37, %15
br i1 %41, label %42, label %36
42: ; preds = %36, %29
%43 = add nuw nsw i32 %21, 1
%44 = icmp eq i32 %43, %2
br i1 %44, label %45, label %20
45: ; preds = %42, %11
%46 = load i32, i32* @stdout
%47 = tail call i32 @fputc(i8 signext 10, i32 %46)
%48 = add nuw nsw i32 %12, 2
%49 = icmp sgt i32 %48, %0
br i1 %49, label %50, label %11
50: ; preds = %45, %3
ret void
}