#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 */
float crossVerts(float const *, int, int, int);
bool math_isConvex(float const *verts, int count) {
  int i = count - 2;
  int j = count - 1;
  int k = 0;
  float w = crossVerts(verts, i, j, k);
  while (k + 1 < count) {
    i = j;
    j = k;
    ++k;
    float w2 = crossVerts(verts, i, j, k);
    if (w * w2 < 0.0f) {
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<math_isConvex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <crossVerts@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jge    11b1 <math_isConvex+0xa1>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <crossVerts@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    11ac <math_isConvex+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <math_isConvex+0xa8>
jmp    114f <math_isConvex+0x3f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_isConvex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %rdi,%r14
lea    -0x2(%r12),%esi
lea    -0x1(%r12),%r13d
xor    %ebp,%ebp
mov    %r13d,%edx
xor    %ecx,%ecx
call   1030 <crossVerts@plt>
movss  %xmm0,0x4(%rsp)
cmp    $0x2,%r12d
mov    $0x1,%r15d
cmovl  %r15d,%r12d
mov    $0x1,%ebx
cmp    %ebx,%r12d
je     1181 <math_isConvex+0x71>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebx,%ecx
call   1030 <crossVerts@plt>
mulss  0x4(%rsp),%xmm0
add    $0x1,%ebx
mov    %ebp,%r13d
lea    0x1(%rbp),%eax
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
mov    %eax,%ebp
jbe    1150 <math_isConvex+0x40>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @math_isConvex(float* %0, i32 %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
store float* %0, float** %4
store i32 %1, i32* %5
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 2
store i32 %12, i32* %6
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %7
store i32 0, i32* %8
%15 = load float*, float** %4
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call float @crossVerts(float* %15, i32 %16, i32 %17, i32 %18)
store float %19, float* %9
br label %20
20: ; preds = %40, %2
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %41
25: ; preds = %20
%26 = load i32, i32* %7
store i32 %26, i32* %6
%27 = load i32, i32* %8
store i32 %27, i32* %7
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
%30 = load float*, float** %4
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call float @crossVerts(float* %30, i32 %31, i32 %32, i32 %33)
store float %34, float* %10
%35 = load float, float* %9
%36 = load float, float* %10
%37 = fmul float %35, %36
%38 = fcmp olt float %37, 0.000000e+00
br i1 %38, label %39, label %40
39: ; preds = %25
store i32 0, i32* %3
br label %42
40: ; preds = %25
br label %20
41: ; preds = %20
store i32 1, i32* %3
br label %42
42: ; preds = %41, %39
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @math_isConvex(float* %0, i32 %1) {
%3 = add nsw i32 %1, -2
%4 = add nsw i32 %1, -1
%5 = tail call float @crossVerts(float* %0, i32 %3, i32 %4, i32 0)
%6 = call i32 @llvm.smax.i32(i32 %1, i32 1)
%7 = add nsw i32 %6, -1
br label %8
8: ; preds = %13, %2
%9 = phi i32 [ %4, %2 ], [ %10, %13 ]
%10 = phi i32 [ 0, %2 ], [ %11, %13 ]
%11 = add nuw nsw i32 %10, 1
%12 = icmp eq i32 %10, %7
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call float @crossVerts(float* %0, i32 %9, i32 %10, i32 %11)
%15 = fmul float %5, %14
%16 = fcmp olt float %15, 0.000000e+00
br i1 %16, label %17, label %8
17: ; preds = %8, %13
%18 = phi i32 [ 0, %13 ], [ 1, %8 ]
ret i32 %18
}