#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 */
void burn_stack(int bytes) {
  char buf[128];
  do {
    volatile char *_vptr = (volatile char *)(buf);
    size_t _vlen = (sizeof buf);
    while (_vlen) {
      *_vptr = (0);
      _vptr++;
      _vlen--;
    }
  } while (0);
  bytes -= sizeof buf;
  if (bytes > 0)
    burn_stack(bytes);
}


x86 assembly (clang, -O0):
<burn_stack>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
movq   $0x80,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
je     1178 <burn_stack+0x68>
mov    -0x98(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
mov    -0xa0(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0xa0(%rbp)
jmp    1137 <burn_stack+0x27>
jmp    117d <burn_stack+0x6d>
movslq -0x4(%rbp),%rax
sub    $0x80,%rax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    119c <burn_stack+0x8c>
mov    -0x4(%rbp),%edi
call   1030 <burn_stack@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<burn_stack>:
push   %rax
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,-0x80(%rsp,%rax,1)
movb   $0x0,-0x7f(%rsp,%rax,1)
movb   $0x0,-0x7e(%rsp,%rax,1)
movb   $0x0,-0x7d(%rsp,%rax,1)
movb   $0x0,-0x7c(%rsp,%rax,1)
movb   $0x0,-0x7b(%rsp,%rax,1)
movb   $0x0,-0x7a(%rsp,%rax,1)
movb   $0x0,-0x79(%rsp,%rax,1)
add    $0x8,%rax
cmp    $0x80,%rax
jne    1120 <burn_stack+0x10>
add    $0xffffff80,%edi
test   %edi,%edi
jle    1161 <burn_stack+0x51>
pop    %rax
jmp    1030 <burn_stack@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @burn_stack(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca i8*
%5 = alloca i64
store i32 %0, i32* %2
br label %6
6: ; preds = %1
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
store i8* %7, i8** %4
store i64 128, i64* %5
br label %8
8: ; preds = %11, %6
%9 = load i64, i64* %5
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load i8*, i8** %4
store volatile i8 0, i8* %12
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
%15 = load i64, i64* %5
%16 = add i64 %15, -1
store i64 %16, i64* %5
br label %8
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = sub i64 %20, 128
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = load i32, i32* %2
br label %27
27: ; preds = %25, %18
ret void
}

LLVM IR (-O2):
define void @burn_stack(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 128, %1 ], [ %15, %4 ]
%6 = phi i8* [ %3, %1 ], [ %14, %4 ]
store volatile i8 0, i8* %6
%7 = getelementptr inbounds i8, i8* %6, i64 1
store volatile i8 0, i8* %7
%8 = getelementptr inbounds i8, i8* %6, i64 2
store volatile i8 0, i8* %8
%9 = getelementptr inbounds i8, i8* %6, i64 3
store volatile i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %6, i64 4
store volatile i8 0, i8* %10
%11 = getelementptr inbounds i8, i8* %6, i64 5
store volatile i8 0, i8* %11
%12 = getelementptr inbounds i8, i8* %6, i64 6
store volatile i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %6, i64 7
store volatile i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %6, i64 8
%15 = add nsw i64 %5, -8
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %4
%18 = add i32 %0, -128
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
tail call void @burn_stack(i32 %18)
br label %21
21: ; preds = %20, %17
ret void
}