#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 *, char *);
int strlen(char *);
int main(void) {
  char str[6] = "UTFPR";
  for (int j = strlen(str); j >= 0; j--) {
    for (int i = 0; i < j; i++) {
      str[j] = '\0';
      printf("%s\n", str + i);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11ad <main+0x8d>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119a <main+0x7a>
movslq -0x10(%rbp),%rax
movb   $0x0,-0xa(%rbp,%rax,1)
lea    -0xa(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <main+0x40>
jmp    119f <main+0x7f>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <main+0x2f>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movw   $0x52,0x4(%rsp)
movl   $0x50465455,(%rsp)
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     1182 <main+0x62>
mov    %eax,%r12d
lea    0xeba(%rip),%r14
mov    %r12,%r15
nop
sub    $0x1,%r15
jb     1182 <main+0x62>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rsp,%r12,1)
lea    (%rsp,%rbx,1),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <main+0x40>
test   %r12,%r12
mov    %r15,%r12
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str = [6 x i8] c"UTFPR\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [6 x i8]* %2 to i8*
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
br label %8
8: ; preds = %29, %0
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %8
store i32 0, i32* %4
br label %12
12: ; preds = %25, %11
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %12
28: ; preds = %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %8
32: ; preds = %8
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@__const.main.str = [6 x i8] c"UTFPR\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = zext i32 %3 to i64
br label %7
7: ; preds = %5, %13
%8 = phi i64 [ %6, %5 ], [ %14, %13 ]
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %8
br label %15
12: ; preds = %7, %13, %0
ret i32 0
13: ; preds = %15
%14 = add nsw i64 %8, -1
br i1 %9, label %12, label %7
15: ; preds = %10, %15
%16 = phi i64 [ 0, %10 ], [ %19, %15 ]
store i8 0, i8* %11
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = add nuw nsw i64 %16, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %13, label %15
}