#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 *);
void main() {
  char str[10] = "newyork12";
  int i = 0;
  int j, n;
  printf("%d\n", strlen(str));
  do {
    for (j = 0; j <= i; j++) {
      printf("%c", str[j]);
    }
    printf("\n");
    i++;
  } while (i < strlen(str));
  n = strlen(str);
  do {
    for (j = 0; j <= n; j++) {
      printf("%c", str[j]);
    }
    printf("\n");
    n--;
  } while (n >= 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xa(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x2(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1196 <main+0x76>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <main+0x45>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jl     115e <main+0x3e>
lea    -0xa(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     120d <main+0xed>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <main+0xbc>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11d5 <main+0xb5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x316b726f7977656e,%rax
72 6b 31
mov    %rax,0x8(%rsp)
movw   $0x32,0x10(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xea5(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x8(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0x1,%r12
cmp    %eax,%r15d
jl     1180 <main+0x50>
lea    0x8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %eax,%r15d
add    $0x1,%r15d
jmp    11fa <main+0xca>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%r14),%eax
add    $0xffffffff,%r15d
test   %r14d,%r14d
mov    %eax,%r14d
jle    1225 <main+0xf5>
mov    %r15d,%r15d
test   %r14d,%r14d
js     11e0 <main+0xb0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x8(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1210 <main+0xe0>
jmp    11e0 <main+0xb0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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