#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ fscanf(void *, char *);
int /*<<< orphan*/ stderr;
int CountList(void *file) {
  int n = 0;
  while (
      fscanf(file,
             "%*s mass, %*g position, %*g, %*g, %*g velocity, %*g, %*g, %*g") !=
      EOF) {
    n++;
  }
  fprintf(stderr, "\nThe number of objects is %d.", n);
  return n;
}


x86 assembly (clang, -O0):
<CountList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     1161 <CountList+0x41>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <CountList+0x13>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xeca(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CountList>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xffffffff,%ebx
lea    0xec9(%rip),%r15
mov    0x2eaa(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fscanf@plt>
add    $0x1,%ebx
cmp    (%r12),%rax
jne    1140 <CountList+0x20>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xeda(%rip),%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [62 x i8] c"%*s mass, %*g position, %*g, %*g, %*g velocity, %*g, %*g, %*g\00"
@EOF = global i64 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"\0AThe number of objects is %d.\00"
define i32 @CountList(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load i8*, i8** %2
%6 = call i64 @fscanf(i8* %5, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
br label %4
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = load i32, i32* %3
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [62 x i8] c"%*s mass, %*g position, %*g, %*g, %*g velocity, %*g, %*g, %*g\00"
@EOF = global i64 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"\0AThe number of objects is %d.\00"
define i32 @CountList(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ 0, %1 ], [ %7, %2 ]
%4 = tail call i64 @fscanf(i8* %0, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
%7 = add nuw nsw i32 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret i32 %3
}