#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 /*<<< orphan*/ AdjustSpan(int *, int *, int);
scalar_t__ IsCompletelyOutside(int, int, int, int, int, int);
bool ClipRectangle(int *x, int *y, int *w, int *h, int clipw, int cliph) {
  if (IsCompletelyOutside(*x, *y, *w, *h, clipw, cliph))
    return false;
  AdjustSpan(x, w, clipw);
  AdjustSpan(y, h, cliph);
  return true;
}


x86 assembly (clang, -O0):
<ClipRectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1040 <IsCompletelyOutside@plt>
cmp    $0x0,%rax
je     117b <ClipRectangle+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <ClipRectangle+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <AdjustSpan@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   1030 <AdjustSpan@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClipRectangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r13d
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,%rbx
mov    (%rdi),%edi
mov    (%rsi),%esi
mov    (%rdx),%edx
mov    (%rcx),%ecx
call   1040 <IsCompletelyOutside@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1175 <ClipRectangle+0x55>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
call   1030 <AdjustSpan@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <AdjustSpan@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ClipRectangle(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%14 = load i32*, i32** %8
%15 = load i32, i32* %14
%16 = load i32*, i32** %9
%17 = load i32, i32* %16
%18 = load i32*, i32** %10
%19 = load i32, i32* %18
%20 = load i32*, i32** %11
%21 = load i32, i32* %20
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = call i64 @IsCompletelyOutside(i32 %15, i32 %17, i32 %19, i32 %21, i32 %22, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %6
store i32 0, i32* %7
br label %36
27: ; preds = %6
%28 = load i32*, i32** %8
%29 = load i32*, i32** %10
%30 = load i32, i32* %12
%31 = call i32 @AdjustSpan(i32* %28, i32* %29, i32 %30)
%32 = load i32*, i32** %9
%33 = load i32*, i32** %11
%34 = load i32, i32* %13
%35 = call i32 @AdjustSpan(i32* %32, i32* %33, i32 %34)
store i32 1, i32* %7
br label %36
36: ; preds = %27, %26
%37 = load i32, i32* %7
ret i32 %37
}

LLVM IR (-O2):
define i32 @ClipRectangle(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4, i32 %5) {
%7 = load i32, i32* %0
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = tail call i64 @IsCompletelyOutside(i32 %7, i32 %8, i32 %9, i32 %10, i32 %4, i32 %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %6
%14 = tail call i32 @AdjustSpan(i32* %0, i32* %2, i32 %4)
%15 = tail call i32 @AdjustSpan(i32* %1, i32* %3, i32 %5)
br label %16
16: ; preds = %6, %13
%17 = phi i32 [ 1, %13 ], [ 0, %6 ]
ret i32 %17
}