#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 */
typedef int /*<<< orphan*/ mark;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
float strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int read_marks(float marks[], int size) {
  char mark[8];
  int c = 0;
  for (int i = 0; i < size; i++) {
    c += 1;
    printf("mark[%d]: ", i + 1);
    fgets(mark, sizeof(mark), stdin);
    marks[i] = strtol(mark, NULL, 0);
  }
  return c;
}


x86 assembly (clang, -O0):
<read_marks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b5 <read_marks+0x85>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1040 <fgets@plt>
lea    -0x14(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <read_marks+0x1d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_marks>:
test   %esi,%esi
jle    11b0 <read_marks+0x80>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
mov    %esi,0xc(%rsp)
mov    %esi,%r13d
xor    %ebx,%ebx
mov    0x2e93(%rip),%r15
lea    0x10(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r14
lea    0xe95(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
mov    (%r15),%edx
mov    %rbp,%rdi
mov    $0x8,%esi
call   1040 <fgets@plt>
mov    %rbp,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
movss  %xmm0,(%r12,%rbx,4)
mov    %r14,%rbx
cmp    %r14,%r13
jne    1160 <read_marks+0x30>
mov    0xc(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"mark[%d]: \00"
@stdin = global i32 0
define i32 @read_marks(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca [8 x i8]
%6 = alloca i32
%7 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %2
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 1
store i32 %14, i32* %6
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %18, i32 8, i32 %19)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%22 = call float @strtol(i8* %21, i32* null, i32 0)
%23 = load float*, float** %3
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds float, float* %23, i64 %25
store float %22, float* %26
br label %27
27: ; preds = %12
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
@.str = [11 x i8] c"mark[%d]: \00"
@stdin = global i32 0
define i32 @read_marks(float* nocapture writeonly %0, i32 %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %10
8: ; preds = %10, %2
%9 = phi i32 [ 0, %2 ], [ %1, %10 ]
ret i32 %9
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %12, %10 ]
%12 = add nuw nsw i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %4, i32 8, i32 %15)
%17 = call float @strtol(i8* nocapture %4, i32* null, i32 0)
%18 = getelementptr inbounds float, float* %0, i64 %11
store float %17, float* %18
%19 = icmp eq i64 %12, %7
br i1 %19, label %8, label %10
}