#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*/ callrts(char *);
int getlabel();
int /*<<< orphan*/ loadargc(int);
int /*<<< orphan*/ nl();
int /*<<< orphan*/ ol(char *);
int /*<<< orphan*/ outstr(char *);
int /*<<< orphan*/ postlabel(int);
int /*<<< orphan*/ printlabel(int);
void callstk(int n) {
  if (n == 2) {
    int label = getlabel();
    ol("pop\tde");
    outstr("\tld\tbc,");
    printlabel(label);
    nl();
    ol("push\thl");
    ol("push\tbc");
    ol("push\tde");
    loadargc(n);
    ol("ret");
    postlabel(label);
  } else {
    loadargc(n);
    callrts("l_jphl");
  }
}


x86 assembly (clang, -O0):
<callstk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    120b <callstk+0x8b>
mov    $0x0,%al
call   1060 <getlabel@plt>
mov    %eax,-0x8(%rbp)
lea    0xe5a(%rip),%rdi
call   1090 <ol@plt>
lea    0xe55(%rip),%rdi
call   1050 <outstr@plt>
mov    -0x8(%rbp),%edi
call   10a0 <printlabel@plt>
mov    $0x0,%al
call   1040 <nl@plt>
lea    0xe42(%rip),%rdi
call   1090 <ol@plt>
lea    0xe3e(%rip),%rdi
call   1090 <ol@plt>
lea    0xe3a(%rip),%rdi
call   1090 <ol@plt>
mov    -0x4(%rbp),%edi
call   1070 <loadargc@plt>
lea    0xe2e(%rip),%rdi
call   1090 <ol@plt>
mov    -0x8(%rbp),%edi
call   1030 <postlabel@plt>
jmp    121f <callstk+0x9f>
mov    -0x4(%rbp),%edi
call   1070 <loadargc@plt>
lea    0xe11(%rip),%rdi
call   1080 <callrts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callstk>:
push   %rbx
cmp    $0x2,%edi
jne    11f7 <callstk+0x77>
xor    %eax,%eax
call   1060 <getlabel@plt>
mov    %eax,%ebx
lea    0xe6a(%rip),%rdi
call   1090 <ol@plt>
lea    0xe65(%rip),%rdi
call   1050 <outstr@plt>
mov    %ebx,%edi
call   10a0 <printlabel@plt>
xor    %eax,%eax
call   1040 <nl@plt>
lea    0xe53(%rip),%rdi
call   1090 <ol@plt>
lea    0xe4f(%rip),%rdi
call   1090 <ol@plt>
lea    0xe4b(%rip),%rdi
call   1090 <ol@plt>
mov    $0x2,%edi
call   1070 <loadargc@plt>
lea    0xe3d(%rip),%rdi
call   1090 <ol@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <postlabel@plt>
call   1070 <loadargc@plt>
lea    0xe28(%rip),%rdi
pop    %rbx
jmp    1080 <callrts@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"pop\09de\00"
@.str.1 = [8 x i8] c"\09ld\09bc,\00"
@.str.2 = [8 x i8] c"push\09hl\00"
@.str.3 = [8 x i8] c"push\09bc\00"
@.str.4 = [8 x i8] c"push\09de\00"
@.str.5 = [4 x i8] c"ret\00"
@.str.6 = [7 x i8] c"l_jphl\00"
define void @callstk(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = call i32 (...) @getlabel()
store i32 %7, i32* %3
%8 = call i32 @ol(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @outstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = call i32 @printlabel(i32 %10)
%12 = call i32 (...) @nl()
%13 = call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = call i32 @loadargc(i32 %16)
%18 = call i32 @ol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = call i32 @postlabel(i32 %19)
br label %25
21: ; preds = %1
%22 = load i32, i32* %2
%23 = call i32 @loadargc(i32 %22)
%24 = call i32 @callrts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %21, %6
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"pop\09de\00"
@.str.1 = [8 x i8] c"\09ld\09bc,\00"
@.str.2 = [8 x i8] c"push\09hl\00"
@.str.3 = [8 x i8] c"push\09bc\00"
@.str.4 = [8 x i8] c"push\09de\00"
@.str.5 = [4 x i8] c"ret\00"
@.str.6 = [7 x i8] c"l_jphl\00"
define void @callstk(i32 %0) {
%2 = icmp eq i32 %0, 2
br i1 %2, label %3, label %15
3: ; preds = %1
%4 = tail call i32 (...) @getlabel()
%5 = tail call i32 @ol(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @outstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @printlabel(i32 %4)
%8 = tail call i32 (...) @nl()
%9 = tail call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @ol(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @loadargc(i32 2)
%13 = tail call i32 @ol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @postlabel(i32 %4)
br label %18
15: ; preds = %1
%16 = tail call i32 @loadargc(i32 %0)
%17 = tail call i32 @callrts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %18
18: ; preds = %15, %3
ret void
}