#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ clamp16bS(unsigned char *, unsigned char *, int, int, int,
                             int);
void Clamp16bS(unsigned char *tex, uint32_t width, uint32_t clamp_to,
               uint32_t real_width, uint32_t real_height) {
  if (real_width <= width)
    return;
  unsigned char *dest = tex + (width << 1);
  unsigned char *constant = dest - 2;
  int count = clamp_to - width;
  int line_full = real_width << 1;
  int line = width << 1;
  clamp16bS(dest, constant, real_height, line, line_full, count);
}


x86 assembly (clang, -O0):
<Clamp16bS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     113a <Clamp16bS+0x2a>
jmp    1190 <Clamp16bS+0x80>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1030 <clamp16bS@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Clamp16bS>:
cmp    %esi,%ecx
jle    113d <Clamp16bS+0x2d>
mov    %ecx,%eax
mov    %edx,%r9d
lea    (%rsi,%rsi,1),%ecx
movslq %ecx,%rcx
lea    (%rdi,%rcx,1),%rdx
add    $0xfffffffffffffffe,%rdx
add    %rcx,%rdi
sub    %esi,%r9d
add    %eax,%eax
mov    %rdx,%rsi
mov    %r8d,%edx
mov    %eax,%r8d
jmp    1030 <clamp16bS@plt>
ret

LLVM IR (-O0):
define void @Clamp16bS(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %5
br label %42
20: ; preds = %5
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = shl i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
store i8* %25, i8** %11
%26 = load i8*, i8** %11
%27 = getelementptr inbounds i8, i8* %26, i64 -2
store i8* %27, i8** %12
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = sub nsw i32 %28, %29
store i32 %30, i32* %13
%31 = load i32, i32* %9
%32 = shl i32 %31, 1
store i32 %32, i32* %14
%33 = load i32, i32* %7
%34 = shl i32 %33, 1
store i32 %34, i32* %15
%35 = load i8*, i8** %11
%36 = load i8*, i8** %12
%37 = load i32, i32* %10
%38 = load i32, i32* %15
%39 = load i32, i32* %14
%40 = load i32, i32* %13
%41 = call i32 @clamp16bS(i8* %35, i8* %36, i32 %37, i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
define void @Clamp16bS(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, %1
br i1 %6, label %7, label %15
7: ; preds = %5
%8 = shl i32 %1, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -2
%12 = sub nsw i32 %2, %1
%13 = shl i32 %3, 1
%14 = tail call i32 @clamp16bS(i8* %10, i8* %11, i32 %4, i32 %8, i32 %13, i32 %12)
br label %15
15: ; preds = %5, %7
ret void
}