#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 */
scalar_t__ malloc(unsigned long long);
unsigned char *generate_multi_part_message(
    const size_t num_full_parts, const size_t num_bytes_in_final_part,
    const unsigned long num_blocks_in_part, unsigned long long *num_bytes) {
  *num_bytes =
      num_bytes_in_final_part + (num_full_parts * num_blocks_in_part * 16);
  unsigned char *message = (unsigned char *)malloc(*num_bytes);
  for (size_t i = 0; i < *num_bytes; i++) {
    message[i] = i & 0xFF;
  }
  return message;
}


x86 assembly (clang, -O0):
<generate_multi_part_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x4,%rax
add    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
jae    1194 <generate_multi_part_message+0x84>
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    115b <generate_multi_part_message+0x4b>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_multi_part_message>:
push   %rbx
mov    %rcx,%rbx
imul   %rdx,%rdi
shl    $0x4,%rdi
add    %rsi,%rdi
mov    %rdi,(%rcx)
call   1030 <malloc@plt>
cmpq   $0x0,(%rbx)
je     113c <generate_multi_part_message+0x2c>
xor    %ecx,%ecx
nop
mov    %cl,(%rax,%rcx,1)
add    $0x1,%rcx
cmp    (%rbx),%rcx
jb     1130 <generate_multi_part_message+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define i8* @generate_multi_part_message(i64 %0, i64 %1, i64 %2, i64* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64* %3, i64** %8
%11 = load i64, i64* %6
%12 = load i64, i64* %5
%13 = load i64, i64* %7
%14 = mul i64 %12, %13
%15 = mul i64 %14, 16
%16 = add i64 %11, %15
%17 = load i64*, i64** %8
store i64 %16, i64* %17
%18 = load i64*, i64** %8
%19 = load i64, i64* %18
%20 = call i64 @malloc(i64 %19)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %9
store i64 0, i64* %10
br label %22
22: ; preds = %34, %4
%23 = load i64, i64* %10
%24 = load i64*, i64** %8
%25 = load i64, i64* %24
%26 = icmp ult i64 %23, %25
br i1 %26, label %27, label %37
27: ; preds = %22
%28 = load i64, i64* %10
%29 = and i64 %28, 255
%30 = trunc i64 %29 to i8
%31 = load i8*, i8** %9
%32 = load i64, i64* %10
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8 %30, i8* %33
br label %34
34: ; preds = %27
%35 = load i64, i64* %10
%36 = add i64 %35, 1
store i64 %36, i64* %10
br label %22
37: ; preds = %22
%38 = load i8*, i8** %9
ret i8* %38
}

LLVM IR (-O2):
define i8* @generate_multi_part_message(i64 %0, i64 %1, i64 %2, i64* nocapture %3) {
%5 = shl i64 %0, 4
%6 = mul i64 %5, %2
%7 = add i64 %6, %1
store i64 %7, i64* %3
%8 = tail call i64 @malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %13, %4
ret i8* %9
13: ; preds = %4, %13
%14 = phi i64 [ %17, %13 ], [ 0, %4 ]
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds i8, i8* %9, i64 %14
store i8 %15, i8* %16
%17 = add nuw i64 %14, 1
%18 = load i64, i64* %3
%19 = icmp ult i64 %17, %18
br i1 %19, label %13, label %12
}