#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 */
struct zint_symbol {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ set_module(struct zint_symbol *, int, int);
void block_copy(struct zint_symbol *symbol, char grid[][120], int start_row,
                int start_col, int height, int width, int row_offset,
                int col_offset) {
  int i, j;
  for (i = start_row; i < (start_row + height); i++) {
    for (j = start_col; j < (start_col + width); j++) {
      if (grid[i][j] == '1') {
        set_module(symbol, i + row_offset, j + col_offset);
      }
    }
  }
}


x86 assembly (clang, -O0):
<block_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    11bd <block_copy+0xad>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    11aa <block_copy+0x9a>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x78,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    1197 <block_copy+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    0x10(%rbp),%esi
mov    -0x28(%rbp),%edx
add    0x18(%rbp),%edx
call   1030 <set_module@plt>
jmp    119c <block_copy+0x8c>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1151 <block_copy+0x41>
jmp    11af <block_copy+0x9f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <block_copy+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
test   %r8d,%r8d
jle    11d2 <block_copy+0xc2>
mov    %rsi,%rbx
mov    %rdi,%r15
add    %edx,%r8d
mov    0x10(%rsp),%rax
add    %ecx,%eax
movslq %ecx,%rcx
movslq %eax,%r13
movslq %edx,%rax
movslq %r8d,%rdx
mov    %rdx,0x20(%rsp)
mov    0x68(%rsp),%edx
mov    %rcx,0x18(%rsp)
add    %ecx,%edx
mov    %edx,0xc(%rsp)
mov    %rax,(%rsp)
imul   $0x78,%rax,%rax
add    %rax,%rbx
jmp    1187 <block_copy+0x77>
nopl   0x0(%rax)
mov    (%rsp),%rax
add    $0x1,%rax
add    $0x78,%rbx
mov    %rax,(%rsp)
cmp    0x20(%rsp),%rax
jge    11d2 <block_copy+0xc2>
cmpl   $0x0,0x10(%rsp)
jle    1170 <block_copy+0x60>
mov    0x60(%rsp),%eax
mov    (%rsp),%rcx
lea    (%rcx,%rax,1),%r12d
mov    0xc(%rsp),%ebp
mov    0x18(%rsp),%r14
jmp    11bc <block_copy+0xac>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14
add    $0x1,%ebp
cmp    %r13,%r14
jge    1170 <block_copy+0x60>
cmpb   $0x31,(%rbx,%r14,1)
jne    11b0 <block_copy+0xa0>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
call   1030 <set_module@plt>
jmp    11b0 <block_copy+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.zint_symbol = type { i32 }
define void @block_copy(%struct.zint_symbol* %0, [120 x i8]* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca %struct.zint_symbol*
%10 = alloca [120 x i8]*
%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 %struct.zint_symbol* %0, %struct.zint_symbol** %9
store [120 x i8]* %1, [120 x i8]** %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
%19 = load i32, i32* %11
store i32 %19, i32* %17
br label %20
20: ; preds = %59, %8
%21 = load i32, i32* %17
%22 = load i32, i32* %11
%23 = load i32, i32* %13
%24 = add nsw i32 %22, %23
%25 = icmp slt i32 %21, %24
br i1 %25, label %26, label %62
26: ; preds = %20
%27 = load i32, i32* %12
store i32 %27, i32* %18
br label %28
28: ; preds = %55, %26
%29 = load i32, i32* %18
%30 = load i32, i32* %12
%31 = load i32, i32* %14
%32 = add nsw i32 %30, %31
%33 = icmp slt i32 %29, %32
br i1 %33, label %34, label %58
34: ; preds = %28
%35 = load [120 x i8]*, [120 x i8]** %10
%36 = load i32, i32* %17
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [120 x i8], [120 x i8]* %35, i64 %37
%39 = load i32, i32* %18
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [120 x i8], [120 x i8]* %38, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 49
br i1 %44, label %45, label %54
45: ; preds = %34
%46 = load %struct.zint_symbol*, %struct.zint_symbol** %9
%47 = load i32, i32* %17
%48 = load i32, i32* %15
%49 = add nsw i32 %47, %48
%50 = load i32, i32* %18
%51 = load i32, i32* %16
%52 = add nsw i32 %50, %51
%53 = call i32 @set_module(%struct.zint_symbol* %46, i32 %49, i32 %52)
br label %54
54: ; preds = %45, %34
br label %55
55: ; preds = %54
%56 = load i32, i32* %18
%57 = add nsw i32 %56, 1
store i32 %57, i32* %18
br label %28
58: ; preds = %28
br label %59
59: ; preds = %58
%60 = load i32, i32* %17
%61 = add nsw i32 %60, 1
store i32 %61, i32* %17
br label %20
62: ; preds = %20
ret void
}

LLVM IR (-O2):
%struct.zint_symbol = type { i32 }
define void @block_copy(%struct.zint_symbol* %0, [120 x i8]* nocapture %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = icmp sgt i32 %4, 0
br i1 %9, label %10, label %38
10: ; preds = %8
%11 = add nsw i32 %4, %2
%12 = add nsw i32 %5, %3
%13 = icmp sgt i32 %5, 0
%14 = sext i32 %3 to i64
%15 = sext i32 %12 to i64
%16 = sext i32 %2 to i64
%17 = sext i32 %11 to i64
br label %18
18: ; preds = %10, %35
%19 = phi i64 [ %16, %10 ], [ %36, %35 ]
br i1 %13, label %20, label %35
20: ; preds = %18
%21 = trunc i64 %19 to i32
%22 = add i32 %21, %6
br label %23
23: ; preds = %20, %32
%24 = phi i64 [ %14, %20 ], [ %33, %32 ]
%25 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 %19, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 49
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = trunc i64 %24 to i32
%30 = add i32 %29, %7
%31 = tail call i32 @set_module(%struct.zint_symbol* %0, i32 %22, i32 %30)
br label %32
32: ; preds = %23, %28
%33 = add nsw i64 %24, 1
%34 = icmp slt i64 %33, %15
br i1 %34, label %23, label %35
35: ; preds = %32, %18
%36 = add nsw i64 %19, 1
%37 = icmp slt i64 %36, %17
br i1 %37, label %18, label %38
38: ; preds = %35, %8
ret void
}