#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*/ foo(int *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int arr[100];
  int n, i, ele;
  i = 0;
  while (scanf("%d", &ele) > 0)
    arr[i++] = ele;
  n = i;
  foo(arr, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a8(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
jle    117e <main+0x5e>
mov    -0x1ac(%rbp),%ecx
mov    -0x1a8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1a8(%rbp)
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    113c <main+0x1c>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <foo@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
xor    %ebx,%ebx
test   %rax,%rax
jle    116c <main+0x4c>
lea    0xeb5(%rip),%r14
lea    0xc(%rsp),%r15
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
jg     1150 <main+0x30>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1030 <foo@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %9, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %13
store i32 %10, i32* %14
br label %6
15: ; preds = %6
%16 = load i32, i32* %4
store i32 %16, i32* %3
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %3
%19 = call i32 @foo(i32* %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %0, %7
%8 = phi i64 [ %10, %7 ], [ 0, %0 ]
%9 = load i32, i32* %2
%10 = add nuw i64 %8, 1
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %8
store i32 %9, i32* %11
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %7
%15 = trunc i64 %10 to i32
br label %16
16: ; preds = %14, %0
%17 = phi i32 [ 0, %0 ], [ %15, %14 ]
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%19 = call i32 @foo(i32* %18, i32 %17)
ret i32 0
}