#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 didot(double *, int *, int);
double exp(double);
int getx(double *x, double *lambda, double *G, int **AT, int numSS,
         int numTotal) {
  int j;
  double logx;
  for (j = 0; j < numTotal; j++) {
    logx = -G[j] + didot(lambda, AT[j], numSS);
    if (logx > 250) {
      return 0;
    }
    x[j] = exp(logx);
  }
  return 1;
}


x86 assembly (clang, -O0):
<getx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    11ed <getx+0xcd>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <didot@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c8 <getx+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <getx+0xd4>
movsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1147 <getx+0x27>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0xc(%rsp)
mov    $0x1,%eax
test   %r9d,%r9d
jle    119b <getx+0x7b>
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r13
mov    %r9d,%r14d
xor    %r15d,%r15d
nop
movsd  0x0(%rbp,%r15,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    (%r12,%r15,8),%rsi
mov    %rbx,%rdi
mov    0xc(%rsp),%edx
call   1040 <didot@plt>
subsd  0x10(%rsp),%xmm0
ucomisd 0xe85(%rip),%xmm0
ja     1199 <getx+0x79>
call   1030 <exp@plt>
movsd  %xmm0,0x0(%r13,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
jne    1150 <getx+0x30>
mov    $0x1,%eax
jmp    119b <getx+0x7b>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getx(double* %0, double* %1, double* %2, i32** %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32**
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
store double* %0, double** %8
store double* %1, double** %9
store double* %2, double** %10
store i32** %3, i32*** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 0, i32* %14
br label %16
16: ; preds = %46, %6
%17 = load i32, i32* %14
%18 = load i32, i32* %13
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %49
20: ; preds = %16
%21 = load double*, double** %10
%22 = load i32, i32* %14
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fneg double %25
%27 = load double*, double** %9
%28 = load i32**, i32*** %11
%29 = load i32, i32* %14
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %28, i64 %30
%32 = load i32*, i32** %31
%33 = load i32, i32* %12
%34 = call double @didot(double* %27, i32* %32, i32 %33)
%35 = fadd double %26, %34
store double %35, double* %15
%36 = load double, double* %15
%37 = fcmp ogt double %36, 2.500000e+02
br i1 %37, label %38, label %39
38: ; preds = %20
store i32 0, i32* %7
br label %50
39: ; preds = %20
%40 = load double, double* %15
%41 = call double @exp(double %40)
%42 = load double*, double** %8
%43 = load i32, i32* %14
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
store double %41, double* %45
br label %46
46: ; preds = %39
%47 = load i32, i32* %14
%48 = add nsw i32 %47, 1
store i32 %48, i32* %14
br label %16
49: ; preds = %16
store i32 1, i32* %7
br label %50
50: ; preds = %49, %38
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
define i32 @getx(double* nocapture writeonly %0, double* %1, double* nocapture %2, i32** nocapture %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %24
8: ; preds = %6
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %8, %19
%11 = phi i64 [ 0, %8 ], [ %22, %19 ]
%12 = getelementptr inbounds double, double* %2, i64 %11
%13 = load double, double* %12
%14 = getelementptr inbounds i32*, i32** %3, i64 %11
%15 = load i32*, i32** %14
%16 = tail call double @didot(double* %1, i32* %15, i32 %4)
%17 = fsub double %16, %13
%18 = fcmp ogt double %17, 2.500000e+02
br i1 %18, label %24, label %19
19: ; preds = %10
%20 = tail call double @exp(double %17)
%21 = getelementptr inbounds double, double* %0, i64 %11
store double %20, double* %21
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %10, %19, %6
%25 = phi i32 [ 1, %6 ], [ 1, %19 ], [ 0, %10 ]
ret i32 %25
}