#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*/ cvAddS(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ cvDestroyWindow(char *);
int cvLoadImage(char const *);
int /*<<< orphan*/ cvNamedWindow(char *);
int /*<<< orphan*/ cvRect(int, int, int, int);
int /*<<< orphan*/ cvReleaseImage(int *);
int /*<<< orphan*/ cvResetImageROI(int);
int /*<<< orphan*/ cvScalar(int);
int /*<<< orphan*/ cvSetImageROI(int, int /*<<< orphan*/);
int /*<<< orphan*/ cvShowImage(char *, int);
int /*<<< orphan*/ cvWaitKey();
void inc(const char *path_to_img, int x, int y, int width, int height,
         int add) {
  auto img = cvLoadImage(path_to_img);
  cvSetImageROI(img, cvRect(x, y, width, height));
  cvAddS(img, cvScalar(add), img);
  cvResetImageROI(img);
  cvNamedWindow("inc");
  cvShowImage("inc", img);
  cvReleaseImage(&img);
  cvWaitKey();
  cvDestroyWindow("inc");
}


x86 assembly (clang, -O0):
<inc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   10d0 <cvLoadImage@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   10b0 <cvRect@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1030 <cvSetImageROI@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <cvScalar@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
mov    -0x20(%rbp),%edx
call   10a0 <cvAddS@plt>
mov    -0x20(%rbp),%edi
call   1070 <cvResetImageROI@plt>
lea    0xddc(%rip),%rdi
call   1060 <cvNamedWindow@plt>
mov    -0x20(%rbp),%esi
lea    0xdcd(%rip),%rdi
call   10c0 <cvShowImage@plt>
lea    -0x20(%rbp),%rdi
call   1080 <cvReleaseImage@plt>
mov    $0x0,%al
call   1040 <cvWaitKey@plt>
lea    0xdb1(%rip),%rdi
call   1090 <cvDestroyWindow@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
call   10d0 <cvLoadImage@plt>
mov    %eax,%ebx
mov    %eax,0x4(%rsp)
mov    %ebp,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   10b0 <cvRect@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <cvSetImageROI@plt>
mov    %r14d,%edi
call   1050 <cvScalar@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    %ebx,%edx
call   10a0 <cvAddS@plt>
mov    %ebx,%edi
call   1070 <cvResetImageROI@plt>
lea    0xdf2(%rip),%rbp
mov    %rbp,%rdi
call   1060 <cvNamedWindow@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   10c0 <cvShowImage@plt>
lea    0x4(%rsp),%rdi
call   1080 <cvReleaseImage@plt>
xor    %eax,%eax
call   1040 <cvWaitKey@plt>
mov    %rbp,%rdi
call   1090 <cvDestroyWindow@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"inc\00"
define void @inc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i8*, i8** %7
%15 = call i32 @cvLoadImage(i8* %14)
store i32 %15, i32* %13
%16 = load i32, i32* %13
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = call i32 @cvRect(i32 %17, i32 %18, i32 %19, i32 %20)
%22 = call i32 @cvSetImageROI(i32 %16, i32 %21)
%23 = load i32, i32* %13
%24 = load i32, i32* %12
%25 = call i32 @cvScalar(i32 %24)
%26 = load i32, i32* %13
%27 = call i32 @cvAddS(i32 %23, i32 %25, i32 %26)
%28 = load i32, i32* %13
%29 = call i32 @cvResetImageROI(i32 %28)
%30 = call i32 @cvNamedWindow(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* %13
%32 = call i32 @cvShowImage(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = call i32 @cvReleaseImage(i32* %13)
%34 = call i32 (...) @cvWaitKey()
%35 = call i32 @cvDestroyWindow(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"inc\00"
define void @inc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = bitcast i32* %7 to i8*
%9 = tail call i32 @cvLoadImage(i8* %0)
store i32 %9, i32* %7
%10 = tail call i32 @cvRect(i32 %1, i32 %2, i32 %3, i32 %4)
%11 = tail call i32 @cvSetImageROI(i32 %9, i32 %10)
%12 = tail call i32 @cvScalar(i32 %5)
%13 = tail call i32 @cvAddS(i32 %9, i32 %12, i32 %9)
%14 = tail call i32 @cvResetImageROI(i32 %9)
%15 = tail call i32 @cvNamedWindow(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @cvShowImage(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%17 = call i32 @cvReleaseImage(i32* %7)
%18 = call i32 (...) @cvWaitKey()
%19 = call i32 @cvDestroyWindow(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}