#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 */
unsigned int *calloc(int, int);
int /*<<< orphan*/ set_error(char *);
unsigned *init_clipping(void) {
  static unsigned *gray_clip = NULL;
  if (gray_clip == NULL) {
    int i;
    gray_clip = calloc(256 * 3, sizeof(unsigned));
    if (!gray_clip) {
      set_error(("Out of memory."));
      return NULL;
    }
    gray_clip += 256;
    for (i = -256; i < 512; i++)
      if (i < 0)
        gray_clip[i] = 0;
      else if (i > 255)
        gray_clip[i] = 255;
      else
        gray_clip[i] = i;
  }
  return gray_clip;
}


x86 assembly (clang, -O0):
<init_clipping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpq   $0x0,0x2f08(%rip)
jne    120e <init_clipping+0xee>
mov    $0x300,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,0x2eec(%rip)
cmpq   $0x0,0x2ee4(%rip)
jne    1173 <init_clipping+0x53>
lea    0xe9f(%rip),%rdi
call   1030 <set_error@plt>
movq   $0x0,-0x8(%rbp)
jmp    1219 <init_clipping+0xf9>
mov    0x2ebe(%rip),%rax
add    $0x400,%rax
mov    %rax,0x2eb1(%rip)
movl   $0xffffff00,-0xc(%rbp)
cmpl   $0x200,-0xc(%rbp)
jge    1209 <init_clipping+0xe9>
cmpl   $0x0,-0xc(%rbp)
jge    11bc <init_clipping+0x9c>
mov    0x2e8c(%rip),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11f6 <init_clipping+0xd6>
cmpl   $0xff,-0xc(%rbp)
jle    11e0 <init_clipping+0xc0>
mov    0x2e68(%rip),%rax
movslq -0xc(%rbp),%rcx
movl   $0xff,(%rax,%rcx,4)
jmp    11f1 <init_clipping+0xd1>
mov    -0xc(%rbp),%edx
mov    0x2e4e(%rip),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11f6 <init_clipping+0xd6>
jmp    11fb <init_clipping+0xdb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118e <init_clipping+0x6e>
jmp    120e <init_clipping+0xee>
mov    0x2e23(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_clipping>:
push   %rax
mov    0x2f10(%rip),%rax
test   %rax,%rax
je     112f <init_clipping+0xf>
pop    %rcx
ret
mov    $0x300,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,0x2ef3(%rip)
test   %rax,%rax
je     11a5 <init_clipping+0x85>
mov    %rax,%rcx
add    $0x400,%rax
mov    %rax,0x2ede(%rip)
mov    $0xffffffffffffff00,%rdx
jmp    1188 <init_clipping+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x0,0x400(%rcx,%rdx,4)
add    $0x1,%rdx
cmp    $0x200,%rdx
je     112d <init_clipping+0xd>
test   %rdx,%rdx
js     1170 <init_clipping+0x50>
mov    %edx,%esi
cmp    $0x100,%edx
jb     11a0 <init_clipping+0x80>
movl   $0xff,(%rax,%rsi,4)
jmp    117b <init_clipping+0x5b>
mov    %edx,(%rax,%rsi,4)
jmp    117b <init_clipping+0x5b>
lea    0xe54(%rip),%rdi
call   1030 <set_error@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@init_clipping.gray_clip = internal global i32* null
@.str = [15 x i8] c"Out of memory.\00"
define i32* @init_clipping() {
%1 = alloca i32*
%2 = alloca i32
%3 = load i32*, i32** @init_clipping.gray_clip
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %45
5: ; preds = %0
%6 = call i32* @calloc(i32 768, i32 4)
store i32* %6, i32** @init_clipping.gray_clip
%7 = load i32*, i32** @init_clipping.gray_clip
%8 = icmp ne i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = call i32 @set_error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %1
br label %47
11: ; preds = %5
%12 = load i32*, i32** @init_clipping.gray_clip
%13 = getelementptr inbounds i32, i32* %12, i64 256
store i32* %13, i32** @init_clipping.gray_clip
store i32 -256, i32* %2
br label %14
14: ; preds = %41, %11
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 512
br i1 %16, label %17, label %44
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32*, i32** @init_clipping.gray_clip
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 0, i32* %24
br label %40
25: ; preds = %17
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 255
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32*, i32** @init_clipping.gray_clip
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 255, i32* %32
br label %39
33: ; preds = %25
%34 = load i32, i32* %2
%35 = load i32*, i32** @init_clipping.gray_clip
%36 = load i32, i32* %2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %33, %28
br label %40
40: ; preds = %39, %20
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %14
44: ; preds = %14
br label %45
45: ; preds = %44, %0
%46 = load i32*, i32** @init_clipping.gray_clip
store i32* %46, i32** %1
br label %47
47: ; preds = %45, %9
%48 = load i32*, i32** %1
ret i32* %48
}

LLVM IR (-O2):
@init_clipping.gray_clip = internal unnamed_addr global i32* null
@.str = [15 x i8] c"Out of memory.\00"
define i32* @init_clipping() {
%1 = load i32*, i32** @init_clipping.gray_clip
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %25
3: ; preds = %0
%4 = tail call i32* @calloc(i32 768, i32 4)
store i32* %4, i32** @init_clipping.gray_clip
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @set_error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %25
8: ; preds = %3
%9 = getelementptr inbounds i32, i32* %4, i64 256
store i32* %9, i32** @init_clipping.gray_clip
br label %10
10: ; preds = %8, %22
%11 = phi i64 [ -256, %8 ], [ %23, %22 ]
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = getelementptr inbounds i32, i32* %9, i64 %11
store i32 0, i32* %14
br label %22
15: ; preds = %10
%16 = trunc i64 %11 to i32
%17 = icmp ugt i32 %16, 255
%18 = and i64 %11, 4294967295
%19 = getelementptr inbounds i32, i32* %9, i64 %18
br i1 %17, label %20, label %21
20: ; preds = %15
store i32 255, i32* %19
br label %22
21: ; preds = %15
store i32 %16, i32* %19
br label %22
22: ; preds = %13, %21, %20
%23 = add nsw i64 %11, 1
%24 = icmp eq i64 %23, 512
br i1 %24, label %25, label %10
25: ; preds = %22, %0, %6
%26 = phi i32* [ null, %6 ], [ %1, %0 ], [ %9, %22 ]
ret i32* %26
}