#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*/ _longadd(int /*<<< orphan*/, unsigned int *);
unsigned _longarrayadd(unsigned *uarray, int lg, unsigned incr) {
  for (; lg-- > 0 && incr != 0;)
    _longadd(uarray++, &incr);
  return incr;
}


x86 assembly (clang, -O0):
<_longarrayadd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jle    1145 <_longarrayadd+0x35>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1155 <_longarrayadd+0x45>
jmp    1174 <_longarrayadd+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1030 <_longadd@plt>
jmp    1122 <_longarrayadd+0x12>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_longarrayadd>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%eax
mov    %edx,0xc(%rsp)
test   %esi,%esi
jle    114d <_longarrayadd+0x3d>
test   %eax,%eax
je     114d <_longarrayadd+0x3d>
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xc(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_longadd@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%ebp
jb     114d <_longarrayadd+0x3d>
add    $0xffffffff,%ebp
add    $0x4,%ebx
test   %eax,%eax
jne    1130 <_longarrayadd+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_longarrayadd(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
br label %7
7: ; preds = %16, %3
%8 = load i32, i32* %5
%9 = add nsw i32 %8, -1
store i32 %9, i32* %5
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br label %14
14: ; preds = %11, %7
%15 = phi i1 [ false, %7 ], [ %13, %11 ]
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i32 1
store i32* %18, i32** %4
%19 = ptrtoint i32* %17 to i32
%20 = call i32 @_longadd(i32 %19, i32* %6)
br label %7
21: ; preds = %14
%22 = load i32, i32* %6
ret i32 %22
}

LLVM IR (-O2):
define i32 @_longarrayadd(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = icmp sgt i32 %1, 0
%6 = icmp ne i32 %2, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %20
8: ; preds = %3, %8
%9 = phi i32 [ %11, %8 ], [ %1, %3 ]
%10 = phi i32* [ %12, %8 ], [ %0, %3 ]
%11 = add nsw i32 %9, -1
%12 = getelementptr inbounds i32, i32* %10, i64 1
%13 = ptrtoint i32* %10 to i64
%14 = trunc i64 %13 to i32
%15 = call i32 @_longadd(i32 %14, i32* %4)
%16 = icmp ugt i32 %9, 1
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %8, label %20
20: ; preds = %8, %3
%21 = phi i32 [ %2, %3 ], [ %17, %8 ]
ret i32 %21
}