#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*/ fhandle_printf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ file_unix_getstderr();
void occampi_debug_gstack(void **items, int icnt) {
  int i;
  fhandle_printf((file_unix_getstderr()),
                 "occampi_debug_gstack(): icnt=%d, items:  ", icnt);
  for (i = 0; i < icnt; i++) {
    fhandle_printf((file_unix_getstderr()), "%p  ", items[i]);
  }
  fhandle_printf((file_unix_getstderr()), "\n");
  return;
}


x86 assembly (clang, -O0):
<occampi_debug_gstack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <file_unix_getstderr@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%edx
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1040 <fhandle_printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <occampi_debug_gstack+0x6d>
mov    $0x0,%al
call   1030 <file_unix_getstderr@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fhandle_printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1150 <occampi_debug_gstack+0x30>
mov    $0x0,%al
call   1030 <file_unix_getstderr@plt>
mov    %eax,%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <fhandle_printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<occampi_debug_gstack>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <file_unix_getstderr@plt>
lea    0xec6(%rip),%rsi
mov    %eax,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fhandle_printf@plt>
test   %ebp,%ebp
jle    1180 <occampi_debug_gstack+0x60>
mov    %ebp,%ebp
lea    0xed8(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <file_unix_getstderr@plt>
mov    (%r15,%rbx,8),%rdx
mov    %eax,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fhandle_printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <occampi_debug_gstack+0x40>
xor    %eax,%eax
call   1030 <file_unix_getstderr@plt>
lea    0xea1(%rip),%rsi
mov    %eax,%edi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fhandle_printf@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"occampi_debug_gstack(): icnt=%d, items: \00"
@.str.1 = [5 x i8] c"%p \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @occampi_debug_gstack(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = call i32 (...) @file_unix_getstderr()
%7 = load i32, i32* %4
%8 = call i32 (i32, i8*, ...) @fhandle_printf(i32 %6, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %5
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = call i32 (...) @file_unix_getstderr()
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fhandle_printf(i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %9
24: ; preds = %9
%25 = call i32 (...) @file_unix_getstderr()
%26 = call i32 (i32, i8*, ...) @fhandle_printf(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"occampi_debug_gstack(): icnt=%d, items: \00"
@.str.1 = [5 x i8] c"%p \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @occampi_debug_gstack(i8** nocapture %0, i32 %1) {
%3 = tail call i32 (...) @file_unix_getstderr()
%4 = tail call i32 (i32, i8*, ...) @fhandle_printf(i32 %3, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = tail call i32 (...) @file_unix_getstderr()
%11 = getelementptr inbounds i8*, i8** %0, i64 %9
%12 = load i8*, i8** %11
%13 = tail call i32 (i32, i8*, ...) @fhandle_printf(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %2
%17 = tail call i32 (...) @file_unix_getstderr()
%18 = tail call i32 (i32, i8*, ...) @fhandle_printf(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}