#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*/ stbhw__set_pixel(unsigned char *, int, int, int,
                                    unsigned char *);
void stbhw__draw_clipped_corner(unsigned char *data, int stride, int xpos,
                                int ypos, int w, int h, int x, int y) {
  static unsigned char template_color[3] = {167, 204, 204};
  int i, j;
  for (j = -2; j <= 1; ++j) {
    for (i = -2; i <= 1; ++i) {
      if ((i == -2 || i == 1) && (j == -2 || j == 1))
        continue;
      else {
        if (x + i < 1 || x + i > w)
          continue;
        if (y + j < 1 || y + j > h)
          continue;
        stbhw__set_pixel(data, stride, xpos + x + i, ypos + y + j,
                         template_color);
      }
    }
  }
}


x86 assembly (clang, -O0):
<stbhw__draw_clipped_corner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0xfffffffe,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jg     1213 <stbhw__draw_clipped_corner+0x103>
movl   $0xfffffffe,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jg     1200 <stbhw__draw_clipped_corner+0xf0>
cmpl   $0xfffffffe,-0x20(%rbp)
je     1169 <stbhw__draw_clipped_corner+0x59>
cmpl   $0x1,-0x20(%rbp)
jne    1182 <stbhw__draw_clipped_corner+0x72>
cmpl   $0xfffffffe,-0x24(%rbp)
je     117d <stbhw__draw_clipped_corner+0x6d>
cmpl   $0x1,-0x24(%rbp)
jne    1182 <stbhw__draw_clipped_corner+0x72>
jmp    11f2 <stbhw__draw_clipped_corner+0xe2>
mov    0x10(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    $0x1,%eax
jl     11a0 <stbhw__draw_clipped_corner+0x90>
mov    0x10(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11a5 <stbhw__draw_clipped_corner+0x95>
jmp    11f2 <stbhw__draw_clipped_corner+0xe2>
mov    0x18(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    $0x1,%eax
jl     11c3 <stbhw__draw_clipped_corner+0xb3>
mov    0x18(%rbp),%eax
add    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11c8 <stbhw__draw_clipped_corner+0xb8>
jmp    11f2 <stbhw__draw_clipped_corner+0xe2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    0x10(%rbp),%edx
add    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    0x18(%rbp),%ecx
add    -0x24(%rbp),%ecx
lea    0x2e40(%rip),%r8
call   1030 <stbhw__set_pixel@plt>
jmp    11f2 <stbhw__draw_clipped_corner+0xe2>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114b <stbhw__draw_clipped_corner+0x3b>
jmp    1205 <stbhw__draw_clipped_corner+0xf5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <stbhw__draw_clipped_corner+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbhw__draw_clipped_corner>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x14(%rsp)
mov    %ecx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x58(%rsp),%r9d
mov    0x50(%rsp),%esi
lea    -0x2(%rsi),%edi
test   %edi,%edi
setle  %r10b
cmp    %r8d,%edi
setg   %al
or     %r10b,%al
mov    %al,0x1(%rsp)
lea    (%rsi,%rdx,1),%eax
add    $0xfffffffe,%eax
mov    %eax,0x8(%rsp)
lea    -0x1(%rsi),%edi
test   %edi,%edi
setle  %r10b
cmp    %r8d,%edi
setg   %al
or     %r10b,%al
mov    %al,0x3(%rsp)
lea    (%rsi,%rdx,1),%eax
add    $0xffffffff,%eax
mov    %eax,0x10(%rsp)
test   %esi,%esi
setle  %dil
cmp    %r8d,%esi
setg   %al
or     %dil,%al
mov    %al,0x2(%rsp)
lea    (%rsi,%rdx,1),%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
mov    %edx,%eax
add    %esi,%eax
mov    %eax,0xc(%rsp)
lea    0x1(%rsi),%edx
cmp    $0x7fffffff,%esi
setae  %al
cmp    %r8d,%edx
setg   %dl
or     %al,%dl
mov    %dl,(%rsp)
add    %r9d,%r14d
mov    $0xfffffffe,%r15d
jmp    11ce <stbhw__draw_clipped_corner+0xbe>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x2,%r15d
je     129f <stbhw__draw_clipped_corner+0x18f>
mov    0x58(%rsp),%eax
add    %r15d,%eax
test   %eax,%eax
setle  %cl
cmp    0x14(%rsp),%eax
setg   %r13b
or     %cl,%r13b
lea    (%r14,%r15,1),%r12d
cmp    $0xfffffffe,%r15d
je     1220 <stbhw__draw_clipped_corner+0x110>
cmp    $0x1,%r15d
je     1220 <stbhw__draw_clipped_corner+0x110>
movzbl 0x1(%rsp),%eax
or     %r13b,%al
jne    1220 <stbhw__draw_clipped_corner+0x110>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0x8(%rsp),%edx
mov    %r12d,%ecx
lea    0x2e16(%rip),%r8
call   1030 <stbhw__set_pixel@plt>
nopw   0x0(%rax,%rax,1)
movzbl 0x3(%rsp),%eax
or     %r13b,%al
jne    1242 <stbhw__draw_clipped_corner+0x132>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0x10(%rsp),%edx
mov    %r12d,%ecx
lea    0x2deb(%rip),%r8
call   1030 <stbhw__set_pixel@plt>
movzbl 0x2(%rsp),%eax
or     %r13b,%al
jne    1264 <stbhw__draw_clipped_corner+0x154>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0xc(%rsp),%edx
mov    %r12d,%ecx
lea    0x2dc9(%rip),%r8
call   1030 <stbhw__set_pixel@plt>
cmp    $0xfffffffe,%r15d
je     11c0 <stbhw__draw_clipped_corner+0xb0>
cmp    $0x1,%r15d
je     11c0 <stbhw__draw_clipped_corner+0xb0>
or     (%rsp),%r13b
jne    11c0 <stbhw__draw_clipped_corner+0xb0>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0x4(%rsp),%edx
mov    %r12d,%ecx
lea    0x2d93(%rip),%r8
call   1030 <stbhw__set_pixel@plt>
jmp    11c0 <stbhw__draw_clipped_corner+0xb0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stbhw__draw_clipped_corner.template_color = internal global [3 x i8] c"\A7\CC\CC"
define void @stbhw__draw_clipped_corner(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i32 -2, i32* %18
br label %19
19: ; preds = %82, %8
%20 = load i32, i32* %18
%21 = icmp sle i32 %20, 1
br i1 %21, label %22, label %85
22: ; preds = %19
store i32 -2, i32* %17
br label %23
23: ; preds = %78, %22
%24 = load i32, i32* %17
%25 = icmp sle i32 %24, 1
br i1 %25, label %26, label %81
26: ; preds = %23
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, -2
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %17
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %39
32: ; preds = %29, %26
%33 = load i32, i32* %18
%34 = icmp eq i32 %33, -2
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %18
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %39
38: ; preds = %35, %32
br label %78
39: ; preds = %35, %29
%40 = load i32, i32* %15
%41 = load i32, i32* %17
%42 = add nsw i32 %40, %41
%43 = icmp slt i32 %42, 1
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = load i32, i32* %15
%46 = load i32, i32* %17
%47 = add nsw i32 %45, %46
%48 = load i32, i32* %13
%49 = icmp sgt i32 %47, %48
br i1 %49, label %50, label %51
50: ; preds = %44, %39
br label %78
51: ; preds = %44
%52 = load i32, i32* %16
%53 = load i32, i32* %18
%54 = add nsw i32 %52, %53
%55 = icmp slt i32 %54, 1
br i1 %55, label %62, label %56
56: ; preds = %51
%57 = load i32, i32* %16
%58 = load i32, i32* %18
%59 = add nsw i32 %57, %58
%60 = load i32, i32* %14
%61 = icmp sgt i32 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %56, %51
br label %78
63: ; preds = %56
%64 = load i8*, i8** %9
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = load i32, i32* %15
%68 = add nsw i32 %66, %67
%69 = load i32, i32* %17
%70 = add nsw i32 %68, %69
%71 = load i32, i32* %12
%72 = load i32, i32* %16
%73 = add nsw i32 %71, %72
%74 = load i32, i32* %18
%75 = add nsw i32 %73, %74
%76 = call i32 @stbhw__set_pixel(i8* %64, i32 %65, i32 %70, i32 %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @stbhw__draw_clipped_corner.template_color, i64 0, i64 0))
br label %77
77: ; preds = %63
br label %78
78: ; preds = %77, %62, %50, %38
%79 = load i32, i32* %17
%80 = add nsw i32 %79, 1
store i32 %80, i32* %17
br label %23
81: ; preds = %23
br label %82
82: ; preds = %81
%83 = load i32, i32* %18
%84 = add nsw i32 %83, 1
store i32 %84, i32* %18
br label %19
85: ; preds = %19
ret void
}

LLVM IR (-O2):
@stbhw__draw_clipped_corner.template_color = internal global [3 x i8] c"\A7\CC\CC"
define void @stbhw__draw_clipped_corner(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = add i32 %6, -2
%10 = icmp slt i32 %9, 1
%11 = icmp sgt i32 %9, %4
%12 = or i1 %10, %11
%13 = add i32 %9, %2
%14 = add i32 %6, -1
%15 = icmp slt i32 %14, 1
%16 = icmp sgt i32 %14, %4
%17 = or i1 %15, %16
%18 = add i32 %14, %2
%19 = icmp slt i32 %6, 1
%20 = icmp sgt i32 %6, %4
%21 = or i1 %19, %20
%22 = add i32 %6, %2
%23 = add i32 %6, 1
%24 = icmp ugt i32 %6, 2147483646
%25 = icmp sgt i32 %23, %4
%26 = or i1 %24, %25
%27 = add i32 %23, %2
br label %28
28: ; preds = %52, %8
%29 = phi i32 [ -2, %8 ], [ %53, %52 ]
%30 = add i32 %29, %7
%31 = icmp slt i32 %30, 1
%32 = icmp sgt i32 %30, %5
%33 = or i1 %31, %32
%34 = add i32 %30, %3
switch i32 %29, label %35 [
i32 -2, label %39
i32 1, label %39
]
35: ; preds = %28
%36 = select i1 %12, i1 true, i1 %33
br i1 %36, label %39, label %37
37: ; preds = %35
%38 = tail call i32 @stbhw__set_pixel(i8* %0, i32 %1, i32 %13, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @stbhw__draw_clipped_corner.template_color, i64 0, i64 0))
br label %39
39: ; preds = %37, %28, %28, %35
%40 = select i1 %17, i1 true, i1 %33
br i1 %40, label %43, label %41
41: ; preds = %39
%42 = tail call i32 @stbhw__set_pixel(i8* %0, i32 %1, i32 %18, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @stbhw__draw_clipped_corner.template_color, i64 0, i64 0))
br label %43
43: ; preds = %39, %41
%44 = select i1 %21, i1 true, i1 %33
br i1 %44, label %47, label %45
45: ; preds = %43
%46 = tail call i32 @stbhw__set_pixel(i8* %0, i32 %1, i32 %22, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @stbhw__draw_clipped_corner.template_color, i64 0, i64 0))
br label %47
47: ; preds = %43, %45
switch i32 %29, label %48 [
i32 -2, label %52
i32 1, label %52
]
48: ; preds = %47
%49 = select i1 %26, i1 true, i1 %33
br i1 %49, label %52, label %50
50: ; preds = %48
%51 = tail call i32 @stbhw__set_pixel(i8* %0, i32 %1, i32 %27, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @stbhw__draw_clipped_corner.template_color, i64 0, i64 0))
br label %52
52: ; preds = %50, %48, %47, %47
%53 = add nsw i32 %29, 1
%54 = icmp eq i32 %53, 2
br i1 %54, label %55, label %28
55: ; preds = %52
ret void
}