#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 is_sqr(int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *);
int count(int n) {
  int count = 0;
  int number;
  for (int i = 0; i < n; i++) {
    if (scanf("%i", &number) == 1) {
      if (is_sqr(number) == 1) {
        printf("%i\n", number);
        count++;
      }
    } else {
      break;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b4 <count+0x84>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    119c <count+0x6c>
mov    -0xc(%rbp),%edi
call   1030 <is_sqr@plt>
cmp    $0x1,%eax
jne    1197 <count+0x67>
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <count+0x71>
jmp    11b4 <count+0x84>
jmp    11a6 <count+0x76>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <count+0x19>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1194 <count+0x64>
mov    %edi,%ebp
xor    %ebx,%ebx
lea    0xeb5(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xeac(%rip),%r12
jmp    1165 <count+0x35>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     1196 <count+0x66>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1196 <count+0x66>
mov    0xc(%rsp),%edi
call   1030 <is_sqr@plt>
cmp    $0x1,%eax
jne    1160 <count+0x30>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1160 <count+0x30>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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