#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  int inicio = 1;
  int final = 5;
  printf("\nFor com variavel numerica: \n");
  for (inicio = 1; inicio <= final; inicio++) {
    printf("Posicao [%d] de [%d]\n", inicio, final);
  }
  int ini = 1;
  int fin = 5;
  printf("\nFor com variavel numerica (decrescente): \n");
  for (fin = 5; fin >= ini; fin--) {
    printf("Posicao [%d] de [%d]\n", fin, ini);
  }
  int posicao = 0;
  char nome[60];
  printf("\nDigite um nome (maximo de 60 caracteres): ");
  gets(nome);
  printf("\nFor com variavel texto: \n");
  for (posicao = 0; posicao <= strlen(nome); posicao++) {
    printf("Posicao [%2d] = [%c]\n", posicao, nome[posicao]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1190 <main+0x60>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x32>
movl   $0x1,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x5,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11e1 <main+0xb1>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <main+0x83>
movl   $0x0,-0x18(%rbp)
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1050 <gets@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
cmp    %ecx,%eax
jg     1258 <main+0x128>
mov    -0x18(%rbp),%esi
movslq -0x18(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1214 <main+0xe4>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     1296 <main+0x156>
lea    0xdd8(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
nop
movsbl (%rsp,%rbx,1),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%rbx),%r12
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
mov    %r12,%rbx
jl     1270 <main+0x130>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Posicao [%d] de [%d]\0A\00"
@.str.3 = [44 x i8] c"\0ADigite um nome (maximo de 60 caracteres): \00"
@.str.5 = [22 x i8] c"Posicao [%2d] = [%c]\0A\00"
@str = [29 x i8] c"\0AFor com variavel numerica: \00"
@str.6 = [43 x i8] c"\0AFor com variavel numerica (decrescente): \00"
@str.7 = [26 x i8] c"\0AFor com variavel texto: \00"
define i32 @main() {
%1 = alloca [60 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 5)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 5)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 5)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 1)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 1)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1)
%14 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @gets(i8* %14)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%18 = call i32 @strlen(i8* %14)
%19 = icmp slt i32 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %0, %20
%21 = phi i64 [ %27, %20 ], [ 0, %0 ]
%22 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = trunc i64 %21 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %24)
%27 = add nuw nsw i64 %21, 1
%28 = call i32 @strlen(i8* %14)
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %21, %29
br i1 %30, label %20, label %31
31: ; preds = %20, %0
ret i32 0
}