#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*/ init_bitmap(int, int, int **);
int paint_region(int, int, int **, int, int, int);
int /*<<< orphan*/ print_bitmap(int, int, int **);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int col = 30;
  int row = 20;
  int pixels;
  int bitmap[col][row];
  int x = 16, y = 12, color = 4;
  init_bitmap(col, row, bitmap);
  print_bitmap(col, row, bitmap);
  pixels = paint_region(col, row, bitmap, x, y, color);
  printf("painted %d pixels: \n\n", pixels);
  print_bitmap(col, row, bitmap);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e,-0x8(%rbp)
movl   $0x14,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
movl   $0x10,-0x2c(%rbp)
movl   $0xc,-0x30(%rbp)
movl   $0x4,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <init_bitmap@plt>
mov    -0x40(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <print_bitmap@plt>
mov    -0x40(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x34(%rbp),%r9d
call   1030 <paint_region@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <print_bitmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x960,%rsp
mov    %rsp,%rbx
mov    $0x1e,%edi
mov    $0x14,%esi
mov    %rbx,%rdx
call   1050 <init_bitmap@plt>
mov    $0x1e,%edi
mov    $0x14,%esi
mov    %rbx,%rdx
call   1060 <print_bitmap@plt>
mov    $0x1e,%edi
mov    $0x14,%esi
mov    %rbx,%rdx
mov    $0x10,%ecx
mov    $0xc,%r8d
mov    $0x4,%r9d
call   1030 <paint_region@plt>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x1e,%edi
mov    $0x14,%esi
mov    %rbx,%rdx
call   1060 <print_bitmap@plt>
xor    %eax,%eax
add    $0x960,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"painted %d pixels: \0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 30, i32* %2
store i32 20, i32* %3
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %5
%16 = mul nuw i64 %12, %14
%17 = alloca i32, i64 %16
store i64 %12, i64* %6
store i64 %14, i64* %7
store i32 16, i32* %8
store i32 12, i32* %9
store i32 4, i32* %10
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = bitcast i32* %17 to i32**
%21 = call i32 @init_bitmap(i32 %18, i32 %19, i32** %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = bitcast i32* %17 to i32**
%25 = call i32 @print_bitmap(i32 %22, i32 %23, i32** %24)
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = bitcast i32* %17 to i32**
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = call i32 @paint_region(i32 %26, i32 %27, i32** %28, i32 %29, i32 %30, i32 %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = bitcast i32* %17 to i32**
%38 = call i32 @print_bitmap(i32 %35, i32 %36, i32** %37)
store i32 0, i32* %1
%39 = load i8*, i8** %5
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [22 x i8] c"painted %d pixels: \0A\0A\00"
define i32 @main() {
%1 = alloca [300 x i32*]
%2 = getelementptr inbounds [300 x i32*], [300 x i32*]* %1, i64 0, i64 0
%3 = call i32 @init_bitmap(i32 30, i32 20, i32** %2)
%4 = call i32 @print_bitmap(i32 30, i32 20, i32** %2)
%5 = call i32 @paint_region(i32 30, i32 20, i32** %2, i32 16, i32 12, i32 4)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @print_bitmap(i32 30, i32 20, i32** %2)
ret i32 0
}