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

/* Variables and functions */
double _Complex_I;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fscanf(int /*<<< orphan*/ *, char *, double *, double *);
int /*<<< orphan*/ stderr;
void readpoles(int np, complex *pl, FILE *in, int *ierror) {
  int i;
  double rea, ima;
  i = 0;
  while (i < np) {
    if (fscanf(in, "%lf%lf", &rea, &ima) != 2) {
      fprintf(stderr, "Error reading poles of pzfiles\n");
      *ierror = 99;
      return;
    }
    pl[i] = rea + ima * _Complex_I;
    i++;
  }
}


x86 assembly (clang, -O0):
<readpoles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c7 <readpoles+0xa7>
mov    -0x18(%rbp),%rdi
lea    0xeab(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1030 <fscanf@plt>
cmp    $0x2,%eax
je     118f <readpoles+0x6f>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
movl   $0x63,(%rax)
jmp    11c7 <readpoles+0xa7>
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mov    0x2e40(%rip),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <readpoles+0x1e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readpoles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,(%rsp)
test   %edi,%edi
jle    11b1 <readpoles+0x91>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%r14d
xor    %r12d,%r12d
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xea6(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1030 <fscanf@plt>
cmp    $0x2,%eax
jne    1192 <readpoles+0x72>
movsd  0x8(%rsp),%xmm0
mov    0x2e69(%rip),%rax
mulsd  (%rax),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%r12,8)
add    $0x1,%r12
cmp    %r12,%r14
jne    1150 <readpoles+0x30>
jmp    11b1 <readpoles+0x91>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rsp),%rax
movl   $0x63,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%lf%lf\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Error reading poles of pzfiles\0A\00"
@_Complex_I = global double 0.000000e+00
define void @readpoles(i32 %0, double* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %9
br label %12
12: ; preds = %24, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %12
%17 = load i32*, i32** %7
%18 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %10, double* %11)
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32*, i32** %8
store i32 99, i32* %23
br label %35
24: ; preds = %16
%25 = load double, double* %10
%26 = load double, double* %11
%27 = load double, double* @_Complex_I
%28 = call double @llvm.fmuladd.f64(double %26, double %27, double %25)
%29 = load double*, double** %6
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %12
35: ; preds = %20, %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%lf%lf\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"Error reading poles of pzfiles\0A\00"
@_Complex_I = global double 0.000000e+00
define void @readpoles(i32 %0, double* nocapture writeonly %1, i32* nocapture %2, i32* nocapture writeonly %3) {
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %5 to i8*
%8 = bitcast double* %6 to i8*
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %27
10: ; preds = %4
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %19
%13 = phi i64 [ 0, %10 ], [ %25, %19 ]
%14 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %5, double* %6)
%15 = icmp eq i32 %14, 2
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 99, i32* %3
br label %27
19: ; preds = %12
%20 = load double, double* %5
%21 = load double, double* %6
%22 = load double, double* @_Complex_I
%23 = call double @llvm.fmuladd.f64(double %21, double %22, double %20)
%24 = getelementptr inbounds double, double* %1, i64 %13
store double %23, double* %24
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %19, %4, %16
ret void
}