#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*/ diffraction(float *, float *, int, float, float, float **,
                               float **, float **, float **, float **, float **,
                               float *, int *, int, int, int);
float drand48();
int /*<<< orphan*/ srand48(long);
void randdf(float *x, float *z, int nxp, float dx, float dz, float **gridcp,
            float **gridcs, float **gridro, float **cp, float **cs, float **ro,
            float *interface, int *zp, int nx, float sizex, float sizez,
            int ndiff, int diffrwidth, int type) {
  float x0, z0, dsx, dsz;
  int i;
  long lseed;
  lseed = (long)ndiff;
  srand48(lseed);
  x0 = x[0];
  z0 = z[0];
  if (nxp == 2) {
    dsx = x[1] - x0;
    dsz = z[1] - z0;
  } else {
    dsx = sizex - x0;
    dsz = sizez - z0;
  }
  for (i = 0; i < ndiff; i++) {
    nxp = 1;
    type = ((int)((2 * drand48()) > 0.0 ? (2 * drand48()) + 0.5
                                        : (2 * drand48()) - 0.5));
    x[0] = x0 + diffrwidth * dx + drand48() * (dsx - 2 * diffrwidth * dx);
    z[0] = z0 + diffrwidth * dz + drand48() * (dsz - 2 * diffrwidth * dz);
    diffraction(x, z, nxp, dx, dz, gridcp, gridcs, gridro, cp, cs, ro,
                interface, zp, nx, diffrwidth, type);
  }
  return;
}


