#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*/ GL_COMPILE;
int /*<<< orphan*/ GL_POINTS;
int M_PI;
double cos(double);
scalar_t__ gen_rand_float(double, double);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glEndList();
int /*<<< orphan*/ glNewList(int, int /*<<< orphan*/);
int /*<<< orphan*/ glPointSize(int);
int /*<<< orphan*/ glVertex3f(scalar_t__, scalar_t__, scalar_t__);
double sin(double);
void gen_rand_explosion_particles(int ps, int ts, double pert, int dl) {
  double phi, theta;
  int p_slices = ps;
  int t_slices = ts;
  double delta_p = M_PI / p_slices;
  double delta_t = 2 * M_PI / t_slices;
  int rows = p_slices - 1;
  int cols = t_slices;
  int i, j;
  double q = pert;
  glNewList(dl, GL_COMPILE);
  glPointSize(1);
  glBegin(GL_POINTS);
  for (i = 0, phi = delta_p; i < rows; phi += delta_p, ++i) {
    double sinphi = sin(phi), cosphi = cos(phi);
    for (j = 0, theta = 0; j < cols; theta += delta_t, ++j)
      glVertex3f(cos(theta) * sinphi + gen_rand_float(-q, q),
                 sin(theta) * sinphi + gen_rand_float(-q, q),
                 cosphi + gen_rand_float(-q, q));
  }
  glEnd();
  glEndList();
  return;
}


