#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 */
double INT_MAX;
int /*<<< orphan*/ fatal_error_i(char *, double);
void check_grid_size(int nx, int ny) {
  int err;
  err = 0;
  if (nx <= 0)
    err = 1;
  if (ny <= 0)
    err = 1;
  if ((double)nx * (double)ny > INT_MAX)
    err = 1;
  if (err == 1)
    fatal_error_i("new_grid: grid size exceeds %d (INT_MAX)", INT_MAX);
}


x86 assembly (clang, -O0):
<check_grid_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1136 <check_grid_size+0x26>
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1147 <check_grid_size+0x37>
movl   $0x1,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e8c(%rip),%rax
ucomisd (%rax),%xmm0
jbe    116d <check_grid_size+0x5d>
movl   $0x1,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    118e <check_grid_size+0x7e>
mov    0x2e6a(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe77(%rip),%rdi
call   1030 <fatal_error_i@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_grid_size>:
mov    0x2ed1(%rip),%rax
movsd  (%rax),%xmm0
test   %edi,%edi
jle    1136 <check_grid_size+0x26>
test   %esi,%esi
jle    1136 <check_grid_size+0x26>
cvtsi2sd %edi,%xmm1
cvtsi2sd %esi,%xmm2
mulsd  %xmm1,%xmm2
ucomisd %xmm0,%xmm2
ja     1136 <check_grid_size+0x26>
ret
lea    0xec3(%rip),%rdi
jmp    1030 <fatal_error_i@plt>

LLVM IR (-O0):
@INT_MAX = global double 0.000000e+00
@.str = [41 x i8] c"new_grid: grid size exceeds %d (INT_MAX)\00"
define void @check_grid_size(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %5
br label %9
9: ; preds = %8, %2
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %5
br label %13
13: ; preds = %12, %9
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = fmul double %15, %17
%19 = load double, double* @INT_MAX
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 1, i32* %5
br label %22
22: ; preds = %21, %13
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load double, double* @INT_MAX
%27 = call i32 @fatal_error_i(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %26)
br label %28
28: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
@INT_MAX = global double 0.000000e+00
@.str = [41 x i8] c"new_grid: grid size exceeds %d (INT_MAX)\00"
define void @check_grid_size(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
%6 = sitofp i32 %0 to double
%7 = sitofp i32 %1 to double
%8 = fmul double %6, %7
%9 = load double, double* @INT_MAX
%10 = fcmp ogt double %8, %9
%11 = or i1 %5, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @fatal_error_i(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %9)
br label %14
14: ; preds = %12, %2
ret void
}