#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 slist {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int ntohl(int const);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ slist_back(struct slist *, char const **, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *);
scalar_t__ slist_pop_back(struct slist *);
void pop_back_erase(struct slist *slist, int range) {
  int i;
  for (i = 0; i < range; ++i) {
    const char *key;
    assert(slist_back(slist, &key, NULL, NULL) == 0);
    int n = ntohl(*(const int *)key);
    assert(slist_pop_back(slist) == 0);
    printf("pop_back_erase=%d\n", n);
  }
}


x86 assembly (clang, -O0):
<pop_back_erase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dc <pop_back_erase+0x8c>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1060 <slist_back@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1070 <ntohl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <slist_pop_back@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x1c(%rbp),%esi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <pop_back_erase+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pop_back_erase>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    11d0 <pop_back_erase+0x80>
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x8(%rsp),%r15
lea    0xe8f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <slist_back@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%edi
call   1070 <ntohl@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <slist_pop_back@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1180 <pop_back_erase+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.slist = type { i32 }
@.str = [19 x i8] c"pop_back_erase=%d\0A\00"
define void @pop_back_erase(%struct.slist* %0, i32 %1) {
%3 = alloca %struct.slist*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store %struct.slist* %0, %struct.slist** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load %struct.slist*, %struct.slist** %3
%14 = call i64 @slist_back(%struct.slist* %13, i8** %6, i32* null, i32* null)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %6
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
%21 = call i32 @ntohl(i32 %20)
store i32 %21, i32* %7
%22 = load %struct.slist*, %struct.slist** %3
%23 = call i64 @slist_pop_back(%struct.slist* %22)
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %7
%28 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %12
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.slist = type { i32 }
@.str = [19 x i8] c"pop_back_erase=%d\0A\00"
define void @pop_back_erase(%struct.slist* %0, i32 %1) {
%3 = alloca i8*
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %3 to i32**
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ 0, %5 ], [ %22, %8 ]
%10 = call i64 @slist_back(%struct.slist* %0, i8** %3, i32* null, i32* null)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = call i32 @ntohl(i32 %15)
%17 = call i64 @slist_pop_back(%struct.slist* %0)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %16)
%22 = add nuw nsw i32 %9, 1
%23 = icmp eq i32 %22, %1
br i1 %23, label %24, label %8
24: ; preds = %8, %2
ret void
}