#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*/ gzFile;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, ...);
int gzscanf(int /*<<< orphan*/ *, char *, float *, ...);
int /*<<< orphan*/ stderr;
int read_data(gzFile *in, int num_data, float *x) {
  int n = 0;
  int data_read = 0;
  int idata = 0;
  int num_lines, num_last_entries;
  int i;
  assert(3 == 3);
  num_last_entries = num_data % 3;
  num_lines = (num_data - num_last_entries) / 3;
  for (i = 0; i < num_lines; i++) {
    n = gzscanf(in, "%f %f %f \n", &x[idata], &x[idata + 1], &x[idata + 2]);
    idata += 3;
    data_read += n;
    if (n != 3) {
      fprintf(stderr, "ERROR [data line %d]: expected %d but got %d data\n",
              i + 1, 3, n);
    }
  }
  if (num_last_entries == 1) {
    n = gzscanf(in, "%f \n", &x[idata]);
    idata += 1;
  } else if (num_last_entries == 2) {
    n = gzscanf(in, "%f %f \n", &x[idata], &x[idata + 1]);
    idata += 2;
  } else {
    n = 0;
  }
  data_read += n;
  if (n != num_last_entries) {
    fprintf(stderr, "ERROR [data line %d]: expected %d but got %d data\n",
            i + 1, num_last_entries, n);
  }
  assert(idata == num_data);
  if (data_read != num_data) {
    fprintf(stderr, "Expected %d data points but read %d: problem with file.\n",
            num_data, data_read);
    exit(EXIT_FAILURE);
  }
  return data_read;
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x1,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1243 <read_data+0x103>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%r8
mov    -0x24(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%r8
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1050 <gzscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x3,-0x1c(%rbp)
je     1230 <read_data+0xf0>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
add    $0x1,%edx
mov    -0x1c(%rbp),%r8d
lea    0xde7(%rip),%rsi
mov    $0x3,%ecx
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1235 <read_data+0xf5>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1198 <read_data+0x58>
cmpl   $0x1,-0x2c(%rbp)
jne    127f <read_data+0x13f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1050 <gzscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12da <read_data+0x19a>
cmpl   $0x2,-0x2c(%rbp)
jne    12ce <read_data+0x18e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rcx
lea    0xd4d(%rip),%rsi
mov    $0x0,%al
call   1050 <gzscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    12d5 <read_data+0x195>
movl   $0x0,-0x1c(%rbp)
jmp    12da <read_data+0x19a>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1313 <read_data+0x1d3>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
add    $0x1,%edx
mov    -0x2c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     135d <read_data+0x21d>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r12
mov    %esi,%r14d
mov    %rdi,0x10(%rsp)
movl   $0x1,0xc(%rsp)
mov    $0x1,%edi
call   1030 <assert@plt>
movslq %r14d,%rax
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,2),%ecx
mov    %eax,%r15d
sub    %ecx,%r15d
xor    %r8d,%r8d
mov    $0x0,%r13d
mov    $0x0,%ebp
cmp    $0x3,%eax
jl     123f <read_data+0xff>
mov    %r15d,0x18(%rsp)
mov    %r14d,0x1c(%rsp)
xor    %r13d,%r13d
mov    %r12,0x20(%rsp)
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11f6 <read_data+0xb6>
nopl   0x0(%rax,%rax,1)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
add    $0x1,%r15d
lea    0xe37(%rip),%rsi
mov    %r15d,%edx
mov    $0x3,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
add    %r14d,%ebp
add    $0xc,%r12
add    $0x3,%r13d
cmp    %ebx,%r15d
je     1224 <read_data+0xe4>
lea    0x4(%r12),%rcx
lea    0x8(%r12),%r8
mov    0x10(%rsp),%rdi
lea    0xdf4(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <gzscanf@plt>
mov    %eax,%r14d
cmp    $0x3,%eax
jne    11c0 <read_data+0x80>
add    $0x1,%r15d
jmp    11e6 <read_data+0xa6>
add    $0x1,%ebx
mov    %ebx,%eax
mov    %ebx,0xc(%rsp)
mov    0x1c(%rsp),%r14d
mov    0x18(%rsp),%r15d
xor    %r8d,%r8d
mov    0x20(%rsp),%r12
cmp    $0x2,%r15d
je     126e <read_data+0x12e>
cmp    $0x1,%r15d
jne    1297 <read_data+0x157>
mov    %r13d,%eax
lea    (%r12,%rax,4),%rdx
lea    0xdad(%rip),%rsi
mov    0x10(%rsp),%rdi
xor    %eax,%eax
call   1050 <gzscanf@plt>
mov    %eax,%r8d
add    $0x1,%r13d
jmp    1297 <read_data+0x157>
mov    %r13d,%eax
lea    (%r12,%rax,4),%rdx
lea    (%r12,%rax,4),%rcx
add    $0x4,%rcx
lea    0xd7f(%rip),%rsi
mov    0x10(%rsp),%rdi
xor    %eax,%eax
call   1050 <gzscanf@plt>
mov    %eax,%r8d
add    $0x2,%r13d
add    %r8d,%ebp
cmp    %r15d,%r8d
je     12bd <read_data+0x17d>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd5c(%rip),%rsi
mov    0xc(%rsp),%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
cmp    %r14d,%r13d
sete   %dil
call   1030 <assert@plt>
cmp    %r14d,%ebp
jne    12e2 <read_data+0x1a2>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
lea    0xd4c(%rip),%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%f %f %f \0A\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"ERROR [data line %d]: expected %d but got %d data\0A\00"
@.str.2 = [5 x i8] c"%f \0A\00"
@.str.3 = [8 x i8] c"%f %f \0A\00"
@.str.4 = [57 x i8] c"Expected %d data points but read %d: problem with file.\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @read_data(i32* %0, i32 %1, float* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store float* %2, float** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%13 = call i32 @assert(i32 1)
%14 = load i32, i32* %5
%15 = srem i32 %14, 3
store i32 %15, i32* %11
%16 = load i32, i32* %5
%17 = load i32, i32* %11
%18 = sub nsw i32 %16, %17
%19 = sdiv i32 %18, 3
store i32 %19, i32* %10
store i32 0, i32* %12
br label %20
20: ; preds = %55, %3
%21 = load i32, i32* %12
%22 = load i32, i32* %10
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %58
24: ; preds = %20
%25 = load i32*, i32** %4
%26 = load float*, float** %6
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
%30 = load float*, float** %6
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %30, i64 %33
%35 = load float*, float** %6
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float, float* %35, i64 %38
%40 = call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), float* %29, float* %34, float* %39)
store i32 %40, i32* %7
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 3
store i32 %42, i32* %9
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = add nsw i32 %44, %43
store i32 %45, i32* %8
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 3
br i1 %47, label %48, label %54
48: ; preds = %24
%49 = load i32, i32* @stderr
%50 = load i32, i32* %12
%51 = add nsw i32 %50, 1
%52 = load i32, i32* %7
%53 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %51, i32 3, i32 %52)
br label %54
54: ; preds = %48, %24
br label %55
55: ; preds = %54
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
br label %20
58: ; preds = %20
%59 = load i32, i32* %11
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %70
61: ; preds = %58
%62 = load i32*, i32** %4
%63 = load float*, float** %6
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %66)
store i32 %67, i32* %7
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %89
70: ; preds = %58
%71 = load i32, i32* %11
%72 = icmp eq i32 %71, 2
br i1 %72, label %73, label %87
73: ; preds = %70
%74 = load i32*, i32** %4
%75 = load float*, float** %6
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
%79 = load float*, float** %6
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %79, i64 %82
%84 = call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %74, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float* %78, float* %83)
store i32 %84, i32* %7
%85 = load i32, i32* %9
%86 = add nsw i32 %85, 2
store i32 %86, i32* %9
br label %88
87: ; preds = %70
store i32 0, i32* %7
br label %88
88: ; preds = %87, %73
br label %89
89: ; preds = %88, %61
%90 = load i32, i32* %7
%91 = load i32, i32* %8
%92 = add nsw i32 %91, %90
store i32 %92, i32* %8
%93 = load i32, i32* %7
%94 = load i32, i32* %11
%95 = icmp ne i32 %93, %94
br i1 %95, label %96, label %103
96: ; preds = %89
%97 = load i32, i32* @stderr
%98 = load i32, i32* %12
%99 = add nsw i32 %98, 1
%100 = load i32, i32* %11
%101 = load i32, i32* %7
%102 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %99, i32 %100, i32 %101)
br label %103
103: ; preds = %96, %89
%104 = load i32, i32* %9
%105 = load i32, i32* %5
%106 = icmp eq i32 %104, %105
%107 = zext i1 %106 to i32
%108 = call i32 @assert(i32 %107)
%109 = load i32, i32* %8
%110 = load i32, i32* %5
%111 = icmp ne i32 %109, %110
br i1 %111, label %112, label %119
112: ; preds = %103
%113 = load i32, i32* @stderr
%114 = load i32, i32* %5
%115 = load i32, i32* %8
%116 = call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %114, i32 %115)
%117 = load i32, i32* @EXIT_FAILURE
%118 = call i32 @exit(i32 %117)
unreachable
119: ; preds = %103
%120 = load i32, i32* %8
ret i32 %120
}

