// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/utils.c
// Function: calcBounds
void calcBounds(struct Triangle *triangles,int trianglesNum,
                struct Sphere *spheres,int spheresNum,
                float *minBound,float *maxBound,
                struct BoundingBox *bounds) {
  int i,j;

  //triangle bounds
  for(i=0;i<trianglesNum;i++) {
    triangleBoundingBox(triangles[i].pt0,
                        triangles[i].pt1,
                        triangles[i].pt2,
                        bounds[i].start,
                        bounds[i].end);
  }

  //sphere bounds
  for(i=0;i<spheresNum;i++) {
    sphereBoundingBox(spheres[i].pos,spheres[i].radius,
                      bounds[trianglesNum+i].start,
                      bounds[trianglesNum+i].end);
  }

  //insert primitives here

  //min,max bounds
  if(trianglesNum+spheresNum > 0) {
    for(i=0;i<3;i++) {
      minBound[i]=bounds[0].start[i];
      maxBound[i]=bounds[0].end[i];

      for(j=1;j<trianglesNum+spheresNum;j++) {
        if(bounds[j].start[i] < minBound[i]) {
          minBound[i]=bounds[j].start[i];
        }

        if(bounds[j].end[i] > maxBound[i]) {
          maxBound[i]=bounds[j].end[i];
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4229cc
movq -0x8(%rbp), %rdi
movslq -0x34(%rbp), %rax
imulq $0x74, %rax, %rax
addq %rax, %rdi
addq $0x1c, %rdi
movq -0x8(%rbp), %rsi
movslq -0x34(%rbp), %rax
imulq $0x74, %rax, %rax
addq %rax, %rsi
addq $0x28, %rsi
movq -0x8(%rbp), %rdx
movslq -0x34(%rbp), %rax
imulq $0x74, %rax, %rax
addq %rax, %rdx
addq $0x34, %rdx
movq 0x10(%rbp), %rcx
movslq -0x34(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq 0x10(%rbp), %r8
movslq -0x34(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %r8
addq $0xc, %r8
callq 0x40ea80
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x422959
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x422a3c
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rax
imulq $0x2c, %rax, %rax
addq %rax, %rdi
addq $0x1c, %rdi
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x2c, %rcx, %rcx
addq %rcx, %rax
movss 0x28(%rax), %xmm0
movq 0x10(%rbp), %rsi
movl -0xc(%rbp), %eax
addl -0x34(%rbp), %eax
cltq
imulq $0x18, %rax, %rax
addq %rax, %rsi
movq 0x10(%rbp), %rdx
movl -0xc(%rbp), %eax
addl -0x34(%rbp), %eax
cltq
imulq $0x18, %rax, %rax
addq %rax, %rdx
addq $0xc, %rdx
callq 0x40ebf0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4229d3
movl -0xc(%rbp), %eax
addl -0x1c(%rbp), %eax
cmpl $0x0, %eax
jle 0x422b67
movl $0x0, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jge 0x422b65
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0xc(%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl -0xc(%rbp), %ecx
addl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x422b55
movq 0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x422af8
movq 0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movss 0xc(%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x422b45
movq 0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movss 0xc(%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x422b47
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x422a98
jmp 0x422b57
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x422a52
jmp 0x422b67
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)