#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() {
  int i, k, j, len;
  char s[100] = "bangladesh";
  for (i = 0; s[i] != '\0'; i++) {
    for (k = 0; k <= i; k++) {
      printf("%c", s[k]);
    }
    printf("\n");
  }
  len = strlen(s);
  for (i = len - 2; i >= 0; i--) {
    for (k = 0; k <= i; k++) {
      printf("%c", s[k]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c4 <main+0x94>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a8 <main+0x78>
movslq -0xc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%esi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <main+0x47>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <main+0x2e>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1237 <main+0x107>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121b <main+0xeb>
movslq -0xc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ea <main+0xba>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11d9 <main+0xa9>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
movaps 0xf20(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf04(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x1,%r15d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmpb   $0x0,0x1(%rsp,%r14,1)
lea    0x1(%r14),%r14
jne    1190 <main+0x70>
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     122c <main+0x10c>
mov    %eax,%r15d
lea    -0x2(%r15),%r14d
add    $0xffffffff,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1200 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%r14),%eax
add    $0xffffffffffffffff,%r15
test   %r14d,%r14d
mov    %eax,%r14d
jg     11f0 <main+0xd0>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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