#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 Funnel {
  int dummy;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, scalar_t__);
void *storage_get(struct Funnel *);
int /*<<< orphan*/ storage_pop(struct Funnel *);
void storage_printer(struct Funnel *f) {
  void *prev = NULL;
  void *next = NULL;
  do {
    prev = storage_get(f);
    if (!prev)
      break;
    printf("%zd, ", *(int64_t *)prev);
    storage_pop(f);
    if (next)
      assert(*(int64_t *)prev >= *(int64_t *)next);
    next = prev;
  } while (prev);
}


x86 assembly (clang, -O0):
<storage_printer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <storage_get@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1179 <storage_printer+0x39>
jmp    11ce <storage_printer+0x8e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <storage_pop@plt>
cmpq   $0x0,-0x18(%rbp)
je     11bb <storage_printer+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <storage_printer+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<storage_printer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1040 <storage_get@plt>
test   %rax,%rax
je     119f <storage_printer+0x5f>
xor    %ebx,%ebx
lea    0xea2(%rip),%r14
jmp    1170 <storage_printer+0x30>
mov    %r15,%rdi
call   1040 <storage_get@plt>
mov    %r12,%rbx
test   %rax,%rax
je     119f <storage_printer+0x5f>
mov    %rax,%r12
mov    (%rax),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <storage_pop@plt>
test   %rbx,%rbx
je     1160 <storage_printer+0x20>
mov    (%r12),%rax
xor    %edi,%edi
cmp    (%rbx),%rax
setge  %dil
call   1060 <assert@plt>
jmp    1160 <storage_printer+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Funnel = type { i32 }
@.str = [6 x i8] c"%zd, \00"
define void @storage_printer(%struct.Funnel* %0) {
%2 = alloca %struct.Funnel*
%3 = alloca i8*
%4 = alloca i8*
store %struct.Funnel* %0, %struct.Funnel** %2
store i8* null, i8** %3
store i8* null, i8** %4
br label %5
5: ; preds = %32, %1
%6 = load %struct.Funnel*, %struct.Funnel** %2
%7 = call i8* @storage_get(%struct.Funnel* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %5
br label %35
11: ; preds = %5
%12 = load i8*, i8** %3
%13 = bitcast i8* %12 to i64*
%14 = load i64, i64* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %14)
%16 = load %struct.Funnel*, %struct.Funnel** %2
%17 = call i32 @storage_pop(%struct.Funnel* %16)
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %30
20: ; preds = %11
%21 = load i8*, i8** %3
%22 = bitcast i8* %21 to i64*
%23 = load i64, i64* %22
%24 = load i8*, i8** %4
%25 = bitcast i8* %24 to i64*
%26 = load i64, i64* %25
%27 = icmp sge i64 %23, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
br label %30
30: ; preds = %20, %11
%31 = load i8*, i8** %3
store i8* %31, i8** %4
br label %32
32: ; preds = %30
%33 = load i8*, i8** %3
%34 = icmp ne i8* %33, null
br i1 %34, label %5, label %35
35: ; preds = %32, %10
ret void
}

LLVM IR (-O2):
%struct.Funnel = type { i32 }
@.str = [6 x i8] c"%zd, \00"
define void @storage_printer(%struct.Funnel* %0) {
%2 = tail call i8* @storage_get(%struct.Funnel* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %22, label %4
4: ; preds = %1, %19
%5 = phi i8* [ %20, %19 ], [ %2, %1 ]
%6 = phi i8* [ %5, %19 ], [ null, %1 ]
%7 = bitcast i8* %5 to i64*
%8 = load i64, i64* %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = tail call i32 @storage_pop(%struct.Funnel* %0)
%11 = icmp eq i8* %6, null
br i1 %11, label %19, label %12
12: ; preds = %4
%13 = load i64, i64* %7
%14 = bitcast i8* %6 to i64*
%15 = load i64, i64* %14
%16 = icmp sge i64 %13, %15
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
br label %19
19: ; preds = %12, %4
%20 = tail call i8* @storage_get(%struct.Funnel* %0)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %4
22: ; preds = %19, %1
ret void
}