#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 */
scalar_t__ es_una_A(char);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
void main(void) {
  int i;
  char cadena[40] = "Hola dola pepsi cola\n";
  for (i = 0; i < strlen(cadena); i++) {
    if (es_una_A(cadena[i]))
      printf("En la posición %d tenemos una letra 'a'\n", i);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    11ba <main+0x7a>
movslq -0x4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1060 <es_una_A@plt>
cmp    $0x0,%rax
je     11a7 <main+0x67>
mov    -0x4(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <main+0x6c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <main+0x24>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11ad <main+0x7d>
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0xeb7(%rip),%r15
jmp    1193 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11ad <main+0x7d>
movsbl (%rsp,%rbx,1),%edi
call   1050 <es_una_A@plt>
test   %rax,%rax
je     1180 <main+0x50>
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
jmp    1180 <main+0x50>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.cadena = [40 x i8] c"Hola dola pepsi cola\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [42 x i8] c"En la posici\C3\B3n %d tenemos una letra 'a'\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = bitcast [40 x i8]* %2 to i8*
store i32 0, i32* %1
br label %4
4: ; preds = %20, %0
%5 = load i32, i32* %1
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %23
9: ; preds = %4
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @es_una_A(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %1
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %1
%22 = add nsw i32 %21, 1
store i32 %22, i32* %1
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@__const.main.cadena = [40 x i8] c"Hola dola pepsi cola\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [42 x i8] c"En la posici\C3\B3n %d tenemos una letra 'a'\0A\00"
define void @main() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 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 %19
5: ; preds = %0, %14
%6 = phi i64 [ %15, %14 ], [ 0, %0 ]
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = call i64 @es_una_A(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %5, %11
%15 = add nuw nsw i64 %6, 1
%16 = call i32 @strlen(i8* %2)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %5, label %19
19: ; preds = %14, %0
ret void
}