#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ **, int /*<<< orphan*/ **, int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ **, int /*<<< orphan*/, int);
void create_frame(int index, uint8_t frame[][80][3], uint8_t image[][80][3]) {
  int sy;
  int dy;
  for (dy = 0; dy < 8; dy++) {
    sy = (dy * 4) + index;
    if ((sy < 0) || (sy >= 4 * 100)) {
      memset(frame[dy], 0, 80 * 3);
    } else {
      memcpy(frame[dy], image[sy], 80 * 3);
    }
  }
}


x86 assembly (clang, -O0):
<create_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x8,-0x20(%rbp)
jge    11cb <create_frame+0xab>
mov    -0x20(%rbp),%eax
shl    $0x2,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1167 <create_frame+0x47>
cmpl   $0x190,-0x1c(%rbp)
jl     118a <create_frame+0x6a>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x3c0,%rax,%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    11b8 <create_frame+0x98>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x3c0,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
imul   $0x3c0,%rax,%rax
add    %rax,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
jmp    11bd <create_frame+0x9d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113a <create_frame+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_frame>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
cmp    $0x190,%edi
jb     1146 <create_frame+0x26>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    115f <create_frame+0x3f>
mov    %ebx,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    %r15,%rdi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0x4(%rbx),%eax
lea    0x3c0(%r15),%rdi
cmp    $0x18f,%eax
jbe    117e <create_frame+0x5e>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    1194 <create_frame+0x74>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0x8(%rbx),%eax
lea    0x780(%r15),%rdi
cmp    $0x18f,%eax
jbe    11b3 <create_frame+0x93>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    11c9 <create_frame+0xa9>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0xc(%rbx),%eax
lea    0xb40(%r15),%rdi
cmp    $0x18f,%eax
jbe    11e8 <create_frame+0xc8>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    11fe <create_frame+0xde>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0x10(%rbx),%eax
lea    0xf00(%r15),%rdi
cmp    $0x18f,%eax
jbe    121d <create_frame+0xfd>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    1233 <create_frame+0x113>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0x14(%rbx),%eax
lea    0x12c0(%r15),%rdi
cmp    $0x18f,%eax
jbe    1252 <create_frame+0x132>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    1268 <create_frame+0x148>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
lea    0x18(%rbx),%eax
lea    0x1680(%r15),%rdi
cmp    $0x18f,%eax
jbe    1287 <create_frame+0x167>
xor    %esi,%esi
mov    $0xf0,%edx
call   1030 <memset@plt>
jmp    129d <create_frame+0x17d>
mov    %eax,%eax
imul   $0x3c0,%rax,%rsi
add    %r14,%rsi
mov    $0xf0,%edx
call   1040 <memcpy@plt>
add    $0x1c,%ebx
add    $0x1a40,%r15
cmp    $0x18f,%ebx
jbe    12c3 <create_frame+0x1a3>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xf0,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memset@plt>
mov    %ebx,%eax
imul   $0x3c0,%rax,%rax
add    %rax,%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0xf0,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <memcpy@plt>

