unsigned int sum(unsigned int *llvm_cbe_a, unsigned int llvm_cbe_n) {
  unsigned int *llvm_cbe_tmp__6;
  unsigned int llvm_cbe_tmp__7;
  unsigned int llvm_cbe_sum;
  unsigned int llvm_cbe_i;
  unsigned int llvm_cbe_tmp__8;
  unsigned int llvm_cbe_tmp__9;
  unsigned int llvm_cbe_tmp__10;
  unsigned int llvm_cbe_tmp__11;
  unsigned int llvm_cbe_tmp__12;
  unsigned int llvm_cbe_tmp__13;
  *(&llvm_cbe_tmp__6) = llvm_cbe_a;
  *(&llvm_cbe_tmp__7) = llvm_cbe_n;
  *(&llvm_cbe_sum) = 0u;
  *(&llvm_cbe_i) = 0u;
  goto llvm_cbe_tmp__14;
  do {
  llvm_cbe_tmp__14:
    llvm_cbe_tmp__8 = *(&llvm_cbe_i);
    llvm_cbe_tmp__9 = *(&llvm_cbe_tmp__7);
    if ((((signed int)llvm_cbe_tmp__8) < ((signed int)llvm_cbe_tmp__9))) {
      goto llvm_cbe_tmp__15;
    } else {
      goto llvm_cbe_tmp__16;
    }
  llvm_cbe_tmp__15:
    llvm_cbe_tmp__10 = *(&llvm_cbe_i);
    llvm_cbe_tmp__11 = *(&llvm_cbe_sum);
    *(&llvm_cbe_sum) = (((unsigned int)(((unsigned int)llvm_cbe_tmp__11) +
                                        ((unsigned int)llvm_cbe_tmp__10))));
    llvm_cbe_tmp__12 = *(&llvm_cbe_i);
    *(&llvm_cbe_i) = ((
        (unsigned int)(((unsigned int)llvm_cbe_tmp__12) + ((unsigned int)1u))));
    goto llvm_cbe_tmp__14;
  } while (1);
llvm_cbe_tmp__16:
  llvm_cbe_tmp__13 = *(&llvm_cbe_sum);
  return llvm_cbe_tmp__13;
}


x86 assembly (clang, -O0):
<sum>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1144 <sum+0x44>
jmp    1149 <sum+0x49>
jmp    1172 <sum+0x72>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1127 <sum+0x27>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum>:
test   %esi,%esi
jle    1118 <sum+0x18>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,1),%eax
add    $0xffffffff,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @sum(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%15 = load i32*, i32** %3
store i32* %15, i32** %5
%16 = load i32, i32* %4
store i32 %16, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %19
17: ; No predecessors!
br label %18
18: ; preds = %36, %17
br label %19
19: ; preds = %27, %18, %2
%20 = load i32, i32* %8
store i32 %20, i32* %9
%21 = load i32, i32* %6
store i32 %21, i32* %10
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %19
br label %27
26: ; preds = %19
br label %38
27: ; preds = %25
%28 = load i32, i32* %8
store i32 %28, i32* %11
%29 = load i32, i32* %7
store i32 %29, i32* %12
%30 = load i32, i32* %12
%31 = load i32, i32* %11
%32 = add i32 %30, %31
store i32 %32, i32* %7
%33 = load i32, i32* %8
store i32 %33, i32* %13
%34 = load i32, i32* %13
%35 = add i32 %34, 1
store i32 %35, i32* %8
br label %19
36: ; No predecessors!
br i1 true, label %18, label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %26
%39 = load i32, i32* %7
store i32 %39, i32* %14
%40 = load i32, i32* %14
ret i32 %40
}

LLVM IR (-O2):
define i32 @sum(i32* nocapture readnone %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = zext i32 %5 to i33
%7 = add nsw i32 %1, -2
%8 = zext i32 %7 to i33
%9 = mul i33 %6, %8
%10 = lshr i33 %9, 1
%11 = trunc i33 %10 to i32
%12 = add i32 %11, %1
%13 = add i32 %12, -1
br label %14
14: ; preds = %4, %2
%15 = phi i32 [ 0, %2 ], [ %13, %4 ]
ret i32 %15
}