#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*/ clip(int);
void bright(int *f, int w, int h, int *g, int q) {
  int i, j;
  for (j = 0; j < h; j++) {
    for (i = 0; i < w; i++) {
      *g++ = clip((*f++) + q);
    }
  }
}


x86 assembly (clang, -O0):
<bright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119d <bright+0x8d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <bright+0x7a>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%edi
add    -0x1c(%rbp),%edi
call   1030 <clip@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1144 <bright+0x34>
jmp    118f <bright+0x7f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <bright+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bright>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0x8(%rsp)
mov    %edx,0xc(%rsp)
test   %edx,%edx
jle    118c <bright+0x7c>
mov    %r8d,%r12d
mov    %rcx,%r13
mov    %rdi,%rbp
mov    0x8(%rsp),%ebx
xor    %eax,%eax
jmp    1149 <bright+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
cmp    0xc(%rsp),%eax
je     118c <bright+0x7c>
cmpl   $0x0,0x8(%rsp)
jle    1140 <bright+0x30>
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r15,4),%edi
add    %r12d,%edi
call   1030 <clip@plt>
mov    %eax,0x0(%r13,%r15,4)
add    $0x1,%r15
add    $0xfffffffffffffffc,%r14
cmp    %r15d,%ebx
jne    1160 <bright+0x50>
sub    %r14,%rbp
sub    %r14,%r13
mov    0x10(%rsp),%rax
jmp    1140 <bright+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @bright(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture writeonly %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = icmp sgt i32 %1, 0
br label %9
9: ; preds = %7, %24
%10 = phi i32 [ 0, %7 ], [ %27, %24 ]
%11 = phi i32* [ %0, %7 ], [ %26, %24 ]
%12 = phi i32* [ %3, %7 ], [ %25, %24 ]
br i1 %8, label %13, label %24
13: ; preds = %9, %13
%14 = phi i32 [ %22, %13 ], [ 0, %9 ]
%15 = phi i32* [ %17, %13 ], [ %11, %9 ]
%16 = phi i32* [ %21, %13 ], [ %12, %9 ]
%17 = getelementptr inbounds i32, i32* %15, i64 1
%18 = load i32, i32* %15
%19 = add nsw i32 %18, %4
%20 = tail call i32 @clip(i32 %19)
%21 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %20, i32* %16
%22 = add nuw nsw i32 %14, 1
%23 = icmp eq i32 %22, %1
br i1 %23, label %24, label %13
24: ; preds = %13, %9
%25 = phi i32* [ %12, %9 ], [ %21, %13 ]
%26 = phi i32* [ %11, %9 ], [ %17, %13 ]
%27 = add nuw nsw i32 %10, 1
%28 = icmp eq i32 %27, %2
br i1 %28, label %29, label %9
29: ; preds = %24, %5
ret void
}