#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
unsigned int strlen(char *);
int main(int argc, char *argv[]) {
  char str1[128];
  char str2[] = "abcdefghijk";
  unsigned int n, i;
  printf("Idatzi esaldi bat: ");
  fgets(str1, 128, stdin);
  n = 0;
  for (i = 0; i < strlen(str1); i++)
    if (str1[i] == 'a')
      n++;
  printf("\n\"%s\" esaldian %d aldiz dago 'a' letra\n", str1, n);
  n = 0;
  i = 0;
  while (str2[i] != '\0') {
    if (str1[i] == 'a')
      n++;
    i++;
  }
  printf("\n\"");
  printf(str2);
  printf("\"");
  printf(" esaldian %d aldiz dago 'a' letra\n", n);
  printf("Sakatu \"return\" amaitzeko .....");
  fgets(str1, 128, stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x9c(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x94(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
movl   $0x0,-0xa0(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xa8(%rbp),%eax
cmp    %ecx,%eax
jae    1206 <main+0xd6>
mov    -0xa4(%rbp),%eax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
jne    11ed <main+0xbd>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
jmp    11f2 <main+0xc2>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    119f <main+0x6f>
lea    -0x90(%rbp),%rsi
mov    -0xa0(%rbp),%edx
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xa0(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
movsbl -0x9c(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1286 <main+0x156>
mov    -0xa4(%rbp),%eax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
jne    1272 <main+0x142>
mov    -0xa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1235 <main+0x105>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x9c(%rbp),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xa0(%rbp),%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
movabs $0x6867666564636261,%rax
66 67 68
mov    %rax,(%rsp)
movl   $0x6b6a69,0x8(%rsp)
lea    0xea0(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e6b(%rip),%r15
mov    (%r15),%edx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    $0x0,%ebp
test   %eax,%eax
je     11cf <main+0x8f>
xor    %ebx,%ebx
lea    0x10(%rsp),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
cmpb   $0x61,0x10(%rsp,%rbx,1)
sete   %al
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     11b0 <main+0x70>
lea    0xe4a(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmpb   $0x61,0x10(%rsp,%rax,1)
sete   %cl
add    %ecx,%r12d
add    $0x1,%eax
cmpb   $0x0,(%rsp,%rax,1)
jne    11f0 <main+0xb0>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x22,%edi
call   1030 <putchar@plt>
lea    0xdf6(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%edx
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str2 = [12 x i8] c"abcdefghijk\00"
@.str = [20 x i8] c"Idatzi esaldi bat: \00"
@stdin = global i32 0
@.str.1 = [40 x i8] c"\0A\22%s\22 esaldian %d aldiz dago 'a' letra\0A\00"
@.str.2 = [3 x i8] c"\0A\22\00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [35 x i8] c" esaldian %d aldiz dago 'a' letra\0A\00"
@.str.5 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca [12 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [12 x i8]* %7 to i8*
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 128, i32 %13)
store i32 0, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %31, %2
%16 = load i32, i32* %9
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp ult i32 %16, %18
br i1 %19, label %20, label %34
20: ; preds = %15
%21 = load i32, i32* %9
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 97
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32, i32* %8
%29 = add i32 %28, 1
store i32 %29, i32* %8
br label %30
30: ; preds = %27, %20
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add i32 %32, 1
store i32 %33, i32* %9
br label %15
34: ; preds = %15
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%36 = load i32, i32* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %35, i32 %36)
store i32 0, i32* %8
store i32 0, i32* %9
br label %38
38: ; preds = %55, %34
%39 = load i32, i32* %9
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %58
45: ; preds = %38
%46 = load i32, i32* %9
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 97
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = load i32, i32* %8
%54 = add i32 %53, 1
store i32 %54, i32* %8
br label %55
55: ; preds = %52, %45
%56 = load i32, i32* %9
%57 = add i32 %56, 1
store i32 %57, i32* %9
br label %38
58: ; preds = %38
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%60 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%61 = call i32 (i8*, ...) @printf(i8* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32, i32* %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%67 = load i32, i32* @stdin
%68 = call i32 @fgets(i8* %66, i32 128, i32 %67)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str2 = [12 x i8] c"abcdefghijk\00"
@.str = [20 x i8] c"Idatzi esaldi bat: \00"
@stdin = global i32 0
@.str.1 = [40 x i8] c"\0A\22%s\22 esaldian %d aldiz dago 'a' letra\0A\00"
@.str.2 = [3 x i8] c"\0A\22\00"
@.str.4 = [35 x i8] c" esaldian %d aldiz dago 'a' letra\0A\00"
@.str.5 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 128, i32 %8)
%10 = call i32 @strlen(i8* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %2, %12
%13 = phi i64 [ %20, %12 ], [ 0, %2 ]
%14 = phi i32 [ %19, %12 ], [ 0, %2 ]
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %13
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 97
%18 = zext i1 %17 to i32
%19 = add i32 %14, %18
%20 = add nuw nsw i64 %13, 1
%21 = call i32 @strlen(i8* %5)
%22 = zext i32 %21 to i64
%23 = icmp ult i64 %20, %22
br i1 %23, label %12, label %24
24: ; preds = %12, %2
%25 = phi i32 [ 0, %2 ], [ %19, %12 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %25)
br label %27
27: ; preds = %24, %27
%28 = phi i64 [ %36, %27 ], [ 0, %24 ]
%29 = phi i32 [ %34, %27 ], [ 0, %24 ]
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %28
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 97
%33 = zext i1 %32 to i32
%34 = add i32 %29, %33
%35 = add nuw nsw i64 %28, 1
%36 = and i64 %35, 4294967295
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %40, label %27
40: ; preds = %27
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* %6)
%43 = call i32 @putchar(i32 34)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32, i32* @stdin
%47 = call i32 @fgets(i8* %5, i32 128, i32 %46)
ret i32 0
}