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

/* Variables and functions */
int BUFSIZ;
char fgets(char *, int, int /*<<< orphan*/ *);
int sscanf(char *, char *, double *, double *, double *);
void read(FILE *f, int *pn, double *x, double *y, double *z) {
  int i;
  char s[BUFSIZ];
  for (i = 0;; i++) {
    if (fgets(s, sizeof(s) - 1, f) == '\0')
      break;
    if (sscanf(s, "%lf %lf %lf", &x[i], &y[i], &z[i]) != 3)
      break;
  }
  *pn = i;
}


x86 assembly (clang, -O0):
<read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x50(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
call   1030 <fgets@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    119b <read+0x7b>
jmp    11f9 <read+0xd9>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x28(%rbp),%r8
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r8
lea    0xe2d(%rip),%rsi
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11e6 <read+0xc6>
jmp    11f9 <read+0xd9>
jmp    11eb <read+0xcb>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1173 <read+0x53>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,-0x38(%rbp)
mov    %rdi,%rdx
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
lea    -0x1(%rax),%esi
mov    %r14,%rdi
mov    %esi,-0x2c(%rbp)
mov    %rdx,-0x40(%rbp)
call   1030 <fgets@plt>
xor    %r13d,%r13d
test   %al,%al
je     11c0 <read+0xa0>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xe76(%rip),%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
jne    11c0 <read+0xa0>
add    $0x1,%r13
mov    %r14,%rdi
mov    -0x2c(%rbp),%esi
mov    -0x40(%rbp),%rdx
call   1030 <fgets@plt>
add    $0x8,%r15
add    $0x8,%r12
add    $0x8,%rbx
test   %al,%al
jne    1180 <read+0x60>
mov    -0x38(%rbp),%rax
mov    %r13d,(%rax)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [12 x i8] c"%lf %lf %lf\00"
define void @read(i32* %0, i32* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store i32* %0, i32** %6
store i32* %1, i32** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%14 = load i32, i32* @BUFSIZ
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %12
%17 = alloca i8, i64 %15
store i64 %15, i64* %13
store i32 0, i32* %11
br label %18
18: ; preds = %43, %5
%19 = sub i64 %15, 1
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %6
%22 = call signext i8 @fgets(i8* %17, i32 %20, i32* %21)
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %18
br label %46
26: ; preds = %18
%27 = load double*, double** %8
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double*, double** %9
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double*, double** %10
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double* %30, double* %34, double* %38)
%40 = icmp ne i32 %39, 3
br i1 %40, label %41, label %42
41: ; preds = %26
br label %46
42: ; preds = %26
br label %43
43: ; preds = %42
%44 = load i32, i32* %11
%45 = add nsw i32 %44, 1
store i32 %45, i32* %11
br label %18
46: ; preds = %41, %25
%47 = load i32, i32* %11
%48 = load i32*, i32** %7
store i32 %47, i32* %48
%49 = load i8*, i8** %12
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [12 x i8] c"%lf %lf %lf\00"
define void @read(i32* nocapture %0, i32* nocapture writeonly %1, double* %2, double* %3, double* %4) {
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = add i32 %6, -1
%10 = call signext i8 @fgets(i8* %8, i32 %9, i32* %0)
%11 = icmp eq i8 %10, 0
br i1 %11, label %26, label %12
12: ; preds = %5, %19
%13 = phi i64 [ %20, %19 ], [ 0, %5 ]
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = getelementptr inbounds double, double* %3, i64 %13
%16 = getelementptr inbounds double, double* %4, i64 %13
%17 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double* %14, double* %15, double* %16)
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = add nuw i64 %13, 1
%21 = call signext i8 @fgets(i8* %8, i32 %9, i32* %0)
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %12
23: ; preds = %12, %19
%24 = phi i64 [ %20, %19 ], [ %13, %12 ]
%25 = trunc i64 %24 to i32
br label %26
26: ; preds = %23, %5
%27 = phi i32 [ 0, %5 ], [ %25, %23 ]
store i32 %27, i32* %1
ret void
}