#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 *, ...);
int strlen(char *);
int main() {
  char word[] = {'p', 'r', 'o', 'g', 'r', 'a', 'm'};
  int i = 0;
  int j = 0;
  int length = strlen(word);
  for (i = 0; i < length; i++) {
    for (j = 0; j < length; j++) {
      if (i == j) {
        printf("%c", word[i]);
      } else if (i + j == length - 1) {
        printf("%c", word[(length - 1) - i]);
      } else {
        printf(" ");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xebd(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122d <main+0x10d>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1211 <main+0xf1>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11b4 <main+0x94>
movslq -0x10(%rbp),%rax
movsbl -0xb(%rbp,%rax,1),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <main+0xde>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11eb <main+0xcb>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
sub    -0x10(%rbp),%eax
cltq
movsbl -0xb(%rbp,%rax,1),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f9 <main+0xd9>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <main+0xde>
jmp    1203 <main+0xe3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <main+0x60>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <main+0x4d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x6d617267,0xb(%rsp)
6d
movl   $0x676f7270,0x8(%rsp)
67
lea    0x8(%rsp),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11d1 <main+0xb1>
mov    %eax,%r12d
lea    -0x1(%r12),%eax
mov    %rax,0x10(%rsp)
mov    %r12d,%r15d
neg    %r12d
xor    %ebx,%ebx
jmp    1183 <main+0x63>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     11d1 <main+0xb1>
mov    0x10(%rsp),%r13
sub    %rbx,%r13
lea    (%r12,%rbx,1),%rbp
xor    %r14d,%r14d
jmp    11b6 <main+0x96>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x8(%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r14
mov    %r14d,%eax
add    %r12d,%eax
je     1170 <main+0x50>
mov    %rbx,%rax
cmp    %r14,%rbx
je     11a0 <main+0x80>
lea    (%r14,%rbp,1),%ecx
mov    $0x20,%edi
mov    %r13,%rax
cmp    $0xffffffff,%ecx
jne    11a5 <main+0x85>
jmp    11a0 <main+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.word = [7 x i8] c"program"
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [7 x i8]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
store i32 0, i32* %3
br label %9
9: ; preds = %55, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %58
13: ; preds = %9
store i32 0, i32* %4
br label %14
14: ; preds = %50, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %53
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %49
29: ; preds = %18
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %46
36: ; preds = %29
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
%39 = load i32, i32* %3
%40 = sub nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
br label %48
46: ; preds = %29
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %36
br label %49
49: ; preds = %48, %22
br label %50
50: ; preds = %49
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %14
53: ; preds = %14
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %9
58: ; preds = %9
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@__const.main.word = [7 x i8] c"program"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %34
5: ; preds = %0
%6 = add nsw i32 %3, -1
%7 = zext i32 %6 to i64
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %30, %5
%10 = phi i64 [ 0, %5 ], [ %32, %30 ]
%11 = trunc i64 %10 to i32
%12 = sub nsw i64 %7, %10
br label %13
13: ; preds = %9, %25
%14 = phi i32 [ 0, %9 ], [ %28, %25 ]
%15 = zext i32 %14 to i64
%16 = icmp eq i64 %10, %15
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = add nuw nsw i32 %14, %11
%19 = icmp eq i32 %18, %6
br i1 %19, label %20, label %25
20: ; preds = %17, %13
%21 = phi i64 [ %10, %13 ], [ %12, %17 ]
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
br label %25
25: ; preds = %20, %17
%26 = phi i32 [ 32, %17 ], [ %24, %20 ]
%27 = call i32 @putchar(i32 %26)
%28 = add nuw nsw i32 %14, 1
%29 = icmp eq i32 %28, %3
br i1 %29, label %30, label %13
30: ; preds = %25
%31 = call i32 @putchar(i32 10)
%32 = add nuw nsw i64 %10, 1
%33 = icmp eq i64 %32, %8
br i1 %33, label %34, label %9
34: ; preds = %30, %0
ret i32 0
}