#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 */
struct winsize {
  int ws_row;
  int ws_col;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ printf(char *);
int main() {
  struct winsize ws;
  int row, space, triangle;
  ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
  for (row = 1; row < ws.ws_row; ++row) {
    for (space = ws.ws_col / 2 - row; space > 0; --space) {
      printf(" ");
    }
    for (triangle = 1; triangle < row * 2; ++triangle) {
      printf("*");
    }
    printf("\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%edi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11de <main+0xbe>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1192 <main+0x72>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <main+0x4e>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11c4 <main+0xa4>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <main+0x79>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1151 <main+0x31>
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1040 <ioctl@plt>
cmpl   $0x2,(%rsp)
jl     11c9 <main+0xa9>
xor    %r14d,%r14d
mov    $0x1,%r15d
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    0x4(%rsp),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
cmp    %ebx,%ebp
jle    1192 <main+0x72>
add    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1180 <main+0x60>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    $0xffffffff,%r14d
add    $0x2,%r15d
cmp    (%rsp),%ebx
jl     1160 <main+0x40>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.winsize = type { i32, i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.winsize
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @STDOUT_FILENO
%7 = load i32, i32* @TIOCGWINSZ
%8 = call i32 @ioctl(i32 %6, i32 %7, %struct.winsize* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %41, %0
%10 = load i32, i32* %3
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %44
14: ; preds = %9
%15 = getelementptr inbounds %struct.winsize, %struct.winsize* %2, i32 0, i32 1
%16 = load i32, i32* %15
%17 = sdiv i32 %16, 2
%18 = load i32, i32* %3
%19 = sub nsw i32 %17, %18
store i32 %19, i32* %4
br label %20
20: ; preds = %25, %14
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
br label %20
28: ; preds = %20
store i32 1, i32* %5
br label %29
29: ; preds = %36, %28
%30 = load i32, i32* %5
%31 = load i32, i32* %3
%32 = mul nsw i32 %31, 2
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %29
39: ; preds = %29
%40 = call i32 @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* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %9
44: ; preds = %9
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}

LLVM IR (-O2):
%struct.winsize = type { i32, i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.winsize
%2 = bitcast %struct.winsize* %1 to i8*
%3 = load i32, i32* @STDOUT_FILENO
%4 = load i32, i32* @TIOCGWINSZ
%5 = call i32 @ioctl(i32 %3, i32 %4, %struct.winsize* %1)
%6 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %35
9: ; preds = %0
%10 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 1
br label %11
11: ; preds = %9, %29
%12 = phi i32 [ 2, %9 ], [ %34, %29 ]
%13 = phi i32 [ 1, %9 ], [ %31, %29 ]
%14 = load i32, i32* %10
%15 = sdiv i32 %14, 2
%16 = sub nsw i32 %15, %13
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %11, %18
%19 = phi i32 [ %21, %18 ], [ %16, %11 ]
%20 = call i32 @putchar(i32 32)
%21 = add nsw i32 %19, -1
%22 = icmp ugt i32 %19, 1
br i1 %22, label %18, label %23
23: ; preds = %18, %11
br label %24
24: ; preds = %23, %24
%25 = phi i32 [ %27, %24 ], [ 1, %23 ]
%26 = call i32 @putchar(i32 42)
%27 = add nuw i32 %25, 1
%28 = icmp eq i32 %27, %12
br i1 %28, label %29, label %24
29: ; preds = %24
%30 = call i32 @putchar(i32 10)
%31 = add nuw nsw i32 %13, 1
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
%34 = add nuw i32 %12, 2
br i1 %33, label %11, label %35
35: ; preds = %29, %0
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}