#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void stk_vars(const char *instr, int wreg, int stkptr, int temp, int fsr,
              int base, int *mem) {
  fprintf(stderr,
          "after '%s'\nWREG=0x%02X STKPTR=0x%02X temp=0x%02X FSR=0x%04X\n",
          instr, wreg, stkptr, temp, fsr);
  if (mem) {
    int i;
    fprintf(stderr, " [0x%04X] ", base);
    for (i = 0; i < 30; i++)
      if (i == fsr - base)
        fprintf(stderr, "<%02x>", mem[i] & 0xff);
      else
        fprintf(stderr, " %02x ", mem[i] & 0xff);
    fprintf(stderr, " [0x%04X]\n", base + 29);
  }
}


x86 assembly (clang, -O0):
<stk_vars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0xead(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,0x10(%rbp)
je     1229 <stk_vars+0x119>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x1e,-0x20(%rbp)
jge    120c <stk_vars+0xfc>
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jne    11d1 <stk_vars+0xc1>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
and    $0xff,%edx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11f9 <stk_vars+0xe9>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
and    $0xff,%edx
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11fe <stk_vars+0xee>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1189 <stk_vars+0x79>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
add    $0x1d,%edx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stk_vars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r14d
mov    %r8d,%ebx
mov    %ecx,%r9d
mov    %edx,%r8d
mov    %esi,%ecx
mov    %rdi,%rdx
mov    0x50(%rsp),%rbp
mov    0x2ea5(%rip),%r15
mov    (%r15),%edi
mov    %ebx,(%rsp)
lea    0xeb8(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %rbp,%rbp
je     11da <stk_vars+0xca>
mov    (%r15),%edi
lea    0xedb(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14d,0x14(%rsp)
sub    %r14d,%ebx
lea    0xecd(%rip),%r12
lea    0xecd(%rip),%r13
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r14,%rbx
mov    (%r15),%edi
mov    %r13,%rsi
cmove  %r12,%rsi
movzbl 0x0(%rbp,%r14,4),%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r14
cmp    $0x1e,%r14
jne    1190 <stk_vars+0x80>
mov    (%r15),%edi
mov    0x14(%rsp),%edx
add    $0x1d,%edx
lea    0xe91(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"after '%s'\0AWREG=0x%02X STKPTR=0x%02X temp=0x%02X FSR=0x%04X\0A\00"
@.str.1 = [11 x i8] c" [0x%04X] \00"
@.str.2 = [7 x i8] c"<%02x>\00"
@.str.3 = [7 x i8] c" %02x \00"
@.str.4 = [11 x i8] c" [0x%04X]\0A\00"
define void @stk_vars(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32* %6, i32** %14
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %8
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18, i32 %19, i32 %20, i32 %21)
%23 = load i32*, i32** %14
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %65
25: ; preds = %7
%26 = load i32, i32* @stderr
%27 = load i32, i32* %13
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %27)
store i32 0, i32* %15
br label %29
29: ; preds = %57, %25
%30 = load i32, i32* %15
%31 = icmp slt i32 %30, 30
br i1 %31, label %32, label %60
32: ; preds = %29
%33 = load i32, i32* %15
%34 = load i32, i32* %12
%35 = load i32, i32* %13
%36 = sub nsw i32 %34, %35
%37 = icmp eq i32 %33, %36
br i1 %37, label %38, label %47
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = load i32*, i32** %14
%41 = load i32, i32* %15
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = and i32 %44, 255
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %56
47: ; preds = %32
%48 = load i32, i32* @stderr
%49 = load i32*, i32** %14
%50 = load i32, i32* %15
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = and i32 %53, 255
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %47, %38
br label %57
57: ; preds = %56
%58 = load i32, i32* %15
%59 = add nsw i32 %58, 1
store i32 %59, i32* %15
br label %29
60: ; preds = %29
%61 = load i32, i32* @stderr
%62 = load i32, i32* %13
%63 = add nsw i32 %62, 29
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %60, %7
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"after '%s'\0AWREG=0x%02X STKPTR=0x%02X temp=0x%02X FSR=0x%04X\0A\00"
@.str.1 = [11 x i8] c" [0x%04X] \00"
@.str.2 = [7 x i8] c"<%02x>\00"
@.str.3 = [7 x i8] c" %02x \00"
@.str.4 = [11 x i8] c" [0x%04X]\0A\00"
define void @stk_vars(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %2, i32 %3, i32 %4)
%10 = icmp eq i32* %6, null
br i1 %10, label %31, label %11
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%14 = sub nsw i32 %4, %5
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %11, %16
%17 = phi i64 [ 0, %11 ], [ %25, %16 ]
%18 = icmp eq i64 %17, %15
%19 = load i32, i32* @stderr
%20 = getelementptr inbounds i32, i32* %6, i64 %17
%21 = select i1 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%22 = load i32, i32* %20
%23 = and i32 %22, 255
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* %21, i32 %23)
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, 30
br i1 %26, label %27, label %16
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = add nsw i32 %5, 29
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %27, %7
ret void
}