#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fread(unsigned char *, int, unsigned short,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
unsigned short ftell(int /*<<< orphan*/ *);
unsigned char *malloc(unsigned short);
unsigned short print_opcode(unsigned char *, unsigned short, unsigned char *,
                            unsigned short *, unsigned short, unsigned char *,
                            unsigned char *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void process_code_seg(FILE *f, unsigned short ds, unsigned short s,
                      unsigned char *opcode_buf, unsigned char *intrinsic_buf,
                      int mute, int count_all_opcodes,
                      int count_all_intrinsic) {
  long pos;
  unsigned short size;
  unsigned short externsize;
  unsigned short i;
  unsigned short offset;
  unsigned short nbytes;
  unsigned char *p;
  unsigned char *pp;
  unsigned char *pdata;
  unsigned short *pextern;
  pos = ftell(f);
  size = s - ds - sizeof(unsigned short);
  pp = p = malloc(size);
  pdata = malloc(ds);
  fread(pdata, 1, ds, f);
  if (!mute)
    printf("Code segment at file offset %08lXH\n", ftell(f));
  fread(p, 1, size, f);
  fseek(f, pos, SEEK_SET);
  if (size < 3 * sizeof(unsigned short)) {
    printf("Code segment bad!\n");
    free(p);
    free(pdata);
    return;
  }
  if (!mute)
    printf("\t\t.argc %04XH\n", *(unsigned short *)pp);
  pp += sizeof(unsigned short);
  if (!mute)
    printf("\t\t.localc %04XH\n", *(unsigned short *)pp);
  pp += sizeof(unsigned short);
  externsize = *(unsigned short *)pp;
  if (!mute)
    printf("\t\t.externsize %04XH\n", externsize);
  pp += sizeof(unsigned short);
  if (size < ((3 + externsize) * sizeof(unsigned short))) {
    printf("Code segment bad!\n");
    free(p);
    free(pdata);
    return;
  }
  size -= ((3 + externsize) * sizeof(unsigned short));
  pextern = (unsigned short *)pp;
  for (i = 0; i < externsize; i++) {
    if (!mute)
      printf("\t\t.extern %04XH\n", *(unsigned short *)pp);
    pp += sizeof(unsigned short);
  }
  offset = 0;
  while (offset < size) {
    nbytes = print_opcode(pp, offset, pdata, pextern, externsize, opcode_buf,
                          intrinsic_buf, mute, count_all_opcodes,
                          count_all_intrinsic);
    pp += nbytes;
    offset += nbytes;
  }
  free(p);
  free(pdata);
}


x86 assembly (clang, -O0):
<process_code_seg>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    %dx,%ax
mov    %si,%dx
mov    0x18(%rbp),%esi
mov    0x10(%rbp),%esi
mov    %rdi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %ax,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
movzwl %ax,%eax
mov    %rax,-0x38(%rbp)
movzwl -0x14(%rbp),%eax
movzwl -0x12(%rbp),%ecx
sub    %ecx,%eax
cltq
sub    $0x2,%rax
mov    %ax,-0x3a(%rbp)
movzwl -0x3a(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    %rax,-0x58(%rbp)
movzwl -0x12(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x12(%rbp),%ax
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
movzwl %ax,%edx
call   1040 <fread@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    121f <process_code_seg+0xaf>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
movzwl %ax,%esi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x3a(%rbp),%ax
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
movzwl %ax,%edx
call   1040 <fread@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
movzwl -0x3a(%rbp),%eax
cmp    $0x6,%rax
jae    1281 <process_code_seg+0x111>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
jmp    1454 <process_code_seg+0x2e4>
cmpl   $0x0,-0x2c(%rbp)
jne    12a0 <process_code_seg+0x130>
mov    -0x58(%rbp),%rax
movzwl (%rax),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    12cb <process_code_seg+0x15b>
mov    -0x58(%rbp),%rax
movzwl (%rax),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    (%rax),%ax
mov    %ax,-0x3c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    12fe <process_code_seg+0x18e>
movzwl -0x3c(%rbp),%esi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
movzwl -0x3a(%rbp),%eax
movzwl -0x3c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
jae    134a <process_code_seg+0x1da>
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
jmp    1454 <process_code_seg+0x2e4>
movzwl -0x3c(%rbp),%eax
add    $0x3,%eax
movslq %eax,%rcx
shl    $0x1,%rcx
movzwl -0x3a(%rbp),%eax
sub    %rcx,%rax
mov    %ax,-0x3a(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
movw   $0x0,-0x3e(%rbp)
movzwl -0x3e(%rbp),%eax
movzwl -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jge    13bd <process_code_seg+0x24d>
cmpl   $0x0,-0x2c(%rbp)
jne    13a0 <process_code_seg+0x230>
mov    -0x58(%rbp),%rax
movzwl (%rax),%esi
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x58(%rbp)
mov    -0x3e(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x3e(%rbp)
jmp    1371 <process_code_seg+0x201>
movw   $0x0,-0x40(%rbp)
movzwl -0x40(%rbp),%eax
movzwl -0x3a(%rbp),%ecx
cmp    %ecx,%eax
jge    1442 <process_code_seg+0x2d2>
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%si
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x3c(%rbp),%r8w
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%rbx
mov    -0x2c(%rbp),%r11d
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
movzwl %si,%esi
movzwl %r8w,%r8d
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1090 <print_opcode@plt>
mov    %ax,-0x42(%rbp)
movzwl -0x42(%rbp),%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
movzwl -0x42(%rbp),%ecx
movzwl -0x40(%rbp),%eax
add    %ecx,%eax
mov    %ax,-0x40(%rbp)
jmp    13c3 <process_code_seg+0x253>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_code_seg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r12d
mov    %r8,0x38(%rsp)
mov    %rcx,0x20(%rsp)
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r13
mov    0x88(%rsp),%eax
mov    %rax,0x30(%rsp)
mov    0x80(%rsp),%eax
mov    %rax,0x28(%rsp)
call   1070 <ftell@plt>
movzwl %ax,%r15d
sub    %ebx,%ebp
add    $0xfffffffe,%ebp
mov    %ebp,0x4(%rsp)
movzwl %bp,%r14d
mov    %r14d,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    %rax,0x8(%rsp)
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
test   %r12d,%r12d
jne    121c <process_code_seg+0x9c>
mov    %r13,%rdi
call   1070 <ftell@plt>
movzwl %ax,%esi
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1090 <fseek@plt>
cmp    $0x5,%r14w
jbe    12b0 <process_code_seg+0x130>
test   %r12d,%r12d
je     125c <process_code_seg+0xdc>
movzwl 0x4(%rbp),%eax
mov    %ax,(%rsp)
movzwl %ax,%ebx
jmp    129b <process_code_seg+0x11b>
movzwl 0x0(%rbp),%esi
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl 0x2(%rbp),%esi
lea    0xdba(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzwl 0x4(%rbp),%eax
mov    %ax,(%rsp)
movzwl %ax,%ebx
lea    0xdb2(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%r15d
mov    0x8(%rsp),%r13
lea    (%rbx,%rbx,1),%eax
add    $0x6,%eax
cmp    %r14d,%eax
jbe    12c4 <process_code_seg+0x144>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
jmp    13a6 <process_code_seg+0x226>
mov    %rbp,0x18(%rsp)
add    $0x6,%r13
sub    %eax,%r15d
mov    %r13,%rbp
cmpw   $0x0,(%rsp)
je     130f <process_code_seg+0x18f>
lea    0xd78(%rip),%r14
movzwl (%rsp),%ebx
mov    %r13,%rbp
jmp    12fa <process_code_seg+0x17a>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rbp
add    $0xffff,%bx
je     130f <process_code_seg+0x18f>
test   %r12d,%r12d
jne    12f0 <process_code_seg+0x170>
movzwl 0x0(%rbp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12f0 <process_code_seg+0x170>
mov    %r15d,%ecx
test   %cx,%cx
mov    0x20(%rsp),%r9
mov    0x38(%rsp),%r10
mov    0x30(%rsp),%r15
mov    0x28(%rsp),%r14
je     13a1 <process_code_seg+0x221>
mov    %r12,%rax
xor    %ebx,%ebx
movzwl (%rsp),%edx
mov    %edx,(%rsp)
mov    %ecx,0x4(%rsp)
mov    %r13,0x8(%rsp)
mov    %r12,0x40(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movzwl %bx,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
mov    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    (%rsp),%r8d
mov    %r9,%r12
push   %r15
push   %r14
push   %rax
push   %r10
mov    %r14,%r13
mov    %r10,%r14
call   10a0 <print_opcode@plt>
mov    0x24(%rsp),%ecx
mov    %r14,%r10
mov    %r13,%r14
mov    %r12,%r9
add    $0x20,%rsp
add    %eax,%ebx
movzwl %ax,%eax
add    %rax,%rbp
mov    0x40(%rsp),%rax
mov    0x8(%rsp),%r13
cmp    %cx,%bx
jb     1350 <process_code_seg+0x1d0>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Code segment at file offset %08lXH\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [19 x i8] c"Code segment bad!\0A\00"
@.str.2 = [15 x i8] c"\09\09.argc %04XH\0A\00"
@.str.3 = [17 x i8] c"\09\09.localc %04XH\0A\00"
@.str.4 = [21 x i8] c"\09\09.externsize %04XH\0A\00"
@.str.5 = [17 x i8] c"\09\09.extern %04XH\0A\00"
define void @process_code_seg(i32* %0, i16 zeroext %1, i16 zeroext %2, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i32*
%10 = alloca i16
%11 = alloca i16
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca i16
%19 = alloca i16
%20 = alloca i16
%21 = alloca i16
%22 = alloca i16
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i16*
store i32* %0, i32** %9
store i16 %1, i16* %10
store i16 %2, i16* %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%27 = load i32*, i32** %9
%28 = call zeroext i16 @ftell(i32* %27)
%29 = zext i16 %28 to i64
store i64 %29, i64* %17
%30 = load i16, i16* %11
%31 = zext i16 %30 to i32
%32 = load i16, i16* %10
%33 = zext i16 %32 to i32
%34 = sub nsw i32 %31, %33
%35 = sext i32 %34 to i64
%36 = sub i64 %35, 2
%37 = trunc i64 %36 to i16
store i16 %37, i16* %18
%38 = load i16, i16* %18
%39 = call i8* @malloc(i16 zeroext %38)
store i8* %39, i8** %23
store i8* %39, i8** %24
%40 = load i16, i16* %10
%41 = call i8* @malloc(i16 zeroext %40)
store i8* %41, i8** %25
%42 = load i8*, i8** %25
%43 = load i16, i16* %10
%44 = load i32*, i32** %9
%45 = call i32 @fread(i8* %42, i32 1, i16 zeroext %43, i32* %44)
%46 = load i32, i32* %14
%47 = icmp ne i32 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %8
%49 = load i32*, i32** %9
%50 = call zeroext i16 @ftell(i32* %49)
%51 = zext i16 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %48, %8
%54 = load i8*, i8** %23
%55 = load i16, i16* %18
%56 = load i32*, i32** %9
%57 = call i32 @fread(i8* %54, i32 1, i16 zeroext %55, i32* %56)
%58 = load i32*, i32** %9
%59 = load i64, i64* %17
%60 = load i32, i32* @SEEK_SET
%61 = call i32 @fseek(i32* %58, i64 %59, i32 %60)
%62 = load i16, i16* %18
%63 = zext i16 %62 to i64
%64 = icmp ult i64 %63, 6
br i1 %64, label %65, label %71
65: ; preds = %53
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%67 = load i8*, i8** %23
%68 = call i32 @free(i8* %67)
%69 = load i8*, i8** %25
%70 = call i32 @free(i8* %69)
br label %188
71: ; preds = %53
%72 = load i32, i32* %14
%73 = icmp ne i32 %72, 0
br i1 %73, label %80, label %74
74: ; preds = %71
%75 = load i8*, i8** %24
%76 = bitcast i8* %75 to i16*
%77 = load i16, i16* %76
%78 = zext i16 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %74, %71
%81 = load i8*, i8** %24
%82 = getelementptr inbounds i8, i8* %81, i64 2
store i8* %82, i8** %24
%83 = load i32, i32* %14
%84 = icmp ne i32 %83, 0
br i1 %84, label %91, label %85
85: ; preds = %80
%86 = load i8*, i8** %24
%87 = bitcast i8* %86 to i16*
%88 = load i16, i16* %87
%89 = zext i16 %88 to i32
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %89)
br label %91
91: ; preds = %85, %80
%92 = load i8*, i8** %24
%93 = getelementptr inbounds i8, i8* %92, i64 2
store i8* %93, i8** %24
%94 = load i8*, i8** %24
%95 = bitcast i8* %94 to i16*
%96 = load i16, i16* %95
store i16 %96, i16* %19
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
br i1 %98, label %103, label %99
99: ; preds = %91
%100 = load i16, i16* %19
%101 = zext i16 %100 to i32
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %101)
br label %103
103: ; preds = %99, %91
%104 = load i8*, i8** %24
%105 = getelementptr inbounds i8, i8* %104, i64 2
store i8* %105, i8** %24
%106 = load i16, i16* %18
%107 = zext i16 %106 to i64
%108 = load i16, i16* %19
%109 = zext i16 %108 to i32
%110 = add nsw i32 3, %109
%111 = sext i32 %110 to i64
%112 = mul i64 %111, 2
%113 = icmp ult i64 %107, %112
br i1 %113, label %114, label %120
114: ; preds = %103
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%116 = load i8*, i8** %23
%117 = call i32 @free(i8* %116)
%118 = load i8*, i8** %25
%119 = call i32 @free(i8* %118)
br label %188
120: ; preds = %103
%121 = load i16, i16* %19
%122 = zext i16 %121 to i32
%123 = add nsw i32 3, %122
%124 = sext i32 %123 to i64
%125 = mul i64 %124, 2
%126 = load i16, i16* %18
%127 = zext i16 %126 to i64
%128 = sub i64 %127, %125
%129 = trunc i64 %128 to i16
store i16 %129, i16* %18
%130 = load i8*, i8** %24
%131 = bitcast i8* %130 to i16*
store i16* %131, i16** %26
store i16 0, i16* %20
br label %132
132: ; preds = %150, %120
%133 = load i16, i16* %20
%134 = zext i16 %133 to i32
%135 = load i16, i16* %19
%136 = zext i16 %135 to i32
%137 = icmp slt i32 %134, %136
br i1 %137, label %138, label %153
138: ; preds = %132
%139 = load i32, i32* %14
%140 = icmp ne i32 %139, 0
br i1 %140, label %147, label %141
141: ; preds = %138
%142 = load i8*, i8** %24
%143 = bitcast i8* %142 to i16*
%144 = load i16, i16* %143
%145 = zext i16 %144 to i32
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %141, %138
%148 = load i8*, i8** %24
%149 = getelementptr inbounds i8, i8* %148, i64 2
store i8* %149, i8** %24
br label %150
150: ; preds = %147
%151 = load i16, i16* %20
%152 = add i16 %151, 1
store i16 %152, i16* %20
br label %132
153: ; preds = %132
store i16 0, i16* %21
br label %154
154: ; preds = %160, %153
%155 = load i16, i16* %21
%156 = zext i16 %155 to i32
%157 = load i16, i16* %18
%158 = zext i16 %157 to i32
%159 = icmp slt i32 %156, %158
br i1 %159, label %160, label %183
160: ; preds = %154
%161 = load i8*, i8** %24
%162 = load i16, i16* %21
%163 = load i8*, i8** %25
%164 = load i16*, i16** %26
%165 = load i16, i16* %19
%166 = load i8*, i8** %12
%167 = load i8*, i8** %13
%168 = load i32, i32* %14
%169 = load i32, i32* %15
%170 = load i32, i32* %16
%171 = call zeroext i16 @print_opcode(i8* %161, i16 zeroext %162, i8* %163, i16* %164, i16 zeroext %165, i8* %166, i8* %167, i32 %168, i32 %169, i32 %170)
store i16 %171, i16* %22
%172 = load i16, i16* %22
%173 = zext i16 %172 to i32
%174 = load i8*, i8** %24
%175 = sext i32 %173 to i64
%176 = getelementptr inbounds i8, i8* %174, i64 %175
store i8* %176, i8** %24
%177 = load i16, i16* %22
%178 = zext i16 %177 to i32
%179 = load i16, i16* %21
%180 = zext i16 %179 to i32
%181 = add nsw i32 %180, %178
%182 = trunc i32 %181 to i16
store i16 %182, i16* %21
br label %154
183: ; preds = %154
%184 = load i8*, i8** %23
%185 = call i32 @free(i8* %184)
%186 = load i8*, i8** %25
%187 = call i32 @free(i8* %186)
br label %188
188: ; preds = %183, %114, %65
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Code segment at file offset %08lXH\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [15 x i8] c"\09\09.argc %04XH\0A\00"
@.str.3 = [17 x i8] c"\09\09.localc %04XH\0A\00"
@.str.4 = [21 x i8] c"\09\09.externsize %04XH\0A\00"
@.str.5 = [17 x i8] c"\09\09.extern %04XH\0A\00"
@str.6 = [18 x i8] c"Code segment bad!\00"
define void @process_code_seg(i32* nocapture %0, i16 zeroext %1, i16 zeroext %2, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7) {
%9 = tail call zeroext i16 @ftell(i32* %0)
%10 = zext i16 %9 to i64
%11 = sub i16 %2, %1
%12 = add i16 %11, -2
%13 = tail call i8* @malloc(i16 zeroext %12)
%14 = tail call i8* @malloc(i16 zeroext %1)
%15 = tail call i32 @fread(i8* %14, i32 1, i16 zeroext %1, i32* %0)
%16 = icmp eq i32 %5, 0
br i1 %16, label %17, label %21
17: ; preds = %8
%18 = tail call zeroext i16 @ftell(i32* %0)
%19 = zext i16 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17, %8
%22 = tail call i32 @fread(i8* %13, i32 1, i16 zeroext %12, i32* %0)
%23 = load i32, i32* @SEEK_SET
%24 = tail call i32 @fseek(i32* %0, i64 %10, i32 %23)
%25 = icmp ult i16 %12, 6
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%28 = tail call i32 @free(i8* %13)
br label %91
29: ; preds = %21
br i1 %16, label %35, label %30
30: ; preds = %29
%31 = getelementptr inbounds i8, i8* %13, i64 4
%32 = bitcast i8* %31 to i16*
%33 = load i16, i16* %32
%34 = zext i16 %33 to i32
br label %50
35: ; preds = %29
%36 = bitcast i8* %13 to i16*
%37 = load i16, i16* %36
%38 = zext i16 %37 to i32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds i8, i8* %13, i64 2
%41 = bitcast i8* %40 to i16*
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds i8, i8* %13, i64 4
%46 = bitcast i8* %45 to i16*
%47 = load i16, i16* %46
%48 = zext i16 %47 to i32
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %30, %35
%51 = phi i32 [ %34, %30 ], [ %48, %35 ]
%52 = phi i16 [ %33, %30 ], [ %47, %35 ]
%53 = getelementptr inbounds i8, i8* %13, i64 6
%54 = shl nuw nsw i32 %51, 1
%55 = add nuw nsw i32 %54, 6
%56 = zext i16 %12 to i32
%57 = icmp ugt i32 %55, %56
br i1 %57, label %58, label %61
58: ; preds = %50
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%60 = tail call i32 @free(i8* %13)
br label %91
61: ; preds = %50
%62 = trunc i32 %55 to i16
%63 = sub i16 %12, %62
%64 = bitcast i8* %53 to i16*
%65 = icmp eq i16 %52, 0
br i1 %65, label %66, label %69
66: ; preds = %77, %61
%67 = phi i8* [ %53, %61 ], [ %78, %77 ]
%68 = icmp eq i16 %63, 0
br i1 %68, label %89, label %81
69: ; preds = %61, %77
%70 = phi i16 [ %79, %77 ], [ 0, %61 ]
%71 = phi i8* [ %78, %77 ], [ %53, %61 ]
br i1 %16, label %72, label %77
72: ; preds = %69
%73 = bitcast i8* %71 to i16*
%74 = load i16, i16* %73
%75 = zext i16 %74 to i32
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %72, %69
%78 = getelementptr inbounds i8, i8* %71, i64 2
%79 = add nuw i16 %70, 1
%80 = icmp eq i16 %79, %52
br i1 %80, label %66, label %69
81: ; preds = %66, %81
%82 = phi i8* [ %86, %81 ], [ %67, %66 ]
%83 = phi i16 [ %87, %81 ], [ 0, %66 ]
%84 = tail call zeroext i16 @print_opcode(i8* %82, i16 zeroext %83, i8* %14, i16* %64, i16 zeroext %52, i8* %3, i8* %4, i32 %5, i32 %6, i32 %7)
%85 = zext i16 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
%87 = add i16 %84, %83
%88 = icmp ult i16 %87, %63
br i1 %88, label %81, label %89
89: ; preds = %81, %66
%90 = tail call i32 @free(i8* %13)
br label %91
91: ; preds = %89, %58, %26
%92 = tail call i32 @free(i8* %14)
ret void
}