#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 uint8_t;

/* Variables and functions */
int checksum(int *);
int createErasePack(uint8_t *pack, uint8_t tipe) {
  uint8_t ptr = 0;
  pack[ptr++] = 0x07;
  pack[ptr++] = 0x0E;
  pack[ptr++] = 1;
  pack[ptr++] = tipe ? 'C' : 'A';
  pack[ptr++] = checksum(&pack[2]);
  return ptr;
}


x86 assembly (clang, -O0):
<createErasePack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
movslq %ecx,%rcx
movl   $0x7,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
movslq %ecx,%rcx
movl   $0xe,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0xc(%rbp),%ecx
mov    $0x41,%edx
mov    $0x43,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1030 <checksum@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createErasePack>:
push   %rbx
mov    %rdi,%rbx
movabs $0xe00000007,%rax
mov    %rax,(%rdi)
add    $0x8,%rdi
movl   $0x1,0x8(%rbx)
xor    %eax,%eax
test   %esi,%esi
setne  %al
add    %eax,%eax
add    $0x41,%eax
mov    %eax,0xc(%rbx)
call   1030 <checksum@plt>
mov    %eax,0x10(%rbx)
mov    $0x5,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @createErasePack(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32*, i32** %3
%7 = load i32, i32* %5
%8 = add nsw i32 %7, 1
store i32 %8, i32* %5
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds i32, i32* %6, i64 %9
store i32 7, i32* %10
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
store i32 %13, i32* %5
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i32, i32* %11, i64 %14
store i32 14, i32* %15
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i32, i32* %16, i64 %19
store i32 1, i32* %20
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 67, i32 65
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
store i32 %24, i32* %29
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = call i32 @checksum(i32* %31)
%33 = load i32*, i32** %3
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i32, i32* %33, i64 %36
store i32 %32, i32* %37
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @createErasePack(i32* %0, i32 %1) {
store i32 7, i32* %0
%3 = getelementptr inbounds i32, i32* %0, i64 1
store i32 14, i32* %3
%4 = getelementptr inbounds i32, i32* %0, i64 2
store i32 1, i32* %4
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i32 65, i32 67
%7 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %6, i32* %7
%8 = tail call i32 @checksum(i32* %4)
%9 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %8, i32* %9
ret i32 5
}