x86 assembly (clang, -O0):
<randdf>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %edx,-0x3c(%rbp)
movss  %xmm0,-0x40(%rbp)
movss  %xmm1,-0x44(%rbp)
mov    %rcx,-0x50(%rbp)
mov    %r8,-0x58(%rbp)
mov    %r9,-0x60(%rbp)
movss  %xmm2,-0x64(%rbp)
movss  %xmm3,-0x68(%rbp)
movslq 0x40(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
call   1040 <srand48@plt>
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x6c(%rbp)
mov    -0x38(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x70(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jne    11f5 <randdf+0xc5>
mov    -0x30(%rbp),%rax
movss  0x4(%rax),%xmm0
subss  -0x6c(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
mov    -0x38(%rbp),%rax
movss  0x4(%rax),%xmm0
subss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
jmp    1213 <randdf+0xe3>
movss  -0x64(%rbp),%xmm0
subss  -0x6c(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
movss  -0x68(%rbp),%xmm0
subss  -0x70(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    0x40(%rbp),%eax
jge    140b <randdf+0x2db>
movl   $0x1,-0x3c(%rbp)
mov    $0x0,%al
call   1050 <drand48@plt>
movaps %xmm0,%xmm1
movss  0xdc1(%rip),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1287 <randdf+0x157>
mov    $0x0,%al
call   1050 <drand48@plt>
movaps %xmm0,%xmm1
movss  0xd9a(%rip),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd92(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12b5 <randdf+0x185>
mov    $0x0,%al
call   1050 <drand48@plt>
movaps %xmm0,%xmm1
movss  0xd67(%rip),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
mov    %eax,0x50(%rbp)
movss  -0x6c(%rbp),%xmm1
cvtsi2ssl 0x48(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   1050 <drand48@plt>
movss  -0x98(%rbp),%xmm1
ff
movss  -0x74(%rbp),%xmm3
mov    0x48(%rbp),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm2
movss  -0x40(%rbp),%xmm4
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm4,%xmm2
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x70(%rbp),%xmm1
cvtsi2ssl 0x48(%rbp),%xmm0
movss  -0x44(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x94(%rbp)
ff
mov    $0x0,%al
call   1050 <drand48@plt>
movss  -0x94(%rbp),%xmm1
ff
movss  -0x78(%rbp),%xmm3
mov    0x48(%rbp),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm2
movss  -0x44(%rbp),%xmm4
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm4,%xmm2
addss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edx
movss  -0x40(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%r9
mov    0x10(%rbp),%r13
mov    0x18(%rbp),%r12
mov    0x20(%rbp),%r15
mov    0x28(%rbp),%r14
mov    0x30(%rbp),%rbx
mov    0x38(%rbp),%r11d
mov    0x48(%rbp),%r10d
mov    0x50(%rbp),%eax
mov    %r13,(%rsp)
mov    %r12,0x8(%rsp)
mov    %r15,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10d,0x30(%rsp)
mov    %eax,0x38(%rsp)
call   1030 <diffraction@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    121a <randdf+0xea>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<randdf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
mov    %r9,%rbx
mov    %r8,%rbp
mov    %rcx,%r14
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
mov    %edx,0x18(%rsp)
mov    %rsi,%r13
mov    %rdi,%r15
mov    0x90(%rsp),%r12d
movslq %r12d,%rdi
call   1040 <srand48@plt>
cmpl   $0x2,0x18(%rsp)
jne    1198 <randdf+0x68>
movss  0x4(%r15),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x4(%r13),%xmm0
movss  %xmm0,0x8(%rsp)
test   %r12d,%r12d
movss  0xc(%rsp),%xmm2
movss  0x8(%rsp),%xmm4
mov    %r14,0x18(%rsp)
jle    130e <randdf+0x1de>
mov    0x98(%rsp),%eax
movss  (%r15),%xmm0
movss  0x0(%r13),%xmm1
cvtsi2ss %eax,%xmm6
movaps %xmm2,%xmm3
subss  %xmm0,%xmm3
subss  %xmm1,%xmm4
movaps %xmm6,%xmm2
movss  0x10(%rsp),%xmm5
mulss  %xmm5,%xmm2
addss  %xmm0,%xmm2
movss  %xmm2,0x20(%rsp)
lea    (%rax,%rax,1),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps %xmm0,%xmm2
mulss  %xmm5,%xmm2
subss  %xmm2,%xmm3
movss  %xmm3,0xc(%rsp)
movss  0x14(%rsp),%xmm2
mulss  %xmm2,%xmm6
addss  %xmm1,%xmm6
movss  %xmm6,0x24(%rsp)
mulss  %xmm2,%xmm0
subss  %xmm0,%xmm4
movss  %xmm4,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <drand48@plt>
addss  %xmm0,%xmm0
mov    %rbp,%r14
mov    %rbx,%rbp
xor    %ebx,%ebx
ucomiss 0xdc6(%rip),%xmm0
seta   %bl
xor    %eax,%eax
call   1050 <drand48@plt>
addss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9d(%rip),%rax
addsd  (%rax,%rbx,8),%xmm0
mov    %rbp,%rbx
mov    %r14,%rbp
cvttsd2si %xmm0,%r14d
xor    %eax,%eax
call   1050 <drand48@plt>
mulss  0xc(%rsp),%xmm0
addss  0x20(%rsp),%xmm0
movss  %xmm0,(%r15)
xor    %eax,%eax
call   1050 <drand48@plt>
mulss  0x8(%rsp),%xmm0
addss  0x24(%rsp),%xmm0
movss  %xmm0,0x0(%r13)
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
mov    0x18(%rsp),%rcx
mov    %rbp,%r8
mov    %rbx,%r9
push   %r14
mov    0xa0(%rsp),%eax
push   %rax
mov    0x98(%rsp),%eax
push   %rax
push   0x98(%rsp)
push   0x98(%rsp)
push   0x98(%rsp)
push   0x98(%rsp)
push   0x98(%rsp)
call   1030 <diffraction@plt>
add    $0x40,%rsp
add    $0xffffffff,%r12d
jne    1230 <randdf+0x100>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @randdf(float* %0, float* %1, i32 %2, float %3, float %4, float** %5, float** %6, float** %7, float** %8, float** %9, float** %10, float* %11, i32* %12, i32 %13, float %14, float %15, i32 %16, i32 %17, i32 %18) {
%20 = alloca float*
%21 = alloca float*
%22 = alloca i32
%23 = alloca float
%24 = alloca float
%25 = alloca float**
%26 = alloca float**
%27 = alloca float**
%28 = alloca float**
%29 = alloca float**
%30 = alloca float**
%31 = alloca float*
%32 = alloca i32*
%33 = alloca i32
%34 = alloca float
%35 = alloca float
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca float
%40 = alloca float
%41 = alloca float
%42 = alloca float
%43 = alloca i32
%44 = alloca i64
store float* %0, float** %20
store float* %1, float** %21
store i32 %2, i32* %22
store float %3, float* %23
store float %4, float* %24
store float** %5, float*** %25
store float** %6, float*** %26
store float** %7, float*** %27
store float** %8, float*** %28
store float** %9, float*** %29
store float** %10, float*** %30
store float* %11, float** %31
store i32* %12, i32** %32
store i32 %13, i32* %33
store float %14, float* %34
store float %15, float* %35
store i32 %16, i32* %36
store i32 %17, i32* %37
store i32 %18, i32* %38
%45 = load i32, i32* %36
%46 = sext i32 %45 to i64
store i64 %46, i64* %44
%47 = load i64, i64* %44
%48 = call i32 @srand48(i64 %47)
%49 = load float*, float** %20
%50 = getelementptr inbounds float, float* %49, i64 0
%51 = load float, float* %50
store float %51, float* %39
%52 = load float*, float** %21
%53 = getelementptr inbounds float, float* %52, i64 0
%54 = load float, float* %53
store float %54, float* %40
%55 = load i32, i32* %22
%56 = icmp eq i32 %55, 2
br i1 %56, label %57, label %68
57: ; preds = %19
%58 = load float*, float** %20
%59 = getelementptr inbounds float, float* %58, i64 1
%60 = load float, float* %59
%61 = load float, float* %39
%62 = fsub float %60, %61
store float %62, float* %41
%63 = load float*, float** %21
%64 = getelementptr inbounds float, float* %63, i64 1
%65 = load float, float* %64
%66 = load float, float* %40
%67 = fsub float %65, %66
store float %67, float* %42
br label %75
68: ; preds = %19
%69 = load float, float* %34
%70 = load float, float* %39
%71 = fsub float %69, %70
store float %71, float* %41
%72 = load float, float* %35
%73 = load float, float* %40
%74 = fsub float %72, %73
store float %74, float* %42
br label %75
75: ; preds = %68, %57
store i32 0, i32* %43
br label %76
76: ; preds = %147, %75
%77 = load i32, i32* %43
%78 = load i32, i32* %36
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %150
80: ; preds = %76
store i32 1, i32* %22
%81 = call float (...) @drand48()
%82 = fmul float 2.000000e+00, %81
%83 = fpext float %82 to double
%84 = fcmp ogt double %83, 0.000000e+00
br i1 %84, label %85, label %90
85: ; preds = %80
%86 = call float (...) @drand48()
%87 = fmul float 2.000000e+00, %86
%88 = fpext float %87 to double
%89 = fadd double %88, 5.000000e-01
br label %95
90: ; preds = %80
%91 = call float (...) @drand48()
%92 = fmul float 2.000000e+00, %91
%93 = fpext float %92 to double
%94 = fsub double %93, 5.000000e-01
br label %95
95: ; preds = %90, %85
%96 = phi double [ %89, %85 ], [ %94, %90 ]
%97 = fptosi double %96 to i32
store i32 %97, i32* %38
%98 = load float, float* %39
%99 = load i32, i32* %37
%100 = sitofp i32 %99 to float
%101 = load float, float* %23
%102 = call float @llvm.fmuladd.f32(float %100, float %101, float %98)
%103 = call float (...) @drand48()
%104 = load float, float* %41
%105 = load i32, i32* %37
%106 = mul nsw i32 2, %105
%107 = sitofp i32 %106 to float
%108 = load float, float* %23
%109 = fneg float %107
%110 = call float @llvm.fmuladd.f32(float %109, float %108, float %104)
%111 = call float @llvm.fmuladd.f32(float %103, float %110, float %102)
%112 = load float*, float** %20
%113 = getelementptr inbounds float, float* %112, i64 0
store float %111, float* %113
%114 = load float, float* %40
%115 = load i32, i32* %37
%116 = sitofp i32 %115 to float
%117 = load float, float* %24
%118 = call float @llvm.fmuladd.f32(float %116, float %117, float %114)
%119 = call float (...) @drand48()
%120 = load float, float* %42
%121 = load i32, i32* %37
%122 = mul nsw i32 2, %121
%123 = sitofp i32 %122 to float
%124 = load float, float* %24
%125 = fneg float %123
%126 = call float @llvm.fmuladd.f32(float %125, float %124, float %120)
%127 = call float @llvm.fmuladd.f32(float %119, float %126, float %118)
%128 = load float*, float** %21
%129 = getelementptr inbounds float, float* %128, i64 0
store float %127, float* %129
%130 = load float*, float** %20
%131 = load float*, float** %21
%132 = load i32, i32* %22
%133 = load float, float* %23
%134 = load float, float* %24
%135 = load float**, float*** %25
%136 = load float**, float*** %26
%137 = load float**, float*** %27
%138 = load float**, float*** %28
%139 = load float**, float*** %29
%140 = load float**, float*** %30
%141 = load float*, float** %31
%142 = load i32*, i32** %32
%143 = load i32, i32* %33
%144 = load i32, i32* %37
%145 = load i32, i32* %38
%146 = call i32 @diffraction(float* %130, float* %131, i32 %132, float %133, float %134, float** %135, float** %136, float** %137, float** %138, float** %139, float** %140, float* %141, i32* %142, i32 %143, i32 %144, i32 %145)
br label %147
147: ; preds = %95
%148 = load i32, i32* %43
%149 = add nsw i32 %148, 1
store i32 %149, i32* %43
br label %76
150: ; preds = %76
ret void
}

LLVM IR (-O2):
define void @randdf(float* %0, float* %1, i32 %2, float %3, float %4, float** %5, float** %6, float** %7, float** %8, float** %9, float** %10, float* %11, i32* %12, i32 %13, float %14, float %15, i32 %16, i32 %17, i32 %18) {
%20 = sext i32 %16 to i64
%21 = tail call i32 @srand48(i64 %20)
%22 = load float, float* %0
%23 = load float, float* %1
%24 = icmp eq i32 %2, 2
br i1 %24, label %25, label %30
25: ; preds = %19
%26 = getelementptr inbounds float, float* %0, i64 1
%27 = load float, float* %26
%28 = getelementptr inbounds float, float* %1, i64 1
%29 = load float, float* %28
br label %30
30: ; preds = %19, %25
%31 = phi float [ %27, %25 ], [ %14, %19 ]
%32 = phi float [ %29, %25 ], [ %15, %19 ]
%33 = icmp sgt i32 %16, 0
br i1 %33, label %34, label %63
34: ; preds = %30
%35 = fsub float %31, %22
%36 = fsub float %32, %23
%37 = sitofp i32 %17 to float
%38 = tail call float @llvm.fmuladd.f32(float %37, float %3, float %22)
%39 = shl nsw i32 %17, 1
%40 = sitofp i32 %39 to float
%41 = fneg float %40
%42 = tail call float @llvm.fmuladd.f32(float %41, float %3, float %35)
%43 = tail call float @llvm.fmuladd.f32(float %37, float %4, float %23)
%44 = tail call float @llvm.fmuladd.f32(float %41, float %4, float %36)
br label %45
45: ; preds = %34, %45
%46 = phi i32 [ 0, %34 ], [ %61, %45 ]
%47 = tail call float (...) @drand48()
%48 = fmul float %47, 2.000000e+00
%49 = fcmp ogt float %48, 0.000000e+00
%50 = tail call float (...) @drand48()
%51 = fmul float %50, 2.000000e+00
%52 = fpext float %51 to double
%53 = select i1 %49, double 5.000000e-01, double -5.000000e-01
%54 = fadd double %53, %52
%55 = fptosi double %54 to i32
%56 = tail call float (...) @drand48()
%57 = tail call float @llvm.fmuladd.f32(float %56, float %42, float %38)
store float %57, float* %0
%58 = tail call float (...) @drand48()
%59 = tail call float @llvm.fmuladd.f32(float %58, float %44, float %43)
store float %59, float* %1
%60 = tail call i32 @diffraction(float* %0, float* %1, i32 1, float %3, float %4, float** %5, float** %6, float** %7, float** %8, float** %9, float** %10, float* %11, i32* %12, i32 %13, i32 %17, i32 %55)
%61 = add nuw nsw i32 %46, 1
%62 = icmp eq i32 %61, %16
br i1 %62, label %63, label %45
63: ; preds = %45, %30
ret void
}