#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 */
size_t SIZE_MAX;
bool valid(size_t n, size_t s) {
  const size_t t = 1ul << (sizeof(size_t) * 4);
  if ((n == 0) || (s == 0))
    return 0;
  if ((n >= t) || (s >= t))
    return ((SIZE_MAX / s) >= n);
  return 1;
}


x86 assembly (clang, -O0):
<valid>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movabs $0x100000000,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1130 <valid+0x30>
cmpq   $0x0,-0x18(%rbp)
jne    113c <valid+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1191 <valid+0x91>
movabs $0x100000000,%rax
cmp    %rax,-0x10(%rbp)
jae    1164 <valid+0x64>
movabs $0x100000000,%rax
cmp    %rax,-0x18(%rbp)
jb     118a <valid+0x8a>
mov    0x2e6d(%rip),%rax
mov    (%rax),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    -0x10(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1191 <valid+0x91>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid>:
xor    %eax,%eax
test   %rdi,%rdi
je     114b <valid+0x4b>
test   %rsi,%rsi
je     114b <valid+0x4b>
mov    %rsi,%rax
or     %rdi,%rax
shr    $0x20,%rax
mov    $0x1,%eax
je     114b <valid+0x4b>
mov    0x2eb4(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     113d <valid+0x3d>
xor    %edx,%edx
div    %rsi
mov    %rax,%rcx
jmp    1143 <valid+0x43>
xor    %edx,%edx
div    %esi
mov    %eax,%ecx
xor    %eax,%eax
cmp    %rdi,%rcx
setae  %al
ret

LLVM IR (-O0):
@SIZE_MAX = global i64 0
define i32 @valid(i64 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 4294967296, i64* %6
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i32 0, i32* %3
br label %27
13: ; preds = %9
%14 = load i64, i64* %4
%15 = icmp uge i64 %14, 4294967296
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i64, i64* %5
%18 = icmp uge i64 %17, 4294967296
br i1 %18, label %19, label %26
19: ; preds = %16, %13
%20 = load i64, i64* @SIZE_MAX
%21 = load i64, i64* %5
%22 = udiv i64 %20, %21
%23 = load i64, i64* %4
%24 = icmp uge i64 %22, %23
%25 = zext i1 %24 to i32
store i32 %25, i32* %3
br label %27
26: ; preds = %16
store i32 1, i32* %3
br label %27
27: ; preds = %26, %19, %12
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@SIZE_MAX = global i64 0
define i32 @valid(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
%4 = icmp eq i64 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = or i64 %1, %0
%8 = icmp ult i64 %7, 4294967296
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = load i64, i64* @SIZE_MAX
%11 = udiv i64 %10, %1
%12 = icmp uge i64 %11, %0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %6, %2, %9
%15 = phi i32 [ %13, %9 ], [ 0, %2 ], [ 1, %6 ]
ret i32 %15
}