#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 */
double exp(double);
int /*<<< orphan*/ movem(double *, double *, int, int);
double pow(double, double);
void gnorm(double *c1, double *c2, int m, const double g) {
  double k;
  if (g != 0.0) {
    k = 1.0 + g * c1[0];
    for (; m >= 1; m--)
      c2[m] = c1[m] / k;
    c2[0] = pow(k, 1.0 / g);
  } else {
    movem(&c1[1], &c2[1], sizeof(*c1), m);
    c2[0] = exp(c1[0]);
  }
  return;
}


x86 assembly (clang, -O0):
<gnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1165 <gnorm+0x35>
jp     1165 <gnorm+0x35>
jmp    11e2 <gnorm+0xb2>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe82(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11be <gnorm+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <gnorm+0x57>
movsd  -0x28(%rbp),%xmm0
movsd  0xe35(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
call   1050 <pow@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1214 <gnorm+0xe4>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x14(%rbp),%ecx
mov    $0x8,%edx
call   1030 <movem@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <exp@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnorm>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ecx
mov    %rsi,%r14
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114c <gnorm+0x1c>
jnp    1272 <gnorm+0x142>
movsd  (%rbx),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xea4(%rip),%xmm2
test   %ecx,%ecx
jle    125b <gnorm+0x12b>
mov    %ecx,%eax
cmp    $0x1,%ecx
je     1230 <gnorm+0x100>
lea    0x8(%r14),%rcx
lea    (%rbx,%rax,8),%rdx
add    $0x8,%rdx
cmp    %rdx,%rcx
jae    1195 <gnorm+0x65>
lea    (%r14,%rax,8),%rcx
add    $0x8,%rcx
lea    0x8(%rbx),%rdx
cmp    %rcx,%rdx
jb     1230 <gnorm+0x100>
mov    %eax,%r8d
and    $0xfffffffe,%r8d
movapd %xmm2,%xmm1
unpcklpd %xmm2,%xmm1
lea    -0x2(%r8),%rcx
mov    %rcx,%r9
shr    %r9
add    $0x1,%r9
shufpd $0x1,%xmm1,%xmm1
test   %rcx,%rcx
je     129a <gnorm+0x16a>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
lea    (%r14,%rax,8),%rcx
add    $0xfffffffffffffff8,%rcx
lea    (%rbx,%rax,8),%rdx
add    $0xfffffffffffffff8,%rdx
xor    %esi,%esi
nopl   0x0(%rax)
movupd (%rdx,%rsi,8),%xmm3
divpd  %xmm1,%xmm3
movupd %xmm3,(%rcx,%rsi,8)
movupd -0x10(%rdx,%rsi,8),%xmm3
divpd  %xmm1,%xmm3
movupd %xmm3,-0x10(%rcx,%rsi,8)
add    $0xfffffffffffffffc,%rsi
add    $0xfffffffffffffffe,%rdi
jne    11e0 <gnorm+0xb0>
neg    %rsi
test   $0x1,%r9b
je     1228 <gnorm+0xf8>
mov    %rax,%rcx
sub    %rsi,%rcx
movupd -0x8(%rbx,%rcx,8),%xmm3
divpd  %xmm1,%xmm3
movupd %xmm3,-0x8(%r14,%rcx,8)
cmp    %rax,%r8
je     125b <gnorm+0x12b>
and    $0x1,%eax
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  -0x8(%rbx,%rax,8),%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,-0x8(%r14,%rax,8)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     1240 <gnorm+0x110>
movsd  0xd9d(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
call   1050 <pow@plt>
jmp    128d <gnorm+0x15d>
lea    0x8(%rbx),%rdi
lea    0x8(%r14),%rsi
mov    $0x8,%edx
call   1030 <movem@plt>
movsd  (%rbx),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %esi,%esi
test   $0x1,%r9b
jne    1211 <gnorm+0xe1>
jmp    1228 <gnorm+0xf8>

LLVM IR (-O0):
define void @gnorm(double* %0, double* %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double %3, double* %8
%10 = load double, double* %8
%11 = fcmp une double %10, 0.000000e+00
br i1 %11, label %12, label %43
12: ; preds = %4
%13 = load double, double* %8
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = call double @llvm.fmuladd.f64(double %13, double %16, double 1.000000e+00)
store double %17, double* %9
br label %18
18: ; preds = %33, %12
%19 = load i32, i32* %7
%20 = icmp sge i32 %19, 1
br i1 %20, label %21, label %36
21: ; preds = %18
%22 = load double*, double** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double, double* %9
%28 = fdiv double %26, %27
%29 = load double*, double** %6
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %7
%35 = add nsw i32 %34, -1
store i32 %35, i32* %7
br label %18
36: ; preds = %18
%37 = load double, double* %9
%38 = load double, double* %8
%39 = fdiv double 1.000000e+00, %38
%40 = call double @pow(double %37, double %39)
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 0
store double %40, double* %42
br label %56
43: ; preds = %4
%44 = load double*, double** %5
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load i32, i32* %7
%49 = call i32 @movem(double* %45, double* %47, i32 8, i32 %48)
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = call double @exp(double %52)
%54 = load double*, double** %6
%55 = getelementptr inbounds double, double* %54, i64 0
store double %53, double* %55
br label %56
56: ; preds = %43, %36
ret void
}

LLVM IR (-O2):
define void @gnorm(double* %0, double* %1, i32 %2, double %3) {
%5 = fcmp une double %3, 0.000000e+00
br i1 %5, label %6, label %93
6: ; preds = %4
%7 = load double, double* %0
%8 = tail call double @llvm.fmuladd.f64(double %3, double %7, double 1.000000e+00)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %90
10: ; preds = %6
%11 = zext i32 %2 to i64
%12 = icmp eq i32 %2, 1
br i1 %12, label %80, label %13
13: ; preds = %10
%14 = getelementptr double, double* %1, i64 1
%15 = add nuw nsw i64 %11, 1
%16 = getelementptr double, double* %1, i64 %15
%17 = getelementptr double, double* %0, i64 1
%18 = getelementptr double, double* %0, i64 %15
%19 = icmp ult double* %14, %18
%20 = icmp ult double* %17, %16
%21 = and i1 %19, %20
br i1 %21, label %80, label %22
22: ; preds = %13
%23 = and i64 %11, 4294967294
%24 = and i64 %11, 1
%25 = insertelement <2 x double> poison, double %8, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = add nsw i64 %23, -2
%28 = lshr exact i64 %27, 1
%29 = add nuw i64 %28, 1
%30 = and i64 %29, 1
%31 = icmp eq i64 %27, 0
br i1 %31, label %63, label %32
32: ; preds = %22
%33 = and i64 %29, -2
%34 = getelementptr inbounds double, double* %0, i64 -1
%35 = getelementptr inbounds double, double* %1, i64 -1
%36 = getelementptr inbounds double, double* %0, i64 -1
%37 = getelementptr inbounds double, double* %1, i64 -1
br label %38
38: ; preds = %38, %32
%39 = phi i64 [ 0, %32 ], [ %60, %38 ]
%40 = phi i64 [ 0, %32 ], [ %61, %38 ]
%41 = sub i64 %11, %39
%42 = getelementptr inbounds double, double* %34, i64 %41
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = shufflevector <2 x double> %44, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%46 = fdiv <2 x double> %45, %26
%47 = shufflevector <2 x double> %46, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%48 = getelementptr inbounds double, double* %35, i64 %41
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %47, <2 x double>* %49
%50 = or i64 %39, 2
%51 = sub i64 %11, %50
%52 = getelementptr inbounds double, double* %36, i64 %51
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%56 = fdiv <2 x double> %55, %26
%57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%58 = getelementptr inbounds double, double* %37, i64 %51
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %57, <2 x double>* %59
%60 = add nuw i64 %39, 4
%61 = add nuw i64 %40, 2
%62 = icmp eq i64 %61, %33
br i1 %62, label %63, label %38
63: ; preds = %38, %22
%64 = phi i64 [ 0, %22 ], [ %60, %38 ]
%65 = icmp eq i64 %30, 0
br i1 %65, label %78, label %66
66: ; preds = %63
%67 = sub i64 %11, %64
%68 = getelementptr inbounds double, double* %0, i64 -1
%69 = getelementptr inbounds double, double* %68, i64 %67
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = shufflevector <2 x double> %71, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%73 = fdiv <2 x double> %72, %26
%74 = getelementptr inbounds double, double* %1, i64 -1
%75 = shufflevector <2 x double> %73, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%76 = getelementptr inbounds double, double* %74, i64 %67
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> %75, <2 x double>* %77
br label %78
78: ; preds = %63, %66
%79 = icmp eq i64 %23, %11
br i1 %79, label %90, label %80
80: ; preds = %13, %10, %78
%81 = phi i64 [ %11, %13 ], [ %11, %10 ], [ %24, %78 ]
br label %82
82: ; preds = %80, %82
%83 = phi i64 [ %88, %82 ], [ %81, %80 ]
%84 = getelementptr inbounds double, double* %0, i64 %83
%85 = load double, double* %84
%86 = fdiv double %85, %8
%87 = getelementptr inbounds double, double* %1, i64 %83
store double %86, double* %87
%88 = add nsw i64 %83, -1
%89 = icmp ugt i64 %83, 1
br i1 %89, label %82, label %90
90: ; preds = %82, %78, %6
%91 = fdiv double 1.000000e+00, %3
%92 = tail call double @pow(double %8, double %91)
br label %99
93: ; preds = %4
%94 = getelementptr inbounds double, double* %0, i64 1
%95 = getelementptr inbounds double, double* %1, i64 1
%96 = tail call i32 @movem(double* %94, double* %95, i32 8, i32 %2)
%97 = load double, double* %0
%98 = tail call double @exp(double %97)
br label %99
99: ; preds = %93, %90
%100 = phi double [ %98, %93 ], [ %92, %90 ]
store double %100, double* %1
ret void
}