#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ manipulateStream(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ processStream(char *, int);
int main() {
  char *stream;
  int i;
  printf("Starting test program\n");
  stream = malloc(100 * sizeof(char));
  if (stream == NULL) {
    printf("malloc() failed\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 100; i++) {
    stream[i] = i;
  }
  processStream(stream, 100);
  manipulateStream(stream, 100);
  free(stream);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <main+0x4e>
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11dd <main+0x7d>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <main+0x55>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1070 <processStream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1040 <manipulateStream@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xef8(%rip),%rdi
call   1050 <puts@plt>
mov    $0x64,%edi
call   1060 <malloc@plt>
test   %rax,%rax
jne    1196 <main+0x36>
lea    0xef3(%rip),%rdi
call   1050 <puts@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rax,%rbx
movaps 0xe60(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe66(%rip),%xmm0
movups %xmm0,0x10(%rax)
movaps 0xe6b(%rip),%xmm0
movups %xmm0,0x20(%rax)
movaps 0xe70(%rip),%xmm0
movups %xmm0,0x30(%rax)
movaps 0xe75(%rip),%xmm0
movups %xmm0,0x40(%rax)
movaps 0xe7a(%rip),%xmm0
movups %xmm0,0x50(%rax)
movl   $0x63626160,0x60(%rax)
mov    %rax,%rdi
mov    $0x64,%esi
call   1070 <processStream@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <manipulateStream@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Starting test program\0A\00"
@.str.1 = [17 x i8] c"malloc() failed\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i8* @malloc(i32 100)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
store i32 0, i32* %3
br label %13
13: ; preds = %23, %12
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32, i32* %3
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %13
26: ; preds = %13
%27 = load i8*, i8** %2
%28 = call i32 @processStream(i8* %27, i32 100)
%29 = load i8*, i8** %2
%30 = call i32 @manipulateStream(i8* %29, i32 100)
%31 = load i8*, i8** %2
%32 = call i32 @free(i8* %31)
%33 = load i32, i32* @EXIT_SUCCESS
%34 = call i32 @exit(i32 %33)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"Starting test program\00"
@str.2 = [16 x i8] c"malloc() failed\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%3 = icmp eq i8* %2, null
br i1 %3, label %25, label %4
4: ; preds = %0
%5 = bitcast i8* %2 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %5
%6 = getelementptr inbounds i8, i8* %2, i64 16
%7 = bitcast i8* %6 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %7
%8 = getelementptr inbounds i8, i8* %2, i64 32
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %9
%10 = getelementptr inbounds i8, i8* %2, i64 48
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %11
%12 = getelementptr inbounds i8, i8* %2, i64 64
%13 = bitcast i8* %12 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %13
%14 = getelementptr inbounds i8, i8* %2, i64 80
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %15
%16 = getelementptr inbounds i8, i8* %2, i64 96
store i8 96, i8* %16
%17 = getelementptr inbounds i8, i8* %2, i64 97
store i8 97, i8* %17
%18 = getelementptr inbounds i8, i8* %2, i64 98
store i8 98, i8* %18
%19 = getelementptr inbounds i8, i8* %2, i64 99
store i8 99, i8* %19
%20 = tail call i32 @processStream(i8* %2, i32 100)
%21 = tail call i32 @manipulateStream(i8* %2, i32 100)
%22 = tail call i32 @free(i8* %2)
%23 = load i32, i32* @EXIT_SUCCESS
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %0
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
}