#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 lobject {
  int dummy;
};
struct lframe {
  int dummy;
};
struct lemon {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lframe_set_item(struct lemon *, struct lframe *, int,
                                   struct lobject *);
void shell_restore_frame(struct lemon *lemon, struct lframe *frame, int nlocals,
                         struct lobject *locals[]) {
  int i;
  for (i = 0; i < nlocals; i++) {
    lframe_set_item(lemon, frame, i, locals[i]);
  }
}


x86 assembly (clang, -O0):
<shell_restore_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1164 <shell_restore_frame+0x54>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
call   1030 <lframe_set_item@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112e <shell_restore_frame+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_restore_frame>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    114a <shell_restore_frame+0x3a>
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <lframe_set_item@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1130 <shell_restore_frame+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.lemon = type { i32 }
%struct.lframe = type { i32 }
%struct.lobject = type { i32 }
define void @shell_restore_frame(%struct.lemon* %0, %struct.lframe* %1, i32 %2, %struct.lobject** %3) {
%5 = alloca %struct.lemon*
%6 = alloca %struct.lframe*
%7 = alloca i32
%8 = alloca %struct.lobject**
%9 = alloca i32
store %struct.lemon* %0, %struct.lemon** %5
store %struct.lframe* %1, %struct.lframe** %6
store i32 %2, i32* %7
store %struct.lobject** %3, %struct.lobject*** %8
store i32 0, i32* %9
br label %10
10: ; preds = %24, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load %struct.lemon*, %struct.lemon** %5
%16 = load %struct.lframe*, %struct.lframe** %6
%17 = load i32, i32* %9
%18 = load %struct.lobject**, %struct.lobject*** %8
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds %struct.lobject*, %struct.lobject** %18, i64 %20
%22 = load %struct.lobject*, %struct.lobject** %21
%23 = call i32 @lframe_set_item(%struct.lemon* %15, %struct.lframe* %16, i32 %17, %struct.lobject* %22)
br label %24
24: ; preds = %14
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %10
27: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.lemon = type { i32 }
%struct.lframe = type { i32 }
%struct.lobject = type { i32 }
define void @shell_restore_frame(%struct.lemon* %0, %struct.lframe* %1, i32 %2, %struct.lobject** nocapture %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = getelementptr inbounds %struct.lobject*, %struct.lobject** %3, i64 %9
%11 = load %struct.lobject*, %struct.lobject** %10
%12 = trunc i64 %9 to i32
%13 = tail call i32 @lframe_set_item(%struct.lemon* %0, %struct.lframe* %1, i32 %12, %struct.lobject* %11)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %4
ret void
}