#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*/ HECMW_vis_print_exit(char *);
int /*<<< orphan*/ find_next_cell(int *, int *, int *, double *, int *);
int find_out_point(double *, double *, int *, double *, double *, int *,
                   double *);
int find_next_point(double orig_xyz[3], double r_dxyz[3], int r_level[3],
                    int current_ijk[3], double in_point[3], double out_point[3],
                    double ray_direction[3], int next_ijk[3]) {
  int flag, face_sect[3];
  flag = 1;
  flag = find_out_point(orig_xyz, r_dxyz, current_ijk, in_point, ray_direction,
                        face_sect, out_point);
  if (flag == 0)
    HECMW_vis_print_exit(
        "ERROR: HEC-MW-VIS-E2007:There is some problem in finding intersection "
        "point");
  if (flag == 1) {
    find_next_cell(r_level, current_ijk, face_sect, ray_direction, next_ijk);
    if ((next_ijk[0] < 0) || (next_ijk[0] > r_level[0] - 1) ||
        (next_ijk[1] < 0) || (next_ijk[1] > r_level[1] - 1) ||
        (next_ijk[2] < 0) || (next_ijk[2] > r_level[2] - 1))
      flag = -1;
  }
  return (flag);
}


x86 assembly (clang, -O0):
<find_next_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8
lea    -0x40(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <find_out_point@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    119d <find_next_point+0x6d>
lea    0xe68(%rip),%rdi
call   1040 <HECMW_vis_print_exit@plt>
cmpl   $0x1,-0x34(%rbp)
jne    123e <find_next_point+0x10e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    0x10(%rbp),%rcx
mov    0x18(%rbp),%r8
call   1050 <find_next_cell@plt>
mov    0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jl     1232 <find_next_point+0x102>
mov    0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1232 <find_next_point+0x102>
mov    0x18(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jl     1232 <find_next_point+0x102>
mov    0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x18(%rbp),%rcx
mov    0x4(%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1232 <find_next_point+0x102>
mov    0x18(%rbp),%rax
cmpl   $0x0,0x8(%rax)
jl     1232 <find_next_point+0x102>
mov    0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    -0x18(%rbp),%rcx
mov    0x8(%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1239 <find_next_point+0x109>
movl   $0xffffffff,-0x34(%rbp)
jmp    123e <find_next_point+0x10e>
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_next_point>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    0x40(%rsp),%r12
mov    %r9,(%rsp)
lea    0xc(%rsp),%r9
mov    %rcx,%rdx
mov    %r8,%rcx
mov    %r12,%r8
call   1030 <find_out_point@plt>
cmp    $0x1,%eax
je     1176 <find_next_point+0x46>
test   %eax,%eax
jne    11c3 <find_next_point+0x93>
lea    0xe93(%rip),%rdi
call   1040 <HECMW_vis_print_exit@plt>
xor    %eax,%eax
jmp    11c3 <find_next_point+0x93>
mov    0x48(%rsp),%r14
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rcx
mov    %r14,%r8
call   1050 <find_next_cell@plt>
mov    (%r14),%eax
test   %eax,%eax
js     11be <find_next_point+0x8e>
cmp    (%r15),%eax
jge    11be <find_next_point+0x8e>
mov    0x4(%r14),%eax
test   %eax,%eax
js     11be <find_next_point+0x8e>
cmp    0x4(%r15),%eax
jge    11be <find_next_point+0x8e>
mov    0x8(%r14),%ecx
test   %ecx,%ecx
js     11be <find_next_point+0x8e>
mov    $0x1,%eax
cmp    0x8(%r15),%ecx
jl     11c3 <find_next_point+0x93>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [76 x i8] c"ERROR: HEC-MW-VIS-E2007:There is some problem in finding intersection point\00"
define i32 @find_next_point(double* %0, double* %1, i32* %2, i32* %3, double* %4, double* %5, double* %6, i32* %7) {
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca [3 x i32]
store double* %0, double** %9
store double* %1, double** %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store i32* %7, i32** %16
store i32 1, i32* %17
%19 = load double*, double** %9
%20 = load double*, double** %10
%21 = load i32*, i32** %12
%22 = load double*, double** %13
%23 = load double*, double** %15
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 0
%25 = load double*, double** %14
%26 = call i32 @find_out_point(double* %19, double* %20, i32* %21, double* %22, double* %23, i32* %24, double* %25)
store i32 %26, i32* %17
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %8
%30 = call i32 @HECMW_vis_print_exit(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %8
%32 = load i32, i32* %17
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %84
34: ; preds = %31
%35 = load i32*, i32** %11
%36 = load i32*, i32** %12
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 0
%38 = load double*, double** %15
%39 = load i32*, i32** %16
%40 = call i32 @find_next_cell(i32* %35, i32* %36, i32* %37, double* %38, i32* %39)
%41 = load i32*, i32** %16
%42 = getelementptr inbounds i32, i32* %41, i64 0
%43 = load i32, i32* %42
%44 = icmp slt i32 %43, 0
br i1 %44, label %82, label %45
45: ; preds = %34
%46 = load i32*, i32** %16
%47 = getelementptr inbounds i32, i32* %46, i64 0
%48 = load i32, i32* %47
%49 = load i32*, i32** %11
%50 = getelementptr inbounds i32, i32* %49, i64 0
%51 = load i32, i32* %50
%52 = sub nsw i32 %51, 1
%53 = icmp sgt i32 %48, %52
br i1 %53, label %82, label %54
54: ; preds = %45
%55 = load i32*, i32** %16
%56 = getelementptr inbounds i32, i32* %55, i64 1
%57 = load i32, i32* %56
%58 = icmp slt i32 %57, 0
br i1 %58, label %82, label %59
59: ; preds = %54
%60 = load i32*, i32** %16
%61 = getelementptr inbounds i32, i32* %60, i64 1
%62 = load i32, i32* %61
%63 = load i32*, i32** %11
%64 = getelementptr inbounds i32, i32* %63, i64 1
%65 = load i32, i32* %64
%66 = sub nsw i32 %65, 1
%67 = icmp sgt i32 %62, %66
br i1 %67, label %82, label %68
68: ; preds = %59
%69 = load i32*, i32** %16
%70 = getelementptr inbounds i32, i32* %69, i64 2
%71 = load i32, i32* %70
%72 = icmp slt i32 %71, 0
br i1 %72, label %82, label %73
73: ; preds = %68
%74 = load i32*, i32** %16
%75 = getelementptr inbounds i32, i32* %74, i64 2
%76 = load i32, i32* %75
%77 = load i32*, i32** %11
%78 = getelementptr inbounds i32, i32* %77, i64 2
%79 = load i32, i32* %78
%80 = sub nsw i32 %79, 1
%81 = icmp sgt i32 %76, %80
br i1 %81, label %82, label %83
82: ; preds = %73, %68, %59, %54, %45, %34
store i32 -1, i32* %17
br label %83
83: ; preds = %82, %73
br label %84
84: ; preds = %83, %31
%85 = load i32, i32* %17
ret i32 %85
}

LLVM IR (-O2):
@.str = [76 x i8] c"ERROR: HEC-MW-VIS-E2007:There is some problem in finding intersection point\00"
define i32 @find_next_point(double* %0, double* %1, i32* %2, i32* %3, double* %4, double* %5, double* %6, i32* %7) {
%9 = alloca [3 x i32]
%10 = bitcast [3 x i32]* %9 to i8*
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 0
%12 = call i32 @find_out_point(double* %0, double* %1, i32* %3, double* %4, double* %6, i32* %11, double* %5)
switch i32 %12, label %39 [
i32 0, label %13
i32 1, label %15
]
13: ; preds = %8
%14 = call i32 @HECMW_vis_print_exit(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
br label %39
15: ; preds = %8
%16 = call i32 @find_next_cell(i32* %2, i32* %3, i32* %11, double* %6, i32* %7)
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 0
br i1 %18, label %38, label %19
19: ; preds = %15
%20 = load i32, i32* %2
%21 = icmp slt i32 %17, %20
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = getelementptr inbounds i32, i32* %7, i64 1
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %22
%27 = getelementptr inbounds i32, i32* %2, i64 1
%28 = load i32, i32* %27
%29 = icmp slt i32 %24, %28
br i1 %29, label %30, label %38
30: ; preds = %26
%31 = getelementptr inbounds i32, i32* %7, i64 2
%32 = load i32, i32* %31
%33 = icmp slt i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = getelementptr inbounds i32, i32* %2, i64 2
%36 = load i32, i32* %35
%37 = icmp slt i32 %32, %36
br i1 %37, label %39, label %38
38: ; preds = %34, %30, %26, %22, %19, %15
br label %39
39: ; preds = %13, %8, %34, %38
%40 = phi i32 [ -1, %38 ], [ 1, %34 ], [ 0, %13 ], [ %12, %8 ]
ret i32 %40
}