LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_value_str_from_ptr
static ore_value
ore_value_str_from_ptr(ore_context* ore, char* p, int l) {
  if (p == NULL) return ore_value_nil();
  ore_value v = { ORE_TYPE_STRING };
  v.v.s = (ore_string*) malloc(sizeof(ore_string));
  if (!v.v.s) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  v.v.s->ref = 0;
  v.v.s->l = l < 0 ? strlen(p) : l;
  v.v.s->p = p;
  return v;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rdx, %rdx
je 0x103a4
movl %ecx, %r15d
movq %rdx, %r14
movq %rsi, %r13
movl $0x10, %edi
callq 0x21a0
testq %rax, %rax
je 0x103c0
movq %rax, %r12
movl $0x0, 0xc(%rax)
testl %r15d, %r15d
jns 0x10387
movq %r14, %rdi
callq 0x20c0
movq %rax, %r15
movl %r15d, 0x8(%r12)
movq %r14, (%r12)
movq $0x4, (%rbx)
movq %r12, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0x103ae
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq $0x0, 0x20(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r13, %rdi
movq %rbx, %rsi
callq 0x257d
jmp 0x103b6
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_parse_num
static ore_value
ore_parse_num(ore_context* ore, const char* s) {
  ore_value v = {0};
  if (*s == '0' && *(s+1) == 'x') {
    v.t = ORE_TYPE_INT;
    v.v.i = strtol(s, NULL, 16);
  } else if (!strchr(s, '.')) {
    v.t = ORE_TYPE_INT;
    v.v.i = atoi(s);
  } else {
    v.t = ORE_TYPE_FLOAT;
    v.v.d = atof(s);
  }
  return v;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq $0x0, 0x20(%rdi)
cmpb $0x30, (%rsi)
jne 0x1072d
cmpb $0x78, 0x1(%r14)
jne 0x1072d
movl $0x2, (%rbx)
movq %r14, %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2180
movl %eax, 0x8(%rbx)
jmp 0x10765
movq %r14, %rdi
movl $0x2e, %esi
callq 0x20d0
testq %rax, %rax
je 0x10754
movl $0x3, (%rbx)
movq %r14, %rdi
callq 0x20a0
movsd %xmm0, 0x8(%rbx)
jmp 0x10765
movl $0x2, (%rbx)
movq %r14, %rdi
callq 0x2220
movl %eax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_parse_str
static ore_value
ore_parse_str(ore_context* ore, const char* s) {
  ore_value v = { ORE_TYPE_STRING };
  char* t = strdup(s);
  if (!t) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  char* p = t + 1;
  char* ps = p;
  int n = 0;
  while (*p) {
    if (*p == '\\' && *(p+1)) {
      p++;
      switch (*p) {
        case 'b': *ps = '\b'; break;
        case 'f': *ps = '\f'; break;
        case 'r': *ps = '\r'; break;
        case 'n': *ps = '\n'; break;
        case 't': *ps = '\t'; break;
        default:
         *ps = *p;
      }
    } else
      *ps = *p;
    p++; ps++; n++;
  }
  *p = 0x00;
  size_t l = n - 1;
  v.v.s = (ore_string*) malloc(sizeof(ore_string));
  if (!v.v.s) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  v.v.s->ref = 0;
  v.v.s->l = l;
  v.v.s->p = calloc(1, l + 1);
  strncpy(v.v.s->p, t + 1, l);
  free(t);
  return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %rdx, %rdi
callq 0x2270
testq %rax, %rax
je 0x10a15
movq %rax, %r14
movq %rax, %r12
incq %r12
movq $-0x1, %r13
leaq 0x3f34(%rip), %rax      # 0x14884
movq %r12, %rcx
movzbl (%rcx), %edx
cmpl $0x5c, %edx
je 0x10961
testl %edx, %edx
jne 0x10995
jmp 0x109a2
movsbl 0x1(%rcx), %esi
testl %esi, %esi
je 0x10995
incq %rcx
leal -0x62(%rsi), %edx
rorl %edx
cmpl $0x9, %edx
ja 0x10983
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movb $0x8, %dl
jmp 0x10995
movl %esi, %edx
jmp 0x10995
movb $0xa, %dl
jmp 0x10995
movb $0xc, %dl
jmp 0x10995
movb $0xd, %dl
jmp 0x10995
movb $0x9, %dl
movb %dl, 0x2(%r14,%r13)
incq %rcx
incq %r13
jmp 0x10953
movb $0x0, (%rcx)
movl $0x10, %edi
callq 0x21a0
testq %rax, %rax
je 0x10a22
movq %rax, %rbp
movl $0x0, 0xc(%rax)
movl %r13d, 0x8(%rax)
leaq 0x1(%r13), %rsi
movl $0x1, %edi
callq 0x2140
movq %rax, (%rbp)
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2050
movq %r14, %rdi
callq 0x22c0
movq $0x4, (%rbx)
movq %rbp, 0x8(%rbx)
movaps (%rsp), %xmm0
movups %xmm0, 0x10(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2607
jmp 0x10a06
movq %r15, %rdi
movq %rbx, %rsi
callq 0x25c2
jmp 0x10a06
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_value_hash_from_khash
static ore_value
ore_value_hash_from_khash(ore_context* ore, ore_hash_t* p) {
  ore_value v = { ORE_TYPE_HASH };
  v.v.h = (ore_hash*) malloc(sizeof(ore_hash));
  if (!v.v.h) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  v.v.h->ref = 0;
  v.v.h->p = p;
  return v;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl $0x10, %edi
callq 0x21a0
testq %rax, %rax
je 0x10a76
movl $0x0, 0x8(%rax)
movq %r14, (%rax)
movq $0x6, (%rbx)
movq %rax, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq $0x0, 0x20(%rbx)
popq %rbx
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %rbx, %rsi
callq 0x264c
jmp 0x10a70
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_expr
static ore_value
ore_expr(ore_context* ore, mpc_ast_t* t) {
  int i;
  ore_value lhs = ore_eval(ore, t->children[0]);
  for (i = 1; i < t->children_num; i += 2) {
    char* op = t->children[i]->contents;
    ore_value rhs = ore_eval(ore, t->children[i+1]);
    lhs = ore_expr0(ore, lhs, op, rhs);
  }
  return lhs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x30(%rdx), %rax
movq (%rax), %rdx
callq 0xdc73
cmpl $0x2, 0x28(%rbx)
jl 0x11179
movl $0x1, %r12d
leaq 0x58(%rsp), %r13
movq 0x30(%rbx), %rax
movq (%rax,%r12,8), %rcx
movq 0x8(%rcx), %rbp
movq 0x8(%rax,%r12,8), %rdx
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0xdc73
movq 0xa0(%rsp), %rax
movq %rax, 0x48(%rsp)
movups 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0x38(%rsp)
movups %xmm0, 0x28(%rsp)
movq 0x20(%r15), %rax
movq %rax, 0x20(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r13, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x1118b
movq 0x78(%rsp), %rax
movq %rax, 0x20(%r15)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
addq $0x2, %r12
cmpl %r12d, 0x28(%rbx)
jg 0x110de
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_define_class
static ore_value
ore_define_class(ore_context* ore, mpc_ast_t* tn, mpc_ast_t* tb, const char* base) {
  ore_value v = { ORE_TYPE_CLASS };
  v.v.c = (ore_class*) malloc(sizeof(ore_class));
  if (!v.v.c) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  v.v.c->n = strdup(tn->contents);
  if (!v.v.c->n) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  v.v.c->t = tb;
  v.v.c->b = base;
  ore_context* g = ore;
  while (g->parent) g = g->parent;
  ore_define(g, v.v.c->n, v);
  return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl $0xb, 0x30(%rsp)
movl $0x18, %edi
callq 0x21a0
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x119c7
movq %rax, %r13
movq 0x8(%rbp), %rdi
callq 0x2270
movq %rax, (%r13)
testq %rax, %rax
je 0x119d4
movq %r12, 0x8(%r13)
movq %r15, 0x10(%r13)
movq %r14, %rdi
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x1196d
movq 0x50(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rax, %rsi
callq 0xd3c9
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rbx)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2805
jmp 0x119b8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27c0
jmp 0x119b8
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_find_statements
static mpc_ast_t*
ore_find_statements(mpc_ast_t* t) {
  int i;
  if (is_a(t, "template")) return t;
  for (i = 0; i < t->children_num; i++) {
    if (is_a(t->children[i], "char") && t->children[i]->contents[0] == '{') {
      if (t->children[i+1]->contents[0] != '}') {
        return t->children[i+1];
      }
    }
  }
  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movq (%rdi), %rdi
leaq 0x2941(%rip), %rsi      # 0x14bd9
callq 0x2290
testq %rax, %rax
jne 0x122ef
movslq 0x28(%r14), %r15
testq %r15, %r15
jle 0x122ec
movq 0x30(%r14), %r12
leaq 0x2252(%rip), %rbx      # 0x14508
xorl %r13d, %r13d
movq (%r12,%r13,8), %r14
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x2290
testq %rax, %rax
je 0x122e4
movq 0x8(%r14), %rax
cmpb $0x7b, (%rax)
jne 0x122e4
movq 0x8(%r12,%r13,8), %r14
movq 0x8(%r14), %rax
cmpb $0x7d, (%rax)
jne 0x122ef
incq %r13
cmpq %r13, %r15
jne 0x122b9
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_cmp_eq
static int
ore_cmp_eq(ore_context* ore, ore_value lhs, ore_value rhs) {
  switch (lhs.t) {
    case ORE_TYPE_NIL:
      return rhs.t == ORE_TYPE_NIL;
    case ORE_TYPE_BOOL:
      if (rhs.t == ORE_TYPE_BOOL && lhs.v.b == rhs.v.b) return 1;
      return 0;
    case ORE_TYPE_INT:
      if (rhs.t == ORE_TYPE_INT && lhs.v.i == rhs.v.i) return 1;
      if (rhs.t == ORE_TYPE_FLOAT && lhs.v.i == rhs.v.d) return 1;
      return 0;
    case ORE_TYPE_FLOAT:
      if (rhs.t == ORE_TYPE_INT && lhs.v.d == rhs.v.i) return 1;
      if (rhs.t == ORE_TYPE_FLOAT && lhs.v.d == rhs.v.d) return 1;
      return 0;
    case ORE_TYPE_STRING:
      if (lhs.t == rhs.t && lhs.v.s->l == rhs.v.s->l &&
          !memcmp(lhs.v.s->p, rhs.v.s->p, lhs.v.s->l))
        return 1;
      return 0;
    case ORE_TYPE_ARRAY:
      if (lhs.t == rhs.t && lhs.v.a->p == rhs.v.a->p)
        return 1;
      return 0;
    case ORE_TYPE_HASH:
      if (lhs.t == rhs.t && lhs.v.h->p == rhs.v.h->p)
        return 1;
      return 0;
    case ORE_TYPE_REGEXP:
      if (lhs.t == rhs.t && lhs.v.r->l == rhs.v.r->l &&
          !memcmp(lhs.v.r->p, rhs.v.r->p, lhs.v.r->l))
        return 1;
      return 0;
    case ORE_TYPE_FUNC:
      if (lhs.t == rhs.t && lhs.v.f.x.o == rhs.v.f.x.o)
        return 1;
      return 0;
    case ORE_TYPE_CFUNC:
      if (lhs.t == rhs.t && lhs.v.f.x.c == rhs.v.f.x.c)
        return 1;
      return 0;
    case ORE_TYPE_ENV:
      if (lhs.t == rhs.t && lhs.v.e->p == rhs.v.e->p)
        return 1;
      return 0;
    default:
      break;
  }
  return 0;
}

// Assembly:
pushq %rax
movl 0x10(%rsp), %esi
xorl %eax, %eax
cmpq $0xa, %rsi
ja 0x12728
leaq 0x38(%rsp), %rcx
leaq 0x10(%rsp), %rdx
leaq 0x231e(%rip), %rdi      # 0x14938
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
xorl %eax, %eax
cmpl $0x0, (%rcx)
sete %al
jmp 0x12728
cmpl $0x4, (%rcx)
je 0x12689
jmp 0x12726
cmpl $0x9, (%rcx)
je 0x126ed
jmp 0x12728
movl (%rcx), %eax
cmpl $0x3, %eax
je 0x126fe
cmpl $0x2, %eax
je 0x126b4
jmp 0x12726
movl (%rcx), %eax
cmpl $0x3, %eax
je 0x12713
cmpl $0x2, %eax
jne 0x12726
cvtsi2sdl 0x8(%rcx), %xmm0
movsd 0x8(%rdx), %xmm1
jmp 0x12708
cmpl $0x7, (%rcx)
jne 0x12726
movq 0x8(%rdx), %rax
movslq 0x8(%rax), %rdx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %edx
jne 0x12726
movq (%rax), %rdi
movq (%rcx), %rsi
callq 0x21c0
testl %eax, %eax
jne 0x12726
jmp 0x126f7
cmpl $0x1, (%rcx)
jne 0x12726
movl 0x8(%rdx), %edx
movl $0x1, %eax
cmpl 0x8(%rcx), %edx
jne 0x12726
jmp 0x12728
cmpl $0x5, (%rcx)
je 0x126d6
jmp 0x12728
cmpl $0x6, (%rcx)
je 0x126d6
jmp 0x12728
cmpl $0xa, (%rcx)
jne 0x12728
movq 0x8(%rdx), %rdx
movq (%rdx), %rdx
movq 0x8(%rcx), %rcx
cmpq (%rcx), %rdx
jne 0x12728
jmp 0x126f7
cmpl $0x8, (%rcx)
jne 0x12728
movq 0x18(%rdx), %rdx
cmpq 0x18(%rcx), %rdx
jne 0x12728
movl $0x1, %eax
jmp 0x12728
cvtsi2sdl 0x8(%rdx), %xmm0
movsd 0x8(%rcx), %xmm1
movl $0x1, %eax
ucomisd %xmm0, %xmm1
jmp 0x12722
movsd 0x8(%rdx), %xmm0
movl $0x1, %eax
ucomisd 0x8(%rcx), %xmm0
jne 0x12726
jnp 0x12728
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O3/mattn[P]orelang/ore.c
// Function: ore_class_new
static ore_value
ore_class_new(ore_context* ore, ore_value clazz) {
  ore_value v = { ORE_TYPE_OBJECT };
  ore_context* this = ore_new(ore);
  v.v.o = (ore_object*) malloc(sizeof(ore_object));
  if (!v.v.o) {
    fprintf(stderr, "failed to allocate memory\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }
  if (clazz.v.c->b != NULL) {
    ore_value bc = ore_find_global(ore, clazz.v.c->b);
    if (bc.t == ORE_TYPE_CLASS)
      ore_define(this, "super", ore_class_new(this, bc));
  }
  v.v.o->t = clazz.t;
  v.v.o->c = clazz.v.c;
  v.v.o->e = this;
  v.v.o->ref = -1;
  ore_eval(this, ore_find_statements(clazz.v.c->t));
  ore_define(this, "this", v);
  return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r12
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl $0xd, 0x30(%rsp)
movq %rsi, %rdi
callq 0xd661
movq %rax, %r14
movl $0x20, %edi
callq 0x21a0
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x1289f
movq %rax, %r15
leaq 0xe0(%rsp), %rbp
movq 0x8(%rbp), %r13
movq 0x10(%r13), %rdx
testq %rdx, %rdx
je 0x12818
movq %r12, %rsi
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x1279a
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0xccb4
cmpl $0xb, (%r12)
jne 0x12818
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0x58(%rsp), %xmm0
movups 0x68(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x1272a
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x3905(%rip), %rsi      # 0x16115
movq %r14, %rdi
callq 0xd3c9
movl (%rbp), %eax
movl %eax, (%r15)
movq %r13, 0x8(%r15)
movq %r14, 0x10(%r15)
movl $0xffffffff, 0x18(%r15) # imm = 0xFFFFFFFF
movq 0x8(%r13), %rdi
callq 0x12282
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xdc73
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x38b0(%rip), %rsi      # 0x1611b
movq %r14, %rdi
callq 0xd3c9
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rbx)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2922
jmp 0x1288d
// File: /workspace/github_c_makefile_star2_O3/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_05/strncmp.c
// Function: main
int main(void)
{
  char s[100] = "This is the first string";
  char *t = "This is the second string";
  size_t nr_chars = 13;

  int is_equal = strcmp_ptr(s, t, nr_chars);

  if (is_equal == 0)
  {
    puts("String s is equal with string t.");
  }
  else if (is_equal > 0)
  {
    puts("String s contains more chars than string t.");
  }
  else if (is_equal < 0)
  {
    puts("String s contains less chars than string t.");
  }

  return 0;
}

// Assembly:
movl $0x1, %eax
leaq 0xf46(%rip), %rdi       # 0x208e
leaq 0xec1(%rip), %rcx       # 0x2010
leaq 0xf1e(%rip), %rdx       # 0x2074
cmpq $0xd, %rax
je 0x1179
movsbl (%rax,%rcx), %esi
movsbl (%rax,%rdx), %r8d
incq %rax
cmpb %r8b, %sil
je 0x1156
subl %r8d, %esi
jle 0x1186
leaq 0xf36(%rip), %rdi       # 0x20af
pushq %rax
callq 0x1030
addq $0x8, %rsp
xorl %eax, %eax
retq
jns 0x1183
leaq 0xf4c(%rip), %rdi       # 0x20db
jmp 0x1179
// File: /workspace/github_c_makefile_star2_O3/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_05/strncmp.c
// Function: strcmp_ptr
int strcmp_ptr(char *s, char *t, size_t n)
{
  while ((*s == *t) && --n)
  {
    if (*s == '\0')
      return 0;

    ++s;
    ++t;
  }

  // If the s string contains more characters than t, then the t char will
  // become '\0' before s char. If this happen then the s char will be its ascii value and
  // t char will be 0, so the final result will be s_ascii_value - 0.

  // If the t string contains more character than s, then the s char will
  // become '\0' before t char. If this happen then the s char will be 0 and
  // t char will be whatever ascii_value is holding, so the final result will be 0 - t_ascii_value.

  return *s - *t;
}

// Assembly:
movb (%rdi), %al
movb (%rsi), %r8b
cmpb %r8b, %al
jne 0x11bd
movl $0x1, %ecx
cmpq %rcx, %rdx
je 0x11ba
testb %al, %al
je 0x11c7
movb (%rdi,%rcx), %al
movb (%rsi,%rcx), %r8b
incq %rcx
cmpb %r8b, %al
je 0x11a0
jmp 0x11bd
movl %eax, %r8d
movsbl %al, %eax
movsbl %r8b, %ecx
subl %ecx, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/rajatxjain[P]gpiocfg/gpiocfg.c
// Function: usage
static void usage(char *prog)
{
	printf("\nUsage: %s [options] <command>\n\n", prog);
	printf("Options:\n");
	printf("  -p, --platform=<name>    Platform to use (Default: icelake)\n\n");
	printf("Commands:\n");
	printf("  -r, --read=<gpio pin>    Read and parse DW0/DW1 config for given pin\n");
	printf("  -v, --value=<DW0 value>  Parse the given DW0 register value\n");
	printf("  -l, --list               List the GPIO pins for selected platform\n");
	printf("  -h, --help               Print this help.\n\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rsi
leaq 0x721(%rip), %rdi       # 0x2113
xorl %eax, %eax
callq 0x1070
leaq 0xe60(%rip), %rdi       # 0x2860
callq 0x1040
leaq 0xe5d(%rip), %rdi       # 0x2869
callq 0x1040
leaq 0xe90(%rip), %rdi       # 0x28a8
callq 0x1040
leaq 0xe8e(%rip), %rdi       # 0x28b2
callq 0x1040
leaq 0xec9(%rip), %rdi       # 0x28f9
callq 0x1040
leaq 0xefb(%rip), %rdi       # 0x2937
callq 0x1040
leaq 0xf33(%rip), %rdi       # 0x297b
popq %rbp
jmp 0x1040
// File: /workspace/github_c_makefile_star2_O3/rajatxjain[P]gpiocfg/gpiocfg.c
// Function: lookup_pin
static int lookup_pin(char *pin_name, struct community **community, unsigned *pin_no_in_cmty)
{
	unsigned cmty_num, pin;
	struct community *cmty;

	for (cmty_num = 0; cmty_num < platform->num_communities; cmty_num++) {		
		cmty = &platform->communities[cmty_num];
		for (pin = 0; pin < cmty->num_pins; pin++)
			if (!strcmp(cmty->pin_names[pin], pin_name)) {
				*community = cmty;
				*pin_no_in_cmty = pin;
				return 1;
			}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq 0x265a(%rip), %rax      # 0x40c0
movl 0x28(%rax), %ecx
movq %rcx, -0x58(%rbp)
testq %rcx, %rcx
je 0x1ae7
movq %rdi, %r15
movq %rsi, -0x48(%rbp)
movq %rdx, -0x50(%rbp)
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
addq $0x10, %rax
movq %rax, -0x38(%rbp)
xorl %r13d, %r13d
imulq $0x1010, %r13, %rcx     # imm = 0x1010
movq -0x40(%rbp), %rax
movq %rcx, -0x30(%rbp)
movl 0xc(%rax,%rcx), %ebx
testq %rbx, %rbx
je 0x1ad6
movq -0x30(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %r12
xorl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rsi
callq 0x1090
testl %eax, %eax
je 0x1aeb
incq %r14
addq $0x20, %r12
cmpq %r14, %rbx
jne 0x1abb
incq %r13
addq $0x1010, -0x38(%rbp)    # imm = 0x1010
cmpq -0x58(%rbp), %r13
jne 0x1a90
xorl %eax, %eax
jmp 0x1b02
movq -0x48(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl %r14d, (%rax)
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/rajatxjain[P]gpiocfg/gpiocfg.c
// Function: mmio_read32
static u_int32_t mmio_read32(unsigned long addr)
{
	int fd;
	volatile u_int32_t *ptr;
	u_int32_t val;
	unsigned int pgsize = getpagesize();
	unsigned long aligned_addr = addr & ~(pgsize - 1);
	unsigned long offset = addr & (pgsize - 1);
	
	fd = open("/dev/mem", O_RDONLY | O_SYNC);
	if (fd < 0) {
		printf("Error opening /dev/mem!!!\n");
		return -1;
	}
	ptr = mmap(NULL, pgsize, PROT_READ, MAP_SHARED, fd, aligned_addr);
	if (!ptr || ptr == MAP_FAILED) {
		printf("Error in mmap for addr 0x%X!!!\n", addr);
		return -1;
	}
	val = *(volatile u_int32_t *)((unsigned long)ptr + offset);
	munmap((void*) ptr, pgsize);
	close(fd);
	return val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x10d0
movl %eax, %r15d
leaq 0x716(%rip), %rdi       # 0x2244
movl $0x101000, %esi         # imm = 0x101000
xorl %eax, %eax
callq 0x10b0
testl %eax, %eax
js 0x1b83
movl %eax, %r14d
movl %r15d, %eax
negl %eax
movl %ebx, %r9d
andl %eax, %r9d
movl %r15d, %r12d
xorl %edi, %edi
movq %r12, %rsi
movl $0x1, %edx
movl $0x1, %ecx
movl %r14d, %r8d
callq 0x1050
leaq 0x1(%rax), %rcx
cmpq $0x1, %rcx
ja 0x1b96
leaq 0x6d6(%rip), %rdi       # 0x224d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1070
jmp 0x1b8f
leaq 0xfa2(%rip), %rdi       # 0x2b2c
callq 0x1040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x1bb2
decl %r15d
andl %r15d, %ebx
movl (%rbx,%rax), %ebx
movq %rax, %rdi
movq %r12, %rsi
callq 0x10a0
movl %r14d, %edi
callq 0x1080
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen.c
// Function: collect_named_labels
static struct Vector /*<SourceLabel>*/
collect_named_labels(const struct Statement *ptr_sta)
{
	struct Statement sta = *ptr_sta;
	struct Vector /*<SourceLabel>*/ ans = init_vector();
	concat_vector(&ans, &sta.labels);
	switch (sta.category) {
	case RETURN_STATEMENT:
	case BREAK_STATEMENT:
	case CONTINUE_STATEMENT:
	case EXPRESSION_STATEMENT:
	case DECLARATION_STATEMENT:
	case GOTO_STATEMENT:
		/* nothing */
		break;

	case SWITCH_STATEMENT: /* do peek labels */
	case IF_STATEMENT:
	case FOR_STATEMENT:
	case WHILE_STATEMENT:
	case DO_WHILE_STATEMENT: {
		const struct Vector /*<SourceLabel>*/ inner_vec =
		    collect_named_labels(sta.inner_statement);
		concat_vector(&ans, &inner_vec);
		break;
	}

	case COMPOUND_STATEMENT:
	case IF_ELSE_STATEMENT: {
		struct Vector /*<Statement>*/ statement_vec = sta.statement_vector;
		for (int counter = 0; counter != statement_vec.length; ++counter) {
			const struct Statement *ptr_ith = statement_vec.vector[counter];
			const struct Vector /*<SourceLabel>*/ inner_vec =
			    collect_named_labels(ptr_ith);
			concat_vector(&ans, &inner_vec);
		}
		break;
	}
	}
	return ans;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdi, %rsi
leaq -0x3d8(%rbp), %rbx
movl $0x390, %edx            # imm = 0x390
movq %rbx, %rdi
callq 0x1100
callq 0x5cf8
leaq -0x38(%rbp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
leaq -0x60(%rbp), %rsi
callq 0x5df4
movl (%rbx), %eax
cmpl $0xb, %eax
ja 0x2e3c
movl $0x83a, %ecx            # imm = 0x83A
btl %eax, %ecx
jae 0x2e56
movq -0xc0(%rbp), %rdi
callq 0x2dc7
leaq -0x48(%rbp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq -0x38(%rbp), %rdi
callq 0x5df4
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rdx
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5, %ecx
btl %eax, %ecx
jae 0x2e3c
movl -0x3d0(%rbp), %r15d
testq %r15, %r15
je 0x2e3c
movq -0x3c8(%rbp), %r12
xorl %r13d, %r13d
leaq -0x38(%rbp), %rbx
leaq -0x48(%rbp), %r14
movq (%r12,%r13,8), %rdi
callq 0x2dc7
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5df4
incq %r13
cmpq %r13, %r15
jne 0x2e7e
jmp 0x2e3c
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/alignment.c
// Function: get_size_alignment_offsets_for_union
struct SizeAndAlignment get_size_alignment_offsets_for_union(
    const struct SizeAndAlignment *inner_type_vec, int **ptr_offset_vec,
    int length)
{
	struct SizeAndAlignment res;
	res.alignment = 1;

	/* union's alignment is the maximum of the members' alignments */
	for (int i = 0; i < length; i++) {
		if (inner_type_vec[i].alignment > res.alignment) {
			res.alignment = inner_type_vec[i].alignment;
		}
	}

	int max_size_of_member = 1;

	/* union's size is AT LEAST the maximum of the members' sizes */
	for (int i = 0; i < length; i++) {
		if (inner_type_vec[i].size > max_size_of_member) {
			max_size_of_member = inner_type_vec[i].size;
		}
	}

	if (max_size_of_member % res.alignment) {
		max_size_of_member +=
		    res.alignment - (max_size_of_member % res.alignment);
	}

	res.size = max_size_of_member;

	/* calloc; all is zero */
	int *offset_vec = calloc(length, sizeof(int));
	*ptr_offset_vec = offset_vec;
	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ecx
movq %rsi, %rbx
testl %edx, %edx
jle 0x2ef4
movl %ecx, %eax
movl $0x1, %r15d
xorl %edx, %edx
movl 0x4(%rdi,%rdx,8), %esi
cmpl %r15d, %esi
cmovgl %esi, %r15d
incq %rdx
cmpq %rdx, %rax
jne 0x2ec1
testl %ecx, %ecx
jle 0x2efa
movl $0x1, %esi
xorl %edx, %edx
movl (%rdi,%rdx,8), %r8d
cmpl %esi, %r8d
cmovgl %r8d, %esi
incq %rdx
cmpq %rdx, %rax
jne 0x2edf
jmp 0x2eff
movl $0x1, %r15d
movl $0x1, %esi
movl %esi, %eax
xorl %edx, %edx
divl %r15d
movl %r15d, %r14d
subl %edx, %r14d
testl %edx, %edx
cmovel %edx, %r14d
addl %esi, %r14d
movslq %ecx, %rdi
movl $0x4, %esi
callq 0x10d0
movq %rax, (%rbx)
shlq $0x20, %r15
orq %r15, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/alignment.c
// Function: get_size_alignment_offsets_for_struct_not_union
struct SizeAndAlignment get_size_alignment_offsets_for_struct_not_union(
    const struct SizeAndAlignment *inner_type_vec, int **ptr_offset_vec,
    int length)
{
	struct SizeAndAlignment res;
	res.alignment = 1;

	/* struct's alignment is the maximum of the members' alignments */
	for (int i = 0; i < length; i++) {
		if (inner_type_vec[i].alignment > res.alignment) {
			res.alignment = inner_type_vec[i].alignment;
		}
	}

	int offset = 0;
	int *offset_vec = calloc(length, sizeof(int));

	for (int i = 0; i < length; i++) {
		if (offset % inner_type_vec[i].alignment) {
			offset += inner_type_vec[i].alignment -
			          (offset % inner_type_vec[i].alignment);
		}
		offset_vec[i] = offset;
		offset += inner_type_vec[i].size;
	}

	if (offset % res.alignment) {
		offset += res.alignment - (offset % res.alignment);
	}

	res.size = offset;
	*ptr_offset_vec = offset_vec;
	return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, %rbx
testl %edx, %edx
jle 0x2fb5
movq %rdi, %r14
movl %r12d, %r15d
movl $0x1, %r13d
xorl %eax, %eax
movl 0x4(%r14,%rax,8), %ecx
cmpl %r13d, %ecx
cmovgl %ecx, %r13d
incq %rax
cmpq %rax, %r15
jne 0x2f60
movl $0x4, %esi
movq %r15, %rdi
callq 0x10d0
movq %rax, %rcx
testl %r12d, %r12d
jle 0x2fcf
xorl %edi, %edi
xorl %esi, %esi
movl 0x4(%r14,%rdi,8), %r8d
movl %esi, %eax
cltd
idivl %r8d
subl %edx, %r8d
testl %edx, %edx
cmovel %edx, %r8d
addl %r8d, %esi
movl %esi, (%rcx,%rdi,4)
addl (%r14,%rdi,8), %esi
incq %rdi
cmpq %rdi, %r15
jne 0x2f8d
jmp 0x2fd1
movslq %r12d, %rdi
movl $0x4, %esi
callq 0x10d0
movq %rax, %rcx
xorl %esi, %esi
movl $0x1, %r13d
jmp 0x2fd1
xorl %esi, %esi
movl %esi, %eax
cltd
idivl %r13d
movl %r13d, %eax
subl %edx, %eax
testl %edx, %edx
cmovel %edx, %eax
addl %esi, %eax
movq %rcx, (%rbx)
shlq $0x20, %r13
orq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/parse_analyze_toplevel.c
// Function: push_offset_and_type
static int
push_offset_and_type(struct AnalyzerState *ptr_ps, const struct Type *ref_type,
                     struct Vector /*<LocalVarInfo>*/ *ptr_offsets_and_types,
                     const char *ident_str)
{

	int offset = add_local_var_to_scope(ptr_ps, ref_type, ident_str);

	struct LocalVarInfo info;
	info.offset = offset;
	info.type = *ref_type;

	struct LocalVarInfo *ptr1 = calloc(1, sizeof(struct LocalVarInfo));
	*ptr1 = info;
	push_vector(ptr_offsets_and_types, ptr1);

	return offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rcx, %rdx
callq 0x38e8
movl %eax, %r15d
movl $0x1, %edi
movl $0x58, %esi
callq 0x10d0
movl $0xa, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r15d, 0x50(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5d9b
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/parse_analyze_statement.c
// Function: add_local_var_to_scope
int add_local_var_to_scope(struct AnalyzerState *ptr_ps,
                           const struct Type *ref_vartype, const char *str)
{
	ptr_ps->newest_offset -= size_of(ptr_ps, ref_vartype);

	struct LocalVarInfo *ptr_varinfo = calloc(1, sizeof(struct LocalVarInfo));
	ptr_varinfo->offset = ptr_ps->newest_offset;
	ptr_varinfo->type = *ref_vartype;
	insert(ptr_ps->scope_chain.var_table, str, ptr_varinfo);

	return ptr_varinfo->offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x2ffc
movl 0x70(%r15), %r13d
subl %eax, %r13d
movl %r13d, 0x70(%r15)
movl $0x1, %edi
movl $0x58, %esi
callq 0x10d0
movq %rax, %r12
movl %r13d, 0x50(%rax)
movl $0xa, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq (%r15), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xa344
movl 0x50(%r12), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/parse_analyze_statement.c
// Function: parse_labeled_statement
struct Statement parse_labeled_statement(struct AnalyzerState *ptr_ps,
                                         const struct Token **ptr_tokvec)
{
	const struct Token *tokvec = *ptr_tokvec;
	enum TokenKind kind = tokvec[0].kind;

	struct SourceLabel l;
	if (kind == RES_DEFAULT) {
		++tokvec;
		l.category = DEFAULT_LABEL;
	} else if (kind == RES_CASE) {
		++tokvec;
		const struct UntypedExpr u = parse_constant_expression(&tokvec);
		int case_int =
		    typecheck_constant_integral_expression(ptr_ps, &u, "case");
		l.category = CASE_LABEL;
		l.case_int = case_int;
	} else {
		l.ident_str = tokvec[0].ident_str;
		++tokvec;
		l.category = IDENT_LABEL;
	}
	expect_and_consume(&tokvec, COLON,
	                   "colon of `default:`, `case VALUE:`, or `ident:`");

	struct Statement s = parse_statement(ptr_ps, &tokvec);

	struct SourceLabel *ptr_l = calloc(1, sizeof(struct SourceLabel));
	*ptr_l = l;
	push_vector(&s.labels, ptr_l);
	*ptr_tokvec = tokvec;
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdx), %rax
movl (%rax), %ecx
cmpl $0x40, %ecx
je 0x398e
cmpl $0x41, %ecx
jne 0x39c5
addq $0x20, %rax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
jmp 0x39c3
addq $0x20, %rax
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
callq 0x8acd
leaq 0xae79(%rip), %rdx      # 0xe828
movq %r15, %rdi
movq %r12, %rsi
callq 0x5e64
movl %eax, -0x34(%rbp)
movl $0x1, %r12d
jmp 0x39db
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movl $0x2, %r12d
leaq 0xae4b(%rip), %rdx      # 0xe82d
leaq -0x30(%rbp), %r13
movq %r13, %rdi
movl $0x1d, %esi
callq 0x9563
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3a4f
movl $0x1, %edi
movl $0x10, %esi
callq 0x10d0
movl %r12d, (%rax)
movl -0x34(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq %r14, %rdi
addq $0x378, %rdi            # imm = 0x378
movq %rax, %rsi
callq 0x5d9b
movq (%r13), %rax
movq %rax, (%rbx)
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen_expression.c
// Function: pass_args
static void pass_args(struct PrinterState *ptr_prs,
                      const struct Vector /*<Expr>*/ *ref_args)
{
	for (int counter = ref_args->length - 1; counter >= 0; counter--) {
		const struct Expr *ptr_expr_ = ref_args->vector[counter];

		print_expression(ptr_prs, ptr_expr_);
	}

	for (int counter = 0; counter < ref_args->length; counter++) {
		if (counter >= 6) {
			break;
		}
		const struct Expr *ptr_expr_ = ref_args->vector[counter];

		switch (size_of_basic(&ptr_expr_->details.type, "argument")) {
		case 1:
		case 4:
			gen_pop_to_reg_4byte(get_reg_name_from_arg_pos_4byte(counter));
			break;
		case 8:
			gen_pop_to_reg_8byte(get_reg_name_from_arg_pos_8byte(counter));
			break;
		default:
			unsupported("Unsupported width in function argument");
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movslq (%rsi), %r15
testq %r15, %r15
jle 0x57ed
movq %rsi, %rbx
movq %rdi, %r14
incq %r15
movq 0x8(%rbx), %rax
movq -0x10(%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x4e8f
decq %r15
cmpq $0x1, %r15
ja 0x5772
cmpl $0x0, (%rbx)
jle 0x57ed
xorl %r14d, %r14d
leaq 0x9c24(%rip), %r15      # 0xf3bf
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %rdi
movq %r15, %rsi
callq 0x95dd
cmpl $0x1, %eax
je 0x57ba
cmpl $0x8, %eax
je 0x57cc
cmpl $0x4, %eax
jne 0x57f8
movl %r14d, %edi
callq 0xb80e
movq %rax, %rdi
callq 0xb1cf
jmp 0x57dc
movl %r14d, %edi
callq 0xb752
movq %rax, %rdi
callq 0xb215
cmpq $0x4, %r14
ja 0x57ed
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x579b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9ba2(%rip), %rdi      # 0xf3a1
callq 0x9581
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen_expression.c
// Function: count_args
static int count_args(const struct Vector /*<Expr>*/ *ref_args)
{
	int ans = 0;
	for (int counter = ref_args->length - 1; counter >= 0; counter--) {
		ans++;
	}

	for (int counter = 0; counter < ref_args->length; counter++) {
		if (counter >= 6) {
			break;
		}
		const struct Expr *ptr_expr_ = ref_args->vector[counter];

		switch (size_of_basic(&ptr_expr_->details.type, "argument")) {
		case 1:
		case 4:
		case 8:
			ans--;
			break;
		default:
			unsupported("Unsupported width in function argument");
		}
	}
	return ans;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rdi), %ebx
testl %ebx, %ebx
jle 0x585f
movq %rdi, %r14
xorl %r13d, %r13d
leaq 0x9b9a(%rip), %r15      # 0xf3bf
movl $0x112, %r12d           # imm = 0x112
movq 0x8(%r14), %rax
movq (%rax,%r13,8), %rdi
movq %r15, %rsi
callq 0x95dd
cmpl $0x8, %eax
ja 0x5872
btl %eax, %r12d
jae 0x5872
leaq 0x1(%r13), %rax
cmpq $0x4, %r13
ja 0x585b
movslq (%r14), %rcx
movq %rax, %r13
cmpq %rcx, %rax
jl 0x582b
subl %eax, %ebx
jmp 0x5861
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9b28(%rip), %rdi      # 0xf3a1
callq 0x9581
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen_expression.c
// Function: print_expression_or_addr_of_struct_or_union
void print_expression_or_addr_of_struct_or_union(struct PrinterState *ptr_prs,
                                                 const struct Expr *ref_expr,
                                                 const char *msg)
{
	if (is_struct_or_union(&ref_expr->details.type)) {
		print_address_of_lvalue_or_struct_or_union(ptr_prs, ref_expr, msg);
	} else {
		print_expression(ptr_prs, ref_expr);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x95ca
movq %r15, %rdi
movq %rbx, %rsi
testl %eax, %eax
je 0x58b5
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4b6c
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4e8f
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen_expression.c
// Function: handle_builtin
void handle_builtin(struct PrinterState *ptr_prs, const char *ident_str)
{
	if (strcmp(ident_str, "__builtin_va_end") == 0) {
		printf("// do nothing for %s\n", ident_str);
		return;
	} else if (strcmp(ident_str, "__builtin_va_start") == 0) {
		int float_arg_num = 0; /* since we still cannot handle them */

		gen_va_start(8 * ptr_prs->integral_explicit_arg_num,
		             48 * (1 + float_arg_num), ptr_prs->reg_save_area);
		return;
	}

	printf("***** Help me: %s\n", ident_str);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x973b(%rip), %rsi      # 0xf013
movq %rbx, %rdi
callq 0x10e0
testl %eax, %eax
je 0x5900
leaq 0x974f(%rip), %rsi      # 0xf03a
movq %rbx, %rdi
callq 0x10e0
testl %eax, %eax
je 0x5915
leaq 0x974f(%rip), %rdi      # 0xf04d
jmp 0x5907
leaq 0x971d(%rip), %rdi      # 0xf024
movq %rbx, %rsi
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x1070
movl 0x44(%r14), %edi
movl 0x48(%r14), %edx
shll $0x3, %edi
movl $0x30, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0xb778
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/codegen_expression.c
// Function: print_expression_as_lvalue
static void print_expression_as_lvalue(struct PrinterState *ptr_prs,
                                       const struct Expr *ref_expr)
{
	const struct Expr expr = *ref_expr;
	print_address_of_lvalue_or_struct_or_union(ptr_prs, &expr, "as lvalue");
	switch (expr.category) {
	case FPCALL_EXPR_RETURNING_INTEGER_CLASS:
	case FPCALL_EXPR_RETURNING_MEMORY_CLASS:
	case FUNCCALL_EXPR_RETURNING_INTEGER_CLASS:
	case FUNCCALL_EXPR_RETURNING_MEMORY_CLASS: {
		unsupported("struct returned by function used as a pure rvalue");
	}
	case LOCAL_VAR_: {
		gen_push_from_local_nbyte(
		    size_of_basic(&expr.details.type, "local var as lvalue"),
		    expr.local_var_offset);

		return;
	}
	case GLOBAL_VAR_: {
		printf("//load from global `%s`\n", expr.global_var_name);
		gen_peek_deref_push_nbyte(
		    size_of_basic(&expr.details.type, "global var as lvalue"));

		return;
	}
	case UNARY_OP_EXPR:
		if (expr.unary_operator == UNARY_OP_ASTERISK) {
			gen_peek_deref_push_nbyte(
			    size_of_basic(&expr.details.type, "*expr as lvalue"));
			return;
		} else {
			simple_error("the only unary operator that can create "
			             "lvalue is `*`\n");
		}
	default:
		simple_error("doesn't seem like an lvalue\n");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
leaq -0x110(%rbp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
callq 0x1100
leaq 0x9494(%rip), %rdx      # 0xedee
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4b6c
movl 0xa0(%r14), %eax
cmpl $0x19, %eax
ja 0x59de
cmpl $0x7, %eax
je 0x59a3
cmpl $0x8, %eax
jne 0x59c8
leaq -0x110(%rbp), %rbx
movq 0xd0(%rbx), %rsi
leaq 0x9956(%rip), %rdi      # 0xf2e6
xorl %eax, %eax
callq 0x1070
leaq 0x9961(%rip), %rsi      # 0xf2ff
movq %rbx, %rdi
jmp 0x59f7
leaq 0x9928(%rip), %rsi      # 0xf2d2
leaq -0x110(%rbp), %rbx
movq %rbx, %rdi
callq 0x95dd
movl 0xf0(%rbx), %esi
movl %eax, %edi
callq 0xa89a
jmp 0x5a03
movl $0x3600000, %ecx        # imm = 0x3600000
btl %eax, %ecx
jae 0x59de
leaq 0x98c7(%rip), %rdi      # 0xf2a0
callq 0x9581
cmpl $0x6, %eax
jne 0x5a1b
cmpl $0x7, -0x68(%rbp)
jne 0x5a0f
leaq 0x9924(%rip), %rsi      # 0xf314
leaq -0x110(%rbp), %rdi
callq 0x95dd
movl %eax, %edi
callq 0xaa6c
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x9477(%rip), %rdi      # 0xee8d
callq 0x9546
leaq 0x936a(%rip), %rdi      # 0xed8c
callq 0x9546
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/main.c
// Function: main
int main(int argc, char const **argv)
{
	struct __FILE *fp = stdin;
	struct Vector macros = init_vector();

	for (int i = 1; i < argc; i++) {
		if (strncmp(argv[i], "-D", 2) == 0) {
			push_vector(&macros, argv[i] + 2);
		} else if (strncmp(argv[i], "--ir=", 5) == 0) {
			const char *ir_filename = argv[i] + 5;
			global_ir = fopen(ir_filename, "w");
			if (!global_ir) {
				fprintf(stderr, "failed to write to file `%s`.\n", ir_filename);
				exit(EXIT_FAILURE);
			}
		} else if (strcmp(argv[i], "-pedantic") == 0) {
			global_flag_pedantic = 1;
		} else {
			const char *filename = argv[i];
			fp = fopen(filename, "r");
			if (!fp) {
				fprintf(stderr, "failed to open file `%s`.\n", filename);
				exit(EXIT_FAILURE);
			}
		}
	}

	char *str = read_from_file(fp);
	const struct Token *tokvec = read_and_preprocess(str, &macros);
	++tokvec; /* skip the dummy token BEGINNING */
	const struct Vector /*<Toplevel>*/ vec = parse(tokvec);
	generate(&vec);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movl %edi, %r15d
movq 0x113f6(%rip), %rax     # 0x16fd8
movq (%rax), %r14
callq 0x5cf8
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
cmpl $0x2, %r15d
jl 0x5ca7
movl %r15d, %r15d
movl $0x1, %r12d
movq (%rbx,%r12,8), %r13
cmpb $0x2d, (%r13)
jne 0x5c29
cmpb $0x44, 0x1(%r13)
jne 0x5c29
addq $0x2, %r13
leaq -0x38(%rbp), %rdi
movq %r13, %rsi
callq 0x5d9b
jmp 0x5c9b
movl $0x5, %edx
movq %r13, %rdi
leaq 0x9790(%rip), %rsi      # 0xf3c8
callq 0x1030
testl %eax, %eax
je 0x5c6d
movq %r13, %rdi
leaq 0x97a4(%rip), %rsi      # 0xf3ef
callq 0x10e0
testl %eax, %eax
je 0x5c91
movq %r13, %rdi
leaq 0xa670(%rip), %rsi      # 0x102ce
callq 0x1130
movq %rax, %r14
testq %rax, %rax
jne 0x5c9b
jmp 0x5ce5
addq $0x5, %r13
movq %r13, %rdi
leaq 0x9753(%rip), %rsi      # 0xf3ce
callq 0x1130
leaq 0x11459(%rip), %rcx     # 0x170e0
movq %rax, (%rcx)
testq %rax, %rax
jne 0x5c9b
jmp 0x5ced
movl $0x1, 0x11441(%rip)     # 0x170dc
incq %r12
cmpq %r12, %r15
jne 0x5c05
movq %r14, %rdi
callq 0xd23c
leaq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0xbf50
leaq 0x20(%rax), %rdi
callq 0x3193
leaq -0x48(%rbp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x29ab
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x159a
movq %r13, %rdi
callq 0x15c1
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/vector.c
// Function: init_vector_
struct Vector *init_vector_(void)
{
	struct Vector *ptr_res = calloc(1, sizeof(struct Vector));
	ptr_res->length = 0;
	ptr_res->capacity = 256;
	ptr_res->vector = calloc(ptr_res->capacity, sizeof(void *));
	return ptr_res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x1, %edi
movl $0x10, %esi
callq 0x10d0
movq %rax, %rbx
movl $0x100, 0x4(%rax)       # imm = 0x100
movl $0x100, %edi            # imm = 0x100
movl $0x8, %esi
callq 0x10d0
movq %rax, 0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/vector.c
// Function: extend_vector
void extend_vector(struct Vector *ptr)
{
	if (ptr->capacity < ptr->length + 1) {
		ptr->vector =
		    realloc(ptr->vector, ptr->capacity * 2 * sizeof(void *));

		ptr->capacity *= 2;
	}
}

// Assembly:
movslq 0x4(%rdi), %rsi
cmpl (%rdi), %esi
jg 0x5d9a
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
shlq $0x4, %rsi
callq 0x1120
movq %rax, 0x8(%rbx)
shll 0x4(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/vector.c
// Function: pop_vector
const void *pop_vector(struct Vector *ptr)
{
	if (ptr->length == 0) {
		assert("tried to pop an empty vector" && 0);
	}
	--(ptr->length);
	return ptr->vector[ptr->length]; /* safe, since it is not yet released or
	                                    anything */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %eax
testl %eax, %eax
jne 0x5ddd
xorl %edi, %edi
xorl %eax, %eax
callq 0x243c
movl (%rbx), %eax
leal -0x1(%rax), %ecx
movl %ecx, (%rbx)
movq 0x8(%rbx), %rcx
cltq
movq -0x8(%rcx,%rax,8), %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/vector.c
// Function: concat_vector
void concat_vector(struct Vector *ptr_ans, const struct Vector *ptr_vec)
{
	if (!ptr_ans) {
		fprintf(stderr, "NULL POINTER IN THE FIRST ARGUMENT\n");
		exit(1);
	}

	if (!ptr_vec) {
		fprintf(stderr, "NULL POINTER IN THE SECOND ARGUMENT\n");
		exit(1);
	}

	if (!ptr_vec->vector) {
		fprintf(stderr, "OH MY GOD: INVALID VECTOR IN THE SECOND ARGUMENT\n");
		exit(1);
	}

	for (int i = 0; i < ptr_vec->length; i++) {
		push_vector(ptr_ans, ptr_vec->vector[i]);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x5e53
movq %rsi, %rbx
testq %rsi, %rsi
je 0x5e58
cmpq $0x0, 0x8(%rbx)
je 0x5e5d
cmpl $0x0, (%rbx)
jle 0x5e4a
movq %rdi, %r14
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movq (%rax,%r15,8), %r12
movq %r14, %rdi
callq 0x5d6f
movq 0x8(%r14), %rax
movslq (%r14), %rcx
movq %r12, (%rax,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, (%r14)
incq %r15
movslq (%rbx), %rax
cmpq %rax, %r15
jl 0x5e1e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x1638
callq 0x1610
callq 0x15e8
nop
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/typecheck_expression.c
// Function: typecheck_constant_integral_expression
int typecheck_constant_integral_expression(struct AnalyzerState *ptr_ps,
                                           const struct UntypedExpr *ref_uexpr,
                                           const char *context)
{
	const struct UntypedExpr uexpr = *ref_uexpr;
	switch (uexpr.category) {
	case INT_LITERAL_:
		return uexpr.int_value;
	case VAR: {
		const char *name = uexpr.var_name;

		if (is_local_var(&ptr_ps->scope_chain, name)) {
			break;
		}

		const struct EnumeratorAndValue *ptr_enum_and_value =
		    get_global_enumerator(&ptr_ps->global_enumerator_list, name);

		if (!ptr_enum_and_value) {
			break;
		}

		return ptr_enum_and_value->value;
	}
	default:
		break;
	}

	fprintf(stderr, "Expected const expression, but did not get one.\n");
	fprintf(stderr, "context: %s\n", context);
	exit(EXIT_FAILURE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x4(%rsi), %eax
cmpl $0x4, %eax
je 0x5ec3
movq %rdx, %rbx
cmpl $0x3, %eax
jne 0x5ed2
movq %rdi, %r14
movq 0x28(%rsi), %r15
movq %rdi, %r12
movq (%r12), %rdi
movq %r15, %rsi
callq 0xa3f8
testl %eax, %eax
jne 0x5ed2
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x5e89
addq $0x88, %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5eda
testq %rax, %rax
je 0x5ed2
movq %rax, %rsi
addq $0x8, %rsi
jmp 0x5ec7
addq $0x20, %rsi
movl (%rsi), %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x1660
// File: /workspace/github_c_makefile_star2_O3/hsjoihs[P]c-compiler/typecheck_expression.c
// Function: get_global_enumerator
static const struct EnumeratorAndValue *
get_global_enumerator(const struct Vector /*<EnumeratorAndValue>*/ *ref_list,
                      const char *name)
{
	for (int i = 0; i < ref_list->length; i++) {
		const struct EnumeratorAndValue *ptr_vec_i = ref_list->vector[i];
		if (strcmp(ptr_vec_i->ident, name) == 0) {
			return ptr_vec_i;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq (%rdi), %r15
testq %r15, %r15
jle 0x5f15
movq %rsi, %rbx
movq 0x8(%rdi), %r12
xorl %r13d, %r13d
movq (%r12,%r13,8), %r14
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x10e0
testl %eax, %eax
je 0x5f18
incq %r13
cmpq %r13, %r15
jne 0x5efa
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq