#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 */
int /*<<< orphan*/ free(double *);
double genrand_real1();
int getx(double *, double *, double *, int **, int, int);
scalar_t__ malloc(int);
void PerturbLambda(double *lambda, double PerturbScale, double *G, int **AT,
                   int numSS, int numTotal) {
  int i;
  double *dummyx;
  double *newlambda;
  int xOK;
  dummyx = (double *)malloc(numTotal * sizeof(double));
  newlambda = (double *)malloc(numSS * sizeof(double));
  xOK = 0;
  while (xOK == 0) {
    for (i = 0; i < numSS; i++) {
      newlambda[i] = lambda[i] + PerturbScale * 2.0 * (genrand_real1() - 0.5);
    }
    xOK = getx(dummyx, newlambda, G, AT, numSS, numTotal);
    PerturbScale /= 2.0;
  }
  for (i = 0; i < numSS; i++) {
    lambda[i] = newlambda[i];
  }
  free(dummyx);
  free(newlambda);
}


x86 assembly (clang, -O0):
<PerturbLambda>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    124c <PerturbLambda+0x10c>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1211 <PerturbLambda+0xd1>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe3c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1060 <genrand_real1@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119e <PerturbLambda+0x5e>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1040 <getx@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    118d <PerturbLambda+0x4d>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1287 <PerturbLambda+0x147>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1253 <PerturbLambda+0x113>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PerturbLambda>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%r13d
mov    %ecx,%r12d
mov    %rdx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%r15
lea    0x0(,%r13,8),%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0x0(,%r12,8),%edi
call   1050 <malloc@plt>
movsd  0x10(%rsp),%xmm0
mov    %rax,%rbx
mov    %r12d,%ebp
jmp    11d3 <PerturbLambda+0x93>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    %r12d,%r8d
mov    %r13d,%r9d
call   1040 <getx@plt>
test   %eax,%eax
jne    13c6 <PerturbLambda+0x286>
movsd  0x10(%rsp),%xmm0
mulsd  0xe35(%rip),%xmm0
test   %r12d,%r12d
movsd  %xmm0,0x10(%rsp)
jle    11a0 <PerturbLambda+0x60>
addsd  %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%r14,8),%xmm0
movsd  %xmm0,0x30(%rsp)
xor    %eax,%eax
call   1060 <genrand_real1@plt>
addsd  0xdf5(%rip),%xmm0
mulsd  0x28(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbp
jne    11f0 <PerturbLambda+0xb0>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    %r12d,%r8d
mov    %r13d,%r9d
call   1040 <getx@plt>
test   %eax,%eax
je     11c5 <PerturbLambda+0x85>
test   %r12d,%r12d
jle    13c6 <PerturbLambda+0x286>
cmp    $0x4,%r12d
jb     1274 <PerturbLambda+0x134>
lea    (%rbx,%rbp,8),%rax
cmp    %r15,%rax
jbe    12f0 <PerturbLambda+0x1b0>
lea    (%r15,%rbp,8),%rax
cmp    %rax,%rbx
jae    12f0 <PerturbLambda+0x1b0>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %rbp,%rcx
mov    %rbp,%rdx
and    $0x3,%rdx
je     12a5 <PerturbLambda+0x165>
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1290 <PerturbLambda+0x150>
cmp    $0x3,%rcx
jb     13c6 <PerturbLambda+0x286>
nop
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%r15,%rax,8)
movsd  0x8(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%r15,%rax,8)
movsd  0x10(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x10(%r15,%rax,8)
movsd  0x18(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x18(%r15,%rax,8)
add    $0x4,%rax
cmp    %rax,%rbp
jne    12b0 <PerturbLambda+0x170>
jmp    13c6 <PerturbLambda+0x286>
mov    %ebp,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rsi
mov    %rsi,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0xc,%rsi
jae    1313 <PerturbLambda+0x1d3>
xor    %esi,%esi
jmp    1382 <PerturbLambda+0x242>
and    $0xfffffffffffffffc,%rdx
xor    %esi,%esi
nopl   0x0(%rax)
movups (%rbx,%rsi,8),%xmm0
movups 0x10(%rbx,%rsi,8),%xmm1
movups %xmm0,(%r15,%rsi,8)
movups %xmm1,0x10(%r15,%rsi,8)
movups 0x20(%rbx,%rsi,8),%xmm0
movups 0x30(%rbx,%rsi,8),%xmm1
movups %xmm0,0x20(%r15,%rsi,8)
movups %xmm1,0x30(%r15,%rsi,8)
movups 0x40(%rbx,%rsi,8),%xmm0
movups 0x50(%rbx,%rsi,8),%xmm1
movups %xmm0,0x40(%r15,%rsi,8)
movups %xmm1,0x50(%r15,%rsi,8)
movupd 0x60(%rbx,%rsi,8),%xmm0
movups 0x70(%rbx,%rsi,8),%xmm1
movupd %xmm0,0x60(%r15,%rsi,8)
movups %xmm1,0x70(%r15,%rsi,8)
add    $0x10,%rsi
add    $0xfffffffffffffffc,%rdx
jne    1320 <PerturbLambda+0x1e0>
test   %rcx,%rcx
je     13bd <PerturbLambda+0x27d>
lea    (%r15,%rsi,8),%rdx
add    $0x10,%rdx
lea    (%rbx,%rsi,8),%rsi
add    $0x10,%rsi
shl    $0x5,%rcx
xor    %edi,%edi
nopl   (%rax)
movupd -0x10(%rsi,%rdi,1),%xmm0
movups (%rsi,%rdi,1),%xmm1
movupd %xmm0,-0x10(%rdx,%rdi,1)
movups %xmm1,(%rdx,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rcx
jne    13a0 <PerturbLambda+0x260>
cmp    %rbp,%rax
jne    1276 <PerturbLambda+0x136>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @PerturbLambda(double* %0, double %1, double* %2, i32** %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca double
%9 = alloca double*
%10 = alloca i32**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
store double* %0, double** %7
store double %1, double* %8
store double* %2, double** %9
store i32** %3, i32*** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%17 = load i32, i32* %12
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to double*
store double* %22, double** %14
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
store double* %28, double** %15
store i32 0, i32* %16
br label %29
29: ; preds = %55, %6
%30 = load i32, i32* %16
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %65
32: ; preds = %29
store i32 0, i32* %13
br label %33
33: ; preds = %52, %32
%34 = load i32, i32* %13
%35 = load i32, i32* %11
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load double*, double** %7
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double, double* %8
%44 = fmul double %43, 2.000000e+00
%45 = call double (...) @genrand_real1()
%46 = fsub double %45, 5.000000e-01
%47 = call double @llvm.fmuladd.f64(double %44, double %46, double %42)
%48 = load double*, double** %15
%49 = load i32, i32* %13
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
br label %52
52: ; preds = %37
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
store i32 %54, i32* %13
br label %33
55: ; preds = %33
%56 = load double*, double** %14
%57 = load double*, double** %15
%58 = load double*, double** %9
%59 = load i32**, i32*** %10
%60 = load i32, i32* %11
%61 = load i32, i32* %12
%62 = call i32 @getx(double* %56, double* %57, double* %58, i32** %59, i32 %60, i32 %61)
store i32 %62, i32* %16
%63 = load double, double* %8
%64 = fdiv double %63, 2.000000e+00
store double %64, double* %8
br label %29
65: ; preds = %29
store i32 0, i32* %13
br label %66
66: ; preds = %80, %65
%67 = load i32, i32* %13
%68 = load i32, i32* %11
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %83
70: ; preds = %66
%71 = load double*, double** %15
%72 = load i32, i32* %13
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = load double*, double** %7
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
store double %75, double* %79
br label %80
80: ; preds = %70
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 1
store i32 %82, i32* %13
br label %66
83: ; preds = %66
%84 = load double*, double** %14
%85 = call i32 @free(double* %84)
%86 = load double*, double** %15
%87 = call i32 @free(double* %86)
ret void
}

LLVM IR (-O2):
define void @PerturbLambda(double* nocapture %0, double %1, double* %2, i32** %3, i32 %4, i32 %5) {
%7 = shl i32 %5, 3
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = shl i32 %4, 3
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double*
%13 = inttoptr i64 %11 to i8*
%14 = icmp sgt i32 %4, 0
%15 = zext i32 %4 to i64
br label %16
16: ; preds = %141, %6
%17 = phi double [ %1, %6 ], [ %142, %141 ]
br i1 %14, label %18, label %143
18: ; preds = %16
%19 = fmul double %17, 2.000000e+00
br label %128
20: ; preds = %138
br i1 %14, label %21, label %165
21: ; preds = %20
%22 = zext i32 %4 to i64
%23 = icmp ult i32 %4, 4
br i1 %23, label %110, label %24
24: ; preds = %21
%25 = getelementptr double, double* %0, i64 %15
%26 = bitcast double* %25 to i8*
%27 = getelementptr double, double* %12, i64 %15
%28 = icmp ugt double* %27, %0
%29 = icmp ult i8* %13, %26
%30 = and i1 %28, %29
br i1 %30, label %110, label %31
31: ; preds = %24
%32 = and i64 %15, 4294967292
%33 = add nsw i64 %32, -4
%34 = lshr exact i64 %33, 2
%35 = add nuw nsw i64 %34, 1
%36 = and i64 %35, 3
%37 = icmp ult i64 %33, 12
br i1 %37, label %89, label %38
38: ; preds = %31
%39 = and i64 %35, 9223372036854775804
br label %40
40: ; preds = %40, %38
%41 = phi i64 [ 0, %38 ], [ %86, %40 ]
%42 = phi i64 [ 0, %38 ], [ %87, %40 ]
%43 = getelementptr inbounds double, double* %12, i64 %41
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = getelementptr inbounds double, double* %43, i64 2
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = getelementptr inbounds double, double* %0, i64 %41
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %45, <2 x double>* %50
%51 = getelementptr inbounds double, double* %49, i64 2
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %48, <2 x double>* %52
%53 = or i64 %41, 4
%54 = getelementptr inbounds double, double* %12, i64 %53
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = getelementptr inbounds double, double* %54, i64 2
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %0, i64 %53
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %56, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %59, <2 x double>* %63
%64 = or i64 %41, 8
%65 = getelementptr inbounds double, double* %12, i64 %64
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = getelementptr inbounds double, double* %65, i64 2
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = getelementptr inbounds double, double* %0, i64 %64
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %67, <2 x double>* %72
%73 = getelementptr inbounds double, double* %71, i64 2
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %70, <2 x double>* %74
%75 = or i64 %41, 12
%76 = getelementptr inbounds double, double* %12, i64 %75
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = getelementptr inbounds double, double* %76, i64 2
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %0, i64 %75
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %78, <2 x double>* %83
%84 = getelementptr inbounds double, double* %82, i64 2
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %81, <2 x double>* %85
%86 = add nuw i64 %41, 16
%87 = add nuw i64 %42, 4
%88 = icmp eq i64 %87, %39
br i1 %88, label %89, label %40
89: ; preds = %40, %31
%90 = phi i64 [ 0, %31 ], [ %86, %40 ]
%91 = icmp eq i64 %36, 0
br i1 %91, label %108, label %92
92: ; preds = %89, %92
%93 = phi i64 [ %105, %92 ], [ %90, %89 ]
%94 = phi i64 [ %106, %92 ], [ 0, %89 ]
%95 = getelementptr inbounds double, double* %12, i64 %93
%96 = bitcast double* %95 to <2 x double>*
%97 = load <2 x double>, <2 x double>* %96
%98 = getelementptr inbounds double, double* %95, i64 2
%99 = bitcast double* %98 to <2 x double>*
%100 = load <2 x double>, <2 x double>* %99
%101 = getelementptr inbounds double, double* %0, i64 %93
%102 = bitcast double* %101 to <2 x double>*
store <2 x double> %97, <2 x double>* %102
%103 = getelementptr inbounds double, double* %101, i64 2
%104 = bitcast double* %103 to <2 x double>*
store <2 x double> %100, <2 x double>* %104
%105 = add nuw i64 %93, 4
%106 = add i64 %94, 1
%107 = icmp eq i64 %106, %36
br i1 %107, label %108, label %92
108: ; preds = %92, %89
%109 = icmp eq i64 %32, %15
br i1 %109, label %165, label %110
110: ; preds = %24, %21, %108
%111 = phi i64 [ 0, %24 ], [ 0, %21 ], [ %32, %108 ]
%112 = xor i64 %111, -1
%113 = add nsw i64 %112, %15
%114 = and i64 %15, 3
%115 = icmp eq i64 %114, 0
br i1 %115, label %125, label %116
116: ; preds = %110, %116
%117 = phi i64 [ %122, %116 ], [ %111, %110 ]
%118 = phi i64 [ %123, %116 ], [ 0, %110 ]
%119 = getelementptr inbounds double, double* %12, i64 %117
%120 = load double, double* %119
%121 = getelementptr inbounds double, double* %0, i64 %117
store double %120, double* %121
%122 = add nuw nsw i64 %117, 1
%123 = add i64 %118, 1
%124 = icmp eq i64 %123, %114
br i1 %124, label %125, label %116
125: ; preds = %116, %110
%126 = phi i64 [ %111, %110 ], [ %122, %116 ]
%127 = icmp ult i64 %113, 3
br i1 %127, label %165, label %146
128: ; preds = %18, %128
%129 = phi i64 [ 0, %18 ], [ %136, %128 ]
%130 = getelementptr inbounds double, double* %0, i64 %129
%131 = load double, double* %130
%132 = tail call double (...) @genrand_real1()
%133 = fadd double %132, -5.000000e-01
%134 = tail call double @llvm.fmuladd.f64(double %19, double %133, double %131)
%135 = getelementptr inbounds double, double* %12, i64 %129
store double %134, double* %135
%136 = add nuw nsw i64 %129, 1
%137 = icmp eq i64 %136, %15
br i1 %137, label %138, label %128
138: ; preds = %128
%139 = tail call i32 @getx(double* %9, double* %12, double* %2, i32** %3, i32 %4, i32 %5)
%140 = icmp eq i32 %139, 0
br i1 %140, label %141, label %20
141: ; preds = %138, %143
%142 = fmul double %17, 5.000000e-01
br label %16
143: ; preds = %16
%144 = tail call i32 @getx(double* %9, double* %12, double* %2, i32** %3, i32 %4, i32 %5)
%145 = icmp eq i32 %144, 0
br i1 %145, label %141, label %165
146: ; preds = %125, %146
%147 = phi i64 [ %163, %146 ], [ %126, %125 ]
%148 = getelementptr inbounds double, double* %12, i64 %147
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %0, i64 %147
store double %149, double* %150
%151 = add nuw nsw i64 %147, 1
%152 = getelementptr inbounds double, double* %12, i64 %151
%153 = load double, double* %152
%154 = getelementptr inbounds double, double* %0, i64 %151
store double %153, double* %154
%155 = add nuw nsw i64 %147, 2
%156 = getelementptr inbounds double, double* %12, i64 %155
%157 = load double, double* %156
%158 = getelementptr inbounds double, double* %0, i64 %155
store double %157, double* %158
%159 = add nuw nsw i64 %147, 3
%160 = getelementptr inbounds double, double* %12, i64 %159
%161 = load double, double* %160
%162 = getelementptr inbounds double, double* %0, i64 %159
store double %161, double* %162
%163 = add nuw nsw i64 %147, 4
%164 = icmp eq i64 %163, %22
br i1 %164, label %165, label %146
165: ; preds = %143, %125, %146, %108, %20
%166 = tail call i32 @free(double* %9)
%167 = tail call i32 @free(double* %12)
ret void
}