#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*/ err(int, char *);
void inc_uiarr(unsigned int *a, size_t n) {
  size_t i;
  for (i = n - 1; i >= 0; i--) {
    a[i]++;
    if (a[i] != 0)
      break;
    if (i == 0)
      err(1, "Serial has become too big!");
  }
}


x86 assembly (clang, -O0):
<inc_uiarr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jb     1191 <inc_uiarr+0x81>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     115f <inc_uiarr+0x4f>
jmp    1191 <inc_uiarr+0x81>
cmpq   $0x0,-0x18(%rbp)
jne    117b <inc_uiarr+0x6b>
mov    $0x1,%edi
lea    0xe8a(%rip),%rsi
call   1030 <err@plt>
jmp    1180 <inc_uiarr+0x70>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <inc_uiarr+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inc_uiarr>:
push   %r15
push   %r14
push   %rbx
addl   $0x1,-0x4(%rdi,%rsi,4)
jne    1151 <inc_uiarr+0x41>
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xed7(%rip),%r15
jmp    113c <inc_uiarr+0x2c>
nopl   0x0(%rax,%rax,1)
addl   $0x1,-0x8(%r14,%rbx,4)
lea    -0x1(%rbx),%rbx
jne    1151 <inc_uiarr+0x41>
cmp    $0x1,%rbx
jne    1130 <inc_uiarr+0x20>
mov    $0x1,%edi
mov    %r15,%rsi
call   1030 <err@plt>
jmp    1130 <inc_uiarr+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Serial has become too big!\00"
define void @inc_uiarr(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = sub i64 %6, 1
store i64 %7, i64* %5
br label %8
8: ; preds = %29, %2
%9 = load i64, i64* %5
%10 = icmp uge i64 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i64, i64* %5
%14 = getelementptr inbounds i32, i32* %12, i64 %13
%15 = load i32, i32* %14
%16 = add i32 %15, 1
store i32 %16, i32* %14
%17 = load i32*, i32** %3
%18 = load i64, i64* %5
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = load i32, i32* %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %11
br label %32
23: ; preds = %11
%24 = load i64, i64* %5
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @err(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
br label %29
29: ; preds = %28
%30 = load i64, i64* %5
%31 = add i64 %30, -1
store i64 %31, i64* %5
br label %8
32: ; preds = %22, %8
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Serial has become too big!\00"
define void @inc_uiarr(i32* nocapture %0, i64 %1) {
%3 = add i64 %1, -1
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
%6 = add i32 %5, 1
store i32 %6, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %2, %13
%9 = phi i64 [ %14, %13 ], [ %3, %2 ]
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %8, %11
%14 = add i64 %9, -1
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = add i32 %16, 1
store i32 %17, i32* %15
%18 = icmp eq i32 %17, 0
br i1 %18, label %8, label %19
19: ; preds = %13, %2
ret void
}