LLVM IR (-O2):
@.str = [11 x i8] c"%f %f %f \0A\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"ERROR [data line %d]: expected %d but got %d data\0A\00"
@.str.2 = [5 x i8] c"%f \0A\00"
@.str.3 = [8 x i8] c"%f %f \0A\00"
@.str.4 = [57 x i8] c"Expected %d data points but read %d: problem with file.\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @read_data(i32* %0, i32 %1, float* %2) {
%4 = tail call i32 @assert(i32 1)
%5 = srem i32 %1, 3
%6 = sdiv i32 %1, 3
%7 = icmp sgt i32 %1, 2
br i1 %7, label %8, label %33
8: ; preds = %3, %27
%9 = phi i64 [ %18, %27 ], [ 0, %3 ]
%10 = phi i32 [ %28, %27 ], [ 0, %3 ]
%11 = phi i32 [ %19, %27 ], [ 0, %3 ]
%12 = getelementptr inbounds float, float* %2, i64 %9
%13 = add nuw nsw i64 %9, 1
%14 = getelementptr inbounds float, float* %2, i64 %13
%15 = add nuw nsw i64 %9, 2
%16 = getelementptr inbounds float, float* %2, i64 %15
%17 = tail call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), float* %12, float* %14, float* %16)
%18 = add nuw nsw i64 %9, 3
%19 = add nsw i32 %17, %11
%20 = icmp eq i32 %17, 3
br i1 %20, label %21, label %23
21: ; preds = %8
%22 = add nuw nsw i32 %10, 1
br label %27
23: ; preds = %8
%24 = load i32, i32* @stderr
%25 = add nuw nsw i32 %10, 1
%26 = tail call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 3, i32 %17)
br label %27
27: ; preds = %21, %23
%28 = phi i32 [ %22, %21 ], [ %25, %23 ]
%29 = icmp eq i32 %28, %6
br i1 %29, label %30, label %8
30: ; preds = %27
%31 = trunc i64 %18 to i32
%32 = add nsw i32 %6, 1
br label %33
33: ; preds = %30, %3
%34 = phi i32 [ 0, %3 ], [ %31, %30 ]
%35 = phi i32 [ 0, %3 ], [ %19, %30 ]
%36 = phi i32 [ 1, %3 ], [ %32, %30 ]
switch i32 %5, label %50 [
i32 1, label %37
i32 2, label %42
]
37: ; preds = %33
%38 = zext i32 %34 to i64
%39 = getelementptr inbounds float, float* %2, i64 %38
%40 = tail call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %39)
%41 = add nuw nsw i32 %34, 1
br label %50
42: ; preds = %33
%43 = zext i32 %34 to i64
%44 = getelementptr inbounds float, float* %2, i64 %43
%45 = add nuw nsw i32 %34, 1
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds float, float* %2, i64 %46
%48 = tail call i32 (i32*, i8*, float*, ...) @gzscanf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float* %44, float* %47)
%49 = add nuw nsw i32 %34, 2
br label %50
50: ; preds = %33, %42, %37
%51 = phi i32 [ %41, %37 ], [ %49, %42 ], [ %34, %33 ]
%52 = phi i32 [ %40, %37 ], [ %48, %42 ], [ 0, %33 ]
%53 = add nsw i32 %52, %35
%54 = icmp eq i32 %52, %5
br i1 %54, label %58, label %55
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %5, i32 %52)
br label %58
58: ; preds = %55, %50
%59 = icmp eq i32 %51, %1
%60 = zext i1 %59 to i32
%61 = tail call i32 @assert(i32 %60)
%62 = icmp eq i32 %53, %1
br i1 %62, label %68, label %63
63: ; preds = %58
%64 = load i32, i32* @stderr
%65 = tail call i32 (i32, i8*, i32, i32, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %1, i32 %53)
%66 = load i32, i32* @EXIT_FAILURE
%67 = tail call i32 @exit(i32 %66)
unreachable
68: ; preds = %58
ret i32 %1
}