#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 INT_MAX;
int /*<<< orphan*/ __ESBMC_assume(int);
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
int *main() {
  int x, y;
  int *a;
  int i;
  if (x < 0 || y < 0 || y > x)
    return (int *)0;
  __ESBMC_assume(x < (INT_MAX / sizeof(int)));
  a = (int *)malloc(x * sizeof(int));
  if (a == 0)
    exit(1);
  for (i = 0; i < y; ++i) {
    a[i] = 0;
  }
  return a;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
cmpl   $0x0,-0xc(%rbp)
jl     1158 <main+0x28>
cmpl   $0x0,-0x10(%rbp)
jl     1158 <main+0x28>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1165 <main+0x35>
movq   $0x0,-0x8(%rbp)
jmp    11e7 <main+0xb7>
movslq -0xc(%rbp),%rax
mov    0x2e78(%rip),%rcx
movslq (%rcx),%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <__ESBMC_assume@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <main+0x7f>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11df <main+0xaf>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b6 <main+0x86>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
xor    %edi,%edi
cmpl   $0x4,(%rax)
setae  %dil
call   1030 <__ESBMC_assume@plt>
xor    %edi,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1154 <main+0x24>
pop    %rcx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32* @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11, %8, %0
store i32* null, i32** %1
br label %50
16: ; preds = %11
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = load i32, i32* @INT_MAX
%20 = sext i32 %19 to i64
%21 = udiv i64 %20, 4
%22 = icmp ult i64 %18, %21
%23 = zext i1 %22 to i32
%24 = call i32 @__ESBMC_assume(i32 %23)
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i32*
store i32* %30, i32** %4
%31 = load i32*, i32** %4
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %35
33: ; preds = %16
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %16
store i32 0, i32* %5
br label %36
36: ; preds = %45, %35
%37 = load i32, i32* %5
%38 = load i32, i32* %3
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = load i32*, i32** %4
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 0, i32* %44
br label %45
45: ; preds = %40
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %36
48: ; preds = %36
%49 = load i32*, i32** %4
store i32* %49, i32** %1
br label %50
50: ; preds = %48, %15
%51 = load i32*, i32** %1
ret i32* %51
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32* @main() {
%1 = load i32, i32* @INT_MAX
%2 = icmp ugt i32 %1, 3
%3 = zext i1 %2 to i32
%4 = tail call i32 @__ESBMC_assume(i32 %3)
%5 = tail call i64 @malloc(i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = inttoptr i64 %5 to i32*
ret i32* %10
}