#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*/ abort();
int first_(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ is_f_(int);
int rest_(int);
int /*<<< orphan*/ stderr;
int at_(int list, int i) {
  if (is_f_(list)) {
    fputs("Array out of range!\n", stderr);
    abort();
  };
  return i > 0 ? at_(rest_(list), i - 1) : first_(list);
}


x86 assembly (clang, -O0):
<at_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <is_f_@plt>
cmp    $0x0,%rax
je     119c <at_+0x3c>
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11c3 <at_+0x63>
mov    -0x4(%rbp),%edi
call   1070 <rest_@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <at_@plt>
mov    %eax,-0xc(%rbp)
jmp    11ce <at_+0x6e>
mov    -0x4(%rbp),%edi
call   1040 <first_@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at_>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1070 <is_f_@plt>
test   %rax,%rax
jne    118c <at_+0x3c>
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebx
mov    %ebp,%edi
test   %ebx,%ebx
jle    11a8 <at_+0x58>
call   1060 <rest_@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <is_f_@plt>
test   %rax,%rax
je     1170 <at_+0x20>
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <first_@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Array out of range!\0A\00"
@stderr = global i32 0
define i32 @at_(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i64 @is_f_(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* %3
%17 = call i32 @rest_(i32 %16)
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = call i32 @at_(i32 %17, i32 %19)
br label %24
21: ; preds = %12
%22 = load i32, i32* %3
%23 = call i32 @first_(i32 %22)
br label %24
24: ; preds = %21, %15
%25 = phi i32 [ %20, %15 ], [ %23, %21 ]
ret i32 %25
}

LLVM IR (-O2):
@.str = [21 x i8] c"Array out of range!\0A\00"
@stderr = global i32 0
define i32 @at_(i32 %0, i32 %1) {
%3 = tail call i64 @is_f_(i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %13, %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %2, %13
%10 = phi i32 [ %15, %13 ], [ %1, %2 ]
%11 = phi i32 [ %14, %13 ], [ %0, %2 ]
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = tail call i32 @rest_(i32 %11)
%15 = add nsw i32 %10, -1
%16 = tail call i64 @is_f_(i32 %14)
%17 = icmp eq i64 %16, 0
br i1 %17, label %9, label %5
18: ; preds = %9
%19 = tail call i32 @first_(i32 %11)
ret i32 %19
}