x86 assembly (clang, -O0):
<gen_rand_explosion_particles>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
cltd
idivl  -0x2c(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cltd
idivl  -0x30(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
call   1050 <glNewList@plt>
mov    $0x1,%edi
call   1080 <glPointSize@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   10a0 <glBegin@plt>
movl   $0x0,-0x4c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    13e1 <gen_rand_explosion_particles+0x251>
movsd  -0x20(%rbp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1090 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    13bf <gen_rand_explosion_particles+0x22f>
movsd  -0x28(%rbp),%xmm0
call   1090 <cos@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <gen_rand_float@plt>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm2
ff
cvtsi2sd %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <gen_rand_float@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm2
ff
cvtsi2sd %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <gen_rand_float@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdx
call   1040 <glVertex3f@plt>
movsd  -0x40(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1270 <gen_rand_explosion_particles+0xe0>
jmp    13c4 <gen_rand_explosion_particles+0x234>
movsd  -0x38(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1237 <gen_rand_explosion_particles+0xa7>
mov    $0x0,%al
call   1060 <glEnd@plt>
mov    $0x0,%al
call   10b0 <glEndList@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_rand_explosion_particles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,%ecx
movapd %xmm0,0x20(%rsp)
mov    %esi,%r13d
mov    %edi,%r12d
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    %esi,%eax
cltd
idiv   %edi
mov    %eax,%r14d
add    %esi,%esi
mov    %esi,%eax
cltd
idiv   %r13d
mov    %eax,%r15d
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
mov    %ecx,%edi
call   1050 <glNewList@plt>
mov    $0x1,%edi
call   1080 <glPointSize@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   10a0 <glBegin@plt>
cmp    $0x2,%r12d
jl     1341 <gen_rand_explosion_particles+0x1b1>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
cvtsi2sd %r15d,%xmm1
movsd  %xmm1,0x48(%rsp)
add    $0xffffffff,%r12d
movapd 0xde7(%rip),%xmm1
xorpd  0x20(%rsp),%xmm1
movapd %xmm1,0x30(%rsp)
xor    %r14d,%r14d
movsd  %xmm0,0x40(%rsp)
jmp    1249 <gen_rand_explosion_particles+0xb9>
movsd  0x8(%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
add    $0x1,%r14d
cmp    %r12d,%r14d
je     1341 <gen_rand_explosion_particles+0x1b1>
movsd  %xmm0,0x8(%rsp)
call   1070 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1090 <cos@plt>
movsd  %xmm0,0x50(%rsp)
test   %r13d,%r13d
jle    1230 <gen_rand_explosion_particles+0xa0>
xorpd  %xmm0,%xmm0
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
call   1090 <cos@plt>
movsd  %xmm0,(%rsp)
movaps 0x30(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
call   1030 <gen_rand_float@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r15
movsd  0x18(%rsp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,(%rsp)
movaps 0x30(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
call   1030 <gen_rand_float@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rbx
movaps 0x30(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
call   1030 <gen_rand_float@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x50(%rsp),%xmm0
cvttsd2si %xmm0,%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <glVertex3f@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
addsd  %xmm1,%xmm0
add    $0xffffffff,%ebp
jne    1280 <gen_rand_explosion_particles+0xf0>
jmp    1230 <gen_rand_explosion_particles+0xa0>
xor    %eax,%eax
call   1060 <glEnd@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <glEndList@plt>

LLVM IR (-O0):
@M_PI = global i32 0
@GL_COMPILE = global i32 0
@GL_POINTS = global i32 0
define void @gen_rand_explosion_particles(i32 %0, i32 %1, double %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 %3, i32* %8
%22 = load i32, i32* %5
store i32 %22, i32* %11
%23 = load i32, i32* %6
store i32 %23, i32* %12
%24 = load i32, i32* @M_PI
%25 = load i32, i32* %11
%26 = sdiv i32 %24, %25
%27 = sitofp i32 %26 to double
store double %27, double* %13
%28 = load i32, i32* @M_PI
%29 = mul nsw i32 2, %28
%30 = load i32, i32* %12
%31 = sdiv i32 %29, %30
%32 = sitofp i32 %31 to double
store double %32, double* %14
%33 = load i32, i32* %11
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %15
%35 = load i32, i32* %12
store i32 %35, i32* %16
%36 = load double, double* %7
store double %36, double* %19
%37 = load i32, i32* %8
%38 = load i32, i32* @GL_COMPILE
%39 = call i32 @glNewList(i32 %37, i32 %38)
%40 = call i32 @glPointSize(i32 1)
%41 = load i32, i32* @GL_POINTS
%42 = call i32 @glBegin(i32 %41)
store i32 0, i32* %17
%43 = load double, double* %13
store double %43, double* %9
br label %44
44: ; preds = %94, %4
%45 = load i32, i32* %17
%46 = load i32, i32* %15
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %100
48: ; preds = %44
%49 = load double, double* %9
%50 = call double @sin(double %49)
store double %50, double* %20
%51 = load double, double* %9
%52 = call double @cos(double %51)
store double %52, double* %21
store i32 0, i32* %18
store double 0.000000e+00, double* %10
br label %53
53: ; preds = %87, %48
%54 = load i32, i32* %18
%55 = load i32, i32* %16
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %93
57: ; preds = %53
%58 = load double, double* %10
%59 = call double @cos(double %58)
%60 = load double, double* %20
%61 = load double, double* %19
%62 = fneg double %61
%63 = load double, double* %19
%64 = call i64 @gen_rand_float(double %62, double %63)
%65 = sitofp i64 %64 to double
%66 = call double @llvm.fmuladd.f64(double %59, double %60, double %65)
%67 = fptosi double %66 to i64
%68 = load double, double* %10
%69 = call double @sin(double %68)
%70 = load double, double* %20
%71 = load double, double* %19
%72 = fneg double %71
%73 = load double, double* %19
%74 = call i64 @gen_rand_float(double %72, double %73)
%75 = sitofp i64 %74 to double
%76 = call double @llvm.fmuladd.f64(double %69, double %70, double %75)
%77 = fptosi double %76 to i64
%78 = load double, double* %21
%79 = load double, double* %19
%80 = fneg double %79
%81 = load double, double* %19
%82 = call i64 @gen_rand_float(double %80, double %81)
%83 = sitofp i64 %82 to double
%84 = fadd double %78, %83
%85 = fptosi double %84 to i64
%86 = call i32 @glVertex3f(i64 %67, i64 %77, i64 %85)
br label %87
87: ; preds = %57
%88 = load double, double* %14
%89 = load double, double* %10
%90 = fadd double %89, %88
store double %90, double* %10
%91 = load i32, i32* %18
%92 = add nsw i32 %91, 1
store i32 %92, i32* %18
br label %53
93: ; preds = %53
br label %94
94: ; preds = %93
%95 = load double, double* %13
%96 = load double, double* %9
%97 = fadd double %96, %95
store double %97, double* %9
%98 = load i32, i32* %17
%99 = add nsw i32 %98, 1
store i32 %99, i32* %17
br label %44
100: ; preds = %44
%101 = call i32 (...) @glEnd()
%102 = call i32 (...) @glEndList()
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
@GL_COMPILE = global i32 0
@GL_POINTS = global i32 0
define void @gen_rand_explosion_particles(i32 %0, i32 %1, double %2, i32 %3) {
%5 = load i32, i32* @M_PI
%6 = sdiv i32 %5, %0
%7 = sitofp i32 %6 to double
%8 = shl nsw i32 %5, 1
%9 = sdiv i32 %8, %1
%10 = sitofp i32 %9 to double
%11 = add i32 %0, -1
%12 = load i32, i32* @GL_COMPILE
%13 = tail call i32 @glNewList(i32 %3, i32 %12)
%14 = tail call i32 @glPointSize(i32 1)
%15 = load i32, i32* @GL_POINTS
%16 = tail call i32 @glBegin(i32 %15)
%17 = icmp sgt i32 %0, 1
br i1 %17, label %18, label %51
18: ; preds = %4
%19 = icmp sgt i32 %1, 0
%20 = fneg double %2
br label %21
21: ; preds = %18, %47
%22 = phi double [ %7, %18 ], [ %48, %47 ]
%23 = phi i32 [ 0, %18 ], [ %49, %47 ]
%24 = tail call double @sin(double %22)
%25 = tail call double @cos(double %22)
br i1 %19, label %26, label %47
26: ; preds = %21, %26
%27 = phi double [ %44, %26 ], [ 0.000000e+00, %21 ]
%28 = phi i32 [ %45, %26 ], [ 0, %21 ]
%29 = tail call double @cos(double %27)
%30 = tail call i64 @gen_rand_float(double %20, double %2)
%31 = sitofp i64 %30 to double
%32 = tail call double @llvm.fmuladd.f64(double %29, double %24, double %31)
%33 = fptosi double %32 to i64
%34 = tail call double @sin(double %27)
%35 = tail call i64 @gen_rand_float(double %20, double %2)
%36 = sitofp i64 %35 to double
%37 = tail call double @llvm.fmuladd.f64(double %34, double %24, double %36)
%38 = fptosi double %37 to i64
%39 = tail call i64 @gen_rand_float(double %20, double %2)
%40 = sitofp i64 %39 to double
%41 = fadd double %25, %40
%42 = fptosi double %41 to i64
%43 = tail call i32 @glVertex3f(i64 %33, i64 %38, i64 %42)
%44 = fadd double %27, %10
%45 = add nuw nsw i32 %28, 1
%46 = icmp eq i32 %45, %1
br i1 %46, label %47, label %26
47: ; preds = %26, %21
%48 = fadd double %22, %7
%49 = add nuw nsw i32 %23, 1
%50 = icmp eq i32 %49, %11
br i1 %50, label %51, label %21
51: ; preds = %47, %4
%52 = tail call i32 (...) @glEnd()
%53 = tail call i32 (...) @glEndList()
ret void
}