void jsr(p, a, s) struct h8_opcode *p;
char *a;
int s;
{
  printf("if (b1 == 0xc4) {\n");
  printf("printf(\"%%c\", reg[2]);\n");
  printf("}\n");
  printf("else {\n");
  printf("reg[7]-=2;\n");
  printf("tmp = reg[7];\n");
  printf("SET_WORD_MEM(tmp, (npc-saved_state.mem)*2);\n");
  printf("npc = (lval>>1) + saved_state.mem;\n");
  printf("}");
}


x86 assembly (clang, -O0):
<jsr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jsr>:
push   %rax
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
lea    0xeea(%rip),%rdi
call   1040 <puts@plt>
mov    $0x7d,%edi
pop    %rax
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.h8_opcode = type opaque
@.str = [19 x i8] c"if (b1 == 0xc4) {\0A\00"
@.str.1 = [24 x i8] c"printf(\22%%c\22, reg[2]);\0A\00"
@.str.2 = [3 x i8] c"}\0A\00"
@.str.3 = [8 x i8] c"else {\0A\00"
@.str.4 = [12 x i8] c"reg[7]-=2;\0A\00"
@.str.5 = [15 x i8] c"tmp = reg[7];\0A\00"
@.str.6 = [45 x i8] c"SET_WORD_MEM(tmp, (npc-saved_state.mem)*2);\0A\00"
@.str.7 = [36 x i8] c"npc = (lval>>1) + saved_state.mem;\0A\00"
@.str.8 = [2 x i8] c"}\00"
define void @jsr(%struct.h8_opcode* %0, i8* %1, i32 %2) {
%4 = alloca %struct.h8_opcode*
%5 = alloca i8*
%6 = alloca i32
store %struct.h8_opcode* %0, %struct.h8_opcode** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.h8_opcode = type opaque
@.str.1 = [24 x i8] c"printf(\22%%c\22, reg[2]);\0A\00"
@str = [18 x i8] c"if (b1 == 0xc4) {\00"
@str.9 = [2 x i8] c"}\00"
@str.10 = [7 x i8] c"else {\00"
@str.11 = [11 x i8] c"reg[7]-=2;\00"
@str.12 = [14 x i8] c"tmp = reg[7];\00"
@str.13 = [44 x i8] c"SET_WORD_MEM(tmp, (npc-saved_state.mem)*2);\00"
@str.14 = [35 x i8] c"npc = (lval>>1) + saved_state.mem;\00"
define void @jsr(%struct.h8_opcode* nocapture readnone %0, i8* nocapture readnone %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.13, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
%12 = tail call i32 @putchar(i32 125)
ret void
}