LLVM IR (-O0):
define void @create_frame(i32 %0, [80 x [3 x i32]]* %1, [80 x [3 x i32]]* %2) {
%4 = alloca i32
%5 = alloca [80 x [3 x i32]]*
%6 = alloca [80 x [3 x i32]]*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store [80 x [3 x i32]]* %1, [80 x [3 x i32]]** %5
store [80 x [3 x i32]]* %2, [80 x [3 x i32]]** %6
store i32 0, i32* %8
br label %9
9: ; preds = %45, %3
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %48
12: ; preds = %9
%13 = load i32, i32* %8
%14 = mul nsw i32 %13, 4
%15 = load i32, i32* %4
%16 = add nsw i32 %14, %15
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = load i32, i32* %7
%21 = icmp sge i32 %20, 400
br i1 %21, label %22, label %30
22: ; preds = %19, %12
%23 = load [80 x [3 x i32]]*, [80 x [3 x i32]]** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %23, i64 %25
%27 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %26, i64 0, i64 0
%28 = bitcast [3 x i32]* %27 to i32**
%29 = call i32 @memset(i32** %28, i32 0, i32 240)
br label %44
30: ; preds = %19
%31 = load [80 x [3 x i32]]*, [80 x [3 x i32]]** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %31, i64 %33
%35 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %34, i64 0, i64 0
%36 = bitcast [3 x i32]* %35 to i32**
%37 = load [80 x [3 x i32]]*, [80 x [3 x i32]]** %6
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %37, i64 %39
%41 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %40, i64 0, i64 0
%42 = bitcast [3 x i32]* %41 to i32**
%43 = call i32 @memcpy(i32** %36, i32** %42, i32 240)
br label %44
44: ; preds = %30, %22
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %9
48: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @create_frame(i32 %0, [80 x [3 x i32]]* %1, [80 x [3 x i32]]* %2) {
%4 = icmp ugt i32 %0, 399
%5 = bitcast [80 x [3 x i32]]* %1 to i32**
br i1 %4, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @memset(i32** %5, i32 0, i32 240)
br label %13
8: ; preds = %3
%9 = zext i32 %0 to i64
%10 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %9, i64 0
%11 = bitcast [3 x i32]* %10 to i32**
%12 = tail call i32 @memcpy(i32** %5, i32** %11, i32 240)
br label %13
13: ; preds = %6, %8
%14 = add i32 %0, 4
%15 = icmp ugt i32 %14, 399
%16 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 1, i64 0
%17 = bitcast [3 x i32]* %16 to i32**
br i1 %15, label %23, label %18
18: ; preds = %13
%19 = zext i32 %14 to i64
%20 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %19, i64 0
%21 = bitcast [3 x i32]* %20 to i32**
%22 = tail call i32 @memcpy(i32** %17, i32** %21, i32 240)
br label %25
23: ; preds = %13
%24 = tail call i32 @memset(i32** %17, i32 0, i32 240)
br label %25
25: ; preds = %23, %18
%26 = add i32 %0, 8
%27 = icmp ugt i32 %26, 399
%28 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 2, i64 0
%29 = bitcast [3 x i32]* %28 to i32**
br i1 %27, label %35, label %30
30: ; preds = %25
%31 = zext i32 %26 to i64
%32 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %31, i64 0
%33 = bitcast [3 x i32]* %32 to i32**
%34 = tail call i32 @memcpy(i32** %29, i32** %33, i32 240)
br label %37
35: ; preds = %25
%36 = tail call i32 @memset(i32** %29, i32 0, i32 240)
br label %37
37: ; preds = %35, %30
%38 = add i32 %0, 12
%39 = icmp ugt i32 %38, 399
%40 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 3, i64 0
%41 = bitcast [3 x i32]* %40 to i32**
br i1 %39, label %47, label %42
42: ; preds = %37
%43 = zext i32 %38 to i64
%44 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %43, i64 0
%45 = bitcast [3 x i32]* %44 to i32**
%46 = tail call i32 @memcpy(i32** %41, i32** %45, i32 240)
br label %49
47: ; preds = %37
%48 = tail call i32 @memset(i32** %41, i32 0, i32 240)
br label %49
49: ; preds = %47, %42
%50 = add i32 %0, 16
%51 = icmp ugt i32 %50, 399
%52 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 4, i64 0
%53 = bitcast [3 x i32]* %52 to i32**
br i1 %51, label %59, label %54
54: ; preds = %49
%55 = zext i32 %50 to i64
%56 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %55, i64 0
%57 = bitcast [3 x i32]* %56 to i32**
%58 = tail call i32 @memcpy(i32** %53, i32** %57, i32 240)
br label %61
59: ; preds = %49
%60 = tail call i32 @memset(i32** %53, i32 0, i32 240)
br label %61
61: ; preds = %59, %54
%62 = add i32 %0, 20
%63 = icmp ugt i32 %62, 399
%64 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 5, i64 0
%65 = bitcast [3 x i32]* %64 to i32**
br i1 %63, label %71, label %66
66: ; preds = %61
%67 = zext i32 %62 to i64
%68 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %67, i64 0
%69 = bitcast [3 x i32]* %68 to i32**
%70 = tail call i32 @memcpy(i32** %65, i32** %69, i32 240)
br label %73
71: ; preds = %61
%72 = tail call i32 @memset(i32** %65, i32 0, i32 240)
br label %73
73: ; preds = %71, %66
%74 = add i32 %0, 24
%75 = icmp ugt i32 %74, 399
%76 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 6, i64 0
%77 = bitcast [3 x i32]* %76 to i32**
br i1 %75, label %83, label %78
78: ; preds = %73
%79 = zext i32 %74 to i64
%80 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %79, i64 0
%81 = bitcast [3 x i32]* %80 to i32**
%82 = tail call i32 @memcpy(i32** %77, i32** %81, i32 240)
br label %85
83: ; preds = %73
%84 = tail call i32 @memset(i32** %77, i32 0, i32 240)
br label %85
85: ; preds = %83, %78
%86 = add i32 %0, 28
%87 = icmp ugt i32 %86, 399
%88 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %1, i64 7, i64 0
%89 = bitcast [3 x i32]* %88 to i32**
br i1 %87, label %95, label %90
90: ; preds = %85
%91 = zext i32 %86 to i64
%92 = getelementptr inbounds [80 x [3 x i32]], [80 x [3 x i32]]* %2, i64 %91, i64 0
%93 = bitcast [3 x i32]* %92 to i32**
%94 = tail call i32 @memcpy(i32** %89, i32** %93, i32 240)
br label %97
95: ; preds = %85
%96 = tail call i32 @memset(i32** %89, i32 0, i32 240)
br label %97
97: ; preds = %95, %90
ret void
}