#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 NumArray {
  int dummy;
};

/* Variables and functions */
struct NumArray *NumArrayCreate(int *, int);
int /*<<< orphan*/ NumArrayFree(struct NumArray *);
int /*<<< orphan*/ printf(char *, int);
int sumRange(struct NumArray *, int, int);
int main(void) {
  int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  struct NumArray *numArray = NumArrayCreate(arr, 10);
  printf("sum of 0 to 1: %d\n", sumRange(numArray, 0, 1));
  printf("sum of 1 to 2: %d\n", sumRange(numArray, 1, 2));
  printf("sum of 1 to 5: %d\n", sumRange(numArray, 1, 5));
  printf("sum of 8 to 9: %d\n", sumRange(numArray, 8, 9));
  NumArrayFree(numArray);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1050 <NumArrayCreate@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <sumRange@plt>
mov    %eax,%esi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <sumRange@plt>
mov    %eax,%esi
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1030 <sumRange@plt>
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    $0x8,%esi
mov    $0x9,%edx
call   1030 <sumRange@plt>
mov    %eax,%esi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1070 <NumArrayFree@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1050 <NumArrayCreate@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <sumRange@plt>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <sumRange@plt>
lea    0xe8d(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1030 <sumRange@plt>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x9,%edx
call   1030 <sumRange@plt>
lea    0xe73(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <NumArrayFree@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.NumArray = type { i32 }
@__const.main.arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [19 x i8] c"sum of 0 to 1: %d\0A\00"
@.str.1 = [19 x i8] c"sum of 1 to 2: %d\0A\00"
@.str.2 = [19 x i8] c"sum of 1 to 5: %d\0A\00"
@.str.3 = [19 x i8] c"sum of 8 to 9: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca %struct.NumArray*
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%6 = call %struct.NumArray* @NumArrayCreate(i32* %5, i32 10)
store %struct.NumArray* %6, %struct.NumArray** %3
%7 = load %struct.NumArray*, %struct.NumArray** %3
%8 = call i32 @sumRange(%struct.NumArray* %7, i32 0, i32 1)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load %struct.NumArray*, %struct.NumArray** %3
%11 = call i32 @sumRange(%struct.NumArray* %10, i32 1, i32 2)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load %struct.NumArray*, %struct.NumArray** %3
%14 = call i32 @sumRange(%struct.NumArray* %13, i32 1, i32 5)
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load %struct.NumArray*, %struct.NumArray** %3
%17 = call i32 @sumRange(%struct.NumArray* %16, i32 8, i32 9)
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load %struct.NumArray*, %struct.NumArray** %3
%20 = call i32 @NumArrayFree(%struct.NumArray* %19)
ret i32 0
}

LLVM IR (-O2):
%struct.NumArray = type { i32 }
@__const.main.arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [19 x i8] c"sum of 0 to 1: %d\0A\00"
@.str.1 = [19 x i8] c"sum of 1 to 2: %d\0A\00"
@.str.2 = [19 x i8] c"sum of 1 to 5: %d\0A\00"
@.str.3 = [19 x i8] c"sum of 8 to 9: %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call %struct.NumArray* @NumArrayCreate(i32* %3, i32 10)
%5 = call i32 @sumRange(%struct.NumArray* %4, i32 0, i32 1)
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @sumRange(%struct.NumArray* %4, i32 1, i32 2)
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @sumRange(%struct.NumArray* %4, i32 1, i32 5)
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @sumRange(%struct.NumArray* %4, i32 8, i32 9)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 @NumArrayFree(%struct.NumArray* %4)
ret i32 0
}