#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 count_convert(int /*<<< orphan*/);
int /*<<< orphan*/ lgs(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int arr[400] = {
      0,
  };
  int arr_size;
  int i, j;
  printf("n= ");
  scanf("%d", &arr_size);
  for (i = 0; i < arr_size; ++i)
    scanf("%d", &arr[i]);
  printf("%d\n", count_convert(lgs(arr, arr_size)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x660,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x650(%rbp),%rdi
xor    %esi,%esi
mov    $0x640,%edx
call   1040 <memset@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    -0x654(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x658(%rbp)
mov    -0x658(%rbp),%eax
cmp    -0x654(%rbp),%eax
jge    11e7 <main+0x97>
movslq -0x658(%rbp),%rax
lea    -0x650(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe36(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x658(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x658(%rbp)
jmp    11a0 <main+0x50>
lea    -0x650(%rbp),%rdi
mov    -0x654(%rbp),%esi
call   1070 <lgs@plt>
mov    %eax,%edi
call   1050 <count_convert@plt>
mov    %eax,%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x650,%rsp
lea    0x10(%rsp),%r15
mov    $0x640,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11bd <main+0x6d>
xor    %ebx,%ebx
lea    0xe64(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     11a0 <main+0x50>
lea    0x10(%rsp),%rdi
call   1070 <lgs@plt>
mov    %eax,%edi
call   1050 <count_convert@plt>
lea    0xe32(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x650,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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