// File: /workspace/github_c_makefile_star2_O3/kieselsteini[P]PiXL-old/pixl.c
// Function: px_lua_init
static int px_lua_init(lua_State *L) {
  SDL_AudioSpec want, have;
  int i, flags;
  const char *str;

  // setup some hints
  str = px_check_arg("-video");
  if (str) SDL_SetHint(SDL_HINT_RENDER_DRIVER, str);

  // check for fullscreen
  if (px_check_parm("-window")) { fullscreen = SDL_FALSE; flags = SDL_WINDOW_RESIZABLE; }
  else { fullscreen = SDL_TRUE; flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_FULLSCREEN_DESKTOP; }

  // init network
  net_initialize(L);

  // init SDL
  if (SDL_Init(SDL_INIT_EVERYTHING)) luaL_error(L, "SDL_Init() failed: %s", SDL_GetError());

  // create window + texture
  window = SDL_CreateWindow(PX_WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, PX_SCREEN_WIDTH, PX_SCREEN_HEIGHT, flags);
  if (!window) luaL_error(L, "SDL_CreateWindow() failed: %s", SDL_GetError());
  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
  if (!renderer) luaL_error(L, "SDL_CreateRenderer() failed: %s", SDL_GetError());
  px_create_texture(L, PX_SCREEN_WIDTH, PX_SCREEN_HEIGHT);
  SDL_ShowCursor(0);

  // audio init
  if (!px_check_parm("-nosound")) {
    SDL_zero(want); SDL_zero(have);
    want.callback = px_audio_mixer_callback;
    want.channels = 1;
    want.format = AUDIO_S8;
    want.freq = PX_AUDIO_FREQUENCY;
    want.samples = 1024 * 4;
    str = px_check_arg("-audio");
    audio_device = SDL_OpenAudioDevice(str, SDL_FALSE, &want, &have, 0);
    if (have.format != AUDIO_S8) luaL_error(L, "SDL_OpenAudioDevice() didn't provide AUDIO_S8 format");
    if (have.channels != 1) luaL_error(L, "SDL_OpenAudioDevice() didn't provide a mono channel");
    if (!audio_device) luaL_error(L, "SDL_OpenAudioDevice() failed: %s", SDL_GetError());
    mixing_frequency = (float)have.freq;
    SDL_PauseAudioDevice(audio_device, SDL_FALSE);
  }

  // init some stuff
  px_randomseed(4096); for (i = 0; i < PX_AUDIO_NOISE; ++i) audio_noise[i] = px_rand() % 8 - 4;
  for (i = 0; i < PX_AUDIO_CHANNELS; ++i) SDL_zerop(&channels[i]);
  running = SDL_TRUE;
  SDL_zero(inputs); SDL_zero(translation);
  px_open_controllers(L);
  px_randomseed(47 * 1024); // reset prng

  // load the Lua script
  str = px_check_arg("-file");
  if (luaL_loadfile(L, str ? str : "game.lua")) lua_error(L);
  lua_call(L, 0, 0);

  // run main loop
  px_run_main_loop(L);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x6a04(%rip), %rdi      # 0x35640
callq 0x30a2b
testl %eax, %eax
je 0x2ec6d
incl %eax
cmpl 0x1389f(%rip), %eax     # 0x424ec
jge 0x2ec6d
movq 0x1389a(%rip), %rcx     # 0x424f0
cltq
movq (%rcx,%rax,8), %rsi
testq %rsi, %rsi
je 0x2ec6d
leaq 0x69df(%rip), %rdi      # 0x35647
callq 0x6790
leaq 0x69e5(%rip), %rdi      # 0x35659
callq 0x30a2b
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl $0x1021, %eax           # imm = 0x1021
movl $0x20, %ebp
cmovel %eax, %ebp
movl %ecx, 0x113eb1(%rip)    # 0x142b44
movl $0xffffffff, 0x113eaf(%rip) # imm = 0xFFFFFFFF
movl $0xf231, %edi           # imm = 0xF231
callq 0x6440
testl %eax, %eax
je 0x2ecc4
callq 0x6380
leaq 0x69aa(%rip), %rsi      # 0x35661
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
leaq 0x69ac(%rip), %rdi      # 0x35677
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl $0x100, %ecx            # imm = 0x100
movl $0xf0, %r8d
movl %ebp, %r9d
callq 0x6070
movq %rax, 0x137e1(%rip)     # 0x424d0
testq %rax, %rax
jne 0x2ed14
callq 0x6380
leaq 0x6983(%rip), %rsi      # 0x35683
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq 0x137bc(%rip), %rax     # 0x424d0
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x6, %edx
callq 0x6050
movq %rax, 0x137ab(%rip)     # 0x424d8
testq %rax, %rax
jne 0x2ed4b
callq 0x6380
leaq 0x6963(%rip), %rsi      # 0x356a1
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xf0, %edx
callq 0x308c5
xorl %edi, %edi
callq 0x6890
leaq 0x6956(%rip), %rdi      # 0x356c1
callq 0x30a2b
testl %eax, %eax
jne 0x2ee81
leaq 0x68(%rsp), %r15
xorl %r14d, %r14d
movl $0x20, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6250
leaq 0x10(%rsp), %rdi
movl $0x20, %edx
xorl %esi, %esi
callq 0x6250
leaq 0x1cd0(%rip), %rax      # 0x30a77
movq %rax, 0x10(%r15)
movb $0x1, 0x6(%r15)
movw $0x8008, 0x4(%r15)      # imm = 0x8008
movl $0xac44, (%r15)         # imm = 0xAC44
movw $0x1000, 0x8(%r15)      # imm = 0x1000
leaq 0x68fe(%rip), %rdi      # 0x356ca
callq 0x30a2b
testl %eax, %eax
je 0x2edf1
incl %eax
cmpl 0x1370f(%rip), %eax     # 0x424ec
jge 0x2edee
movq 0x1370a(%rip), %rcx     # 0x424f0
cltq
movq (%rcx,%rax,8), %r14
jmp 0x2edf1
xorl %r14d, %r14d
leaq 0x68(%rsp), %rdx
leaq 0x10(%rsp), %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x65b0
movl %eax, 0x136d7(%rip)     # 0x424e8
cmpw $0x8008, 0x4(%r15)      # imm = 0x8008
je 0x2ee2b
leaq 0x68b0(%rip), %rsi      # 0x356d1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdb8f
cmpb $0x1, 0x16(%rsp)
je 0x2ee43
leaq 0x68cd(%rip), %rsi      # 0x35706
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdb8f
movl 0x1369f(%rip), %edi     # 0x424e8
testl %edi, %edi
jne 0x2ee6c
callq 0x6380
leaq 0x68e1(%rip), %rsi      # 0x3573a
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movl 0x1367c(%rip), %edi     # 0x424e8
cvtsi2ssl 0x10(%rsp), %xmm0
movss %xmm0, 0x113c56(%rip)   # 0x142ad0
xorl %esi, %esi
callq 0x6610
movl $0x1000, %eax           # imm = 0x1000
movl $0x400, %ecx            # imm = 0x400
movl %eax, %edx
shll $0xd, %edx
xorl %eax, %edx
movl %edx, %esi
shrl $0x11, %esi
xorl %edx, %esi
movl %esi, %eax
shll $0x5, %eax
xorl %esi, %eax
decl %ecx
jne 0x2ee8b
xorl %ecx, %ecx
leaq 0x113823(%rip), %rdx    # 0x1426d0
movl %eax, %esi
shll $0xd, %esi
xorl %eax, %esi
movl %esi, %edi
shrl $0x11, %edi
xorl %esi, %edi
movl %edi, %eax
shll $0x5, %eax
xorl %edi, %eax
andb $0x7, %dil
addb $-0x4, %dil
movb %dil, (%rcx,%rdx)
incq %rcx
cmpq $0x400, %rcx            # imm = 0x400
jne 0x2eead
movl %eax, 0x113c68(%rip)    # 0x142b48
xorl %r14d, %r14d
leaq 0x113626(%rip), %r15    # 0x142510
leaq (%r15,%r14), %rdi
movl $0x38, %edx
xorl %esi, %esi
callq 0x6250
addq $0x38, %r14
cmpq $0x1c0, %r14            # imm = 0x1C0
jne 0x2eeea
movl $0x1, 0x113c2f(%rip)    # 0x142b40
leaq 0x113bc8(%rip), %r14    # 0x142ae0
movl $0x60, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x6250
leaq 0x1135d2(%rip), %rdi    # 0x142500
movl $0x8, %edx
xorl %esi, %esi
callq 0x6250
movq %rbx, %rdi
callq 0x30dfb
movl $0xbc00, %ecx           # imm = 0xBC00
movl $0x400, %eax            # imm = 0x400
movl %ecx, %edx
shll $0xd, %edx
xorl %ecx, %edx
movl %edx, %esi
shrl $0x11, %esi
xorl %edx, %esi
movl %esi, %ecx
shll $0x5, %ecx
xorl %esi, %ecx
decl %eax
jne 0x2ef4c
movl %ecx, 0x113bdd(%rip)    # 0x142b48
leaq 0x67e9(%rip), %rdi      # 0x3575b
callq 0x30a2b
testl %eax, %eax
je 0x2ef94
incl %eax
cmpl 0x13569(%rip), %eax     # 0x424ec
jge 0x2ef94
movq 0x13564(%rip), %rcx     # 0x424f0
cltq
movq (%rcx,%rax,8), %rax
jmp 0x2ef96
xorl %eax, %eax
testq %rax, %rax
leaq 0x67c1(%rip), %rsi      # 0x35761
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9f0
testl %eax, %eax
je 0x2efba
movq %rbx, %rdi
callq 0xc83a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xbea9
leaq 0x510b(%rip), %rsi      # 0x340dd
movq %rbx, %rdi
callq 0xad70
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x2eff2
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xbea9
jmp 0x2effc
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x8f61
callq 0x64e0
cmpl $0x0, 0x113b38(%rip)    # 0x142b40
je 0x2f5a0
leaq 0x30(%rsp), %r15
leaq 0x6774(%rip), %r12      # 0x3578e
leaq 0x631f(%rip), %rbp      # 0x35340
xorl %r13d, %r13d
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x6310
testl %eax, %eax
je 0x2f350
movl 0x30(%rsp), %eax
cmpl $0x400, %eax            # imm = 0x400
jg 0x2f06d
leal -0x300(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2f09f
cmpl $0x100, %eax            # imm = 0x100
je 0x2f1ad
cmpl $0x400, %eax            # imm = 0x400
jne 0x2f027
movq 0x44(%rsp), %rax
movq %rax, 0x113a79(%rip)    # 0x142ae4
jmp 0x2f027
leal -0x401(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2f16f
leal -0x651(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2f10c
addl $0xfffff9ad, %eax       # imm = 0xFFFFF9AD
cmpl $0x2, %eax
jae 0x2f027
movq %rbx, %rdi
callq 0x30dfb
jmp 0x2f027
movl 0x44(%rsp), %ecx
cmpl $0x300, %eax            # imm = 0x300
jne 0x2f0db
cmpl $0x78, %ecx
jle 0x2f188
leal -0x4000004f(%rcx), %eax
cmpl $0x3, %eax
ja 0x2f22c
leaq 0x5cd7(%rip), %rcx      # 0x34da0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x20, %ax
jmp 0x2f326
cmpl $0x77, %ecx
jle 0x2f1bc
leal -0x4000004f(%rcx), %eax
cmpl $0x3, %eax
ja 0x2f21b
leaq 0x5c96(%rip), %rcx      # 0x34d90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0xffdf, %ax            # imm = 0xFFDF
jmp 0x2f304
movzbl 0x3c(%rsp), %ecx
cmpw $0xe, %cx
ja 0x2f027
movl $0x784f, %edx           # imm = 0x784F
btl %ecx, %edx
jae 0x2f027
movl 0x38(%rsp), %esi
cmpq $0x7, %rsi
ja 0x2f027
movzwl %cx, %ecx
leaq 0x623f(%rip), %rdx      # 0x35380
movb (%rdx,%rcx,2), %cl
movl $0x1, %edx
shll %cl, %edx
leaq (%rsi,%rsi,2), %rcx
leaq (%r14,%rcx,4), %rcx
movzwl (%rcx), %esi
cmpl $0x651, %eax            # imm = 0x651
jne 0x2f344
orl %edx, %esi
movw %si, (%rcx)
orw %dx, 0x2(%rcx)
jmp 0x2f027
movzbl 0x40(%rsp), %ecx
cmpl $0x1, %ecx
je 0x2f1dc
cmpl $0x3, %ecx
jne 0x2f027
movw $0x1, %cx
jmp 0x2f1de
cmpl $0x60, %ecx
jg 0x2f23d
cmpl $0xd, %ecx
je 0x2f1a4
cmpl $0x1b, %ecx
je 0x2f1ad
cmpl $0x20, %ecx
jne 0x2f027
movw $0x100, %ax             # imm = 0x100
jmp 0x2f326
movl $0x0, 0x113989(%rip)    # 0x142b40
jmp 0x2f027
cmpl $0x60, %ecx
jg 0x2f265
cmpl $0xd, %ecx
je 0x2f1d3
cmpl $0x20, %ecx
jne 0x2f027
movw $0xfeff, %ax            # imm = 0xFEFF
jmp 0x2f304
xorl %ecx, %ecx
movl $0x1, %edx
shll %cl, %edx
movzwl 0x1138f4(%rip), %ecx    # 0x142ae0
movzwl %dx, %edx
cmpl $0x401, %eax            # imm = 0x401
jne 0x2f20b
orl %edx, %ecx
movw %cx, 0x1138e1(%rip)     # 0x142ae0
orw %dx, 0x1138dc(%rip)     # 0x142ae2
jmp 0x2f027
notl %edx
andl %edx, %ecx
movw %cx, 0x1138ca(%rip)     # 0x142ae0
jmp 0x2f027
leal -0x79(%rcx), %eax
cmpl $0x2, %eax
jae 0x2f280
movw $0xfffe, %ax            # imm = 0xFFFE
jmp 0x2f304
leal -0x79(%rcx), %eax
cmpl $0x2, %eax
jae 0x2f28f
movw $0x1, %ax
jmp 0x2f326
cmpl $0x61, %ecx
je 0x2f322
movw $0x8, %ax
cmpl $0x73, %ecx
je 0x2f326
cmpl $0x78, %ecx
jne 0x2f027
movw $0x2, %ax
jmp 0x2f326
cmpl $0x61, %ecx
je 0x2f2ee
movw $0xfff7, %ax            # imm = 0xFFF7
cmpl $0x73, %ecx
je 0x2f304
jmp 0x2f027
cmpl $0x78, %ecx
jne 0x2f027
movw $0xfffd, %ax            # imm = 0xFFFD
jmp 0x2f304
cmpl $0x40000045, %ecx       # imm = 0x40000045
jne 0x2f027
xorl %eax, %eax
cmpl $0x0, 0x1138a0(%rip)    # 0x142b44
sete %al
movl %eax, 0x113897(%rip)    # 0x142b44
movq 0x1321c(%rip), %rdi     # 0x424d0
movl $0x0, %esi
movl $0x1001, %eax           # imm = 0x1001
cmovel %eax, %esi
callq 0x6540
cmpl $0x0, 0x113877(%rip)    # 0x142b44
jne 0x2f027
movq 0x131f6(%rip), %rdi     # 0x424d0
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
callq 0x6080
jmp 0x2f027
movw $0xfffb, %ax            # imm = 0xFFFB
jmp 0x2f304
movw $0xff7f, %ax            # imm = 0xFF7F
jmp 0x2f304
movw $0xffbf, %ax            # imm = 0xFFBF
jmp 0x2f304
movw $0xffef, %ax            # imm = 0xFFEF
andw %ax, 0x1137d5(%rip)     # 0x142ae0
jmp 0x2f027
movw $0x80, %ax
jmp 0x2f326
movw $0x40, %ax
jmp 0x2f326
movw $0x10, %ax
jmp 0x2f326
movw $0x4, %ax
movd %eax, %xmm0
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
por 0x1137a9(%rip), %xmm0   # 0x142ae0
movd %xmm0, 0x1137a1(%rip)   # 0x142ae0
jmp 0x2f027
notl %edx
andl %edx, %esi
movw %si, (%rcx)
jmp 0x2f027
callq 0x64e0
subl (%rsp), %r13d
movl %eax, (%rsp)
addl %eax, %r13d
cmpl $0x21, %r13d
jb 0x2f3b2
movq %rbx, %rdi
movq %r12, %rsi
callq 0xad70
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x2f388
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xbea9
jmp 0x2f392
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x8f61
movl $0x2, %eax
movw $0x0, (%rax,%r14)
addq $0xc, %rax
cmpq $0x62, %rax
jne 0x2f397
addl $-0x21, %r13d
cmpl $0x20, %r13d
ja 0x2f365
movq 0x13127(%rip), %rdi     # 0x424e0
testq %rdi, %rdi
je 0x2f529
xorl %esi, %esi
leaq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x65d0
testl %eax, %eax
je 0x2f3f0
callq 0x6380
movq %rbx, %rdi
leaq 0x63f0(%rip), %rsi      # 0x357d6
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movl 0x113116(%rip), %esi    # 0x14250c
testl %esi, %esi
jle 0x2f474
movl 0x113108(%rip), %edx    # 0x142508
leaq 0x130f9(%rip), %rax     # 0x42500
xorl %ecx, %ecx
testl %edx, %edx
jle 0x2f466
movl 0x4(%rsp), %edx
imull %ecx, %edx
movslq %edx, %rsi
addq 0x8(%rsp), %rsi
movq %rax, %rdi
xorl %r8d, %r8d
movzbl (%rdi), %edx
andl $0xf, %edx
movb $-0x1, (%rsi,%r8,4)
movb 0x2(%rbp,%rdx,4), %r9b
movb %r9b, 0x1(%rsi,%r8,4)
movb (%rbp,%rdx,4), %r9b
movb 0x1(%rbp,%rdx,4), %dl
movb %dl, 0x2(%rsi,%r8,4)
movb %r9b, 0x3(%rsi,%r8,4)
incq %r8
movslq 0x1130b4(%rip), %rdx    # 0x142508
addq $0x400, %rdi            # imm = 0x400
cmpq %rdx, %r8
jl 0x2f422
movl 0x1130a6(%rip), %esi    # 0x14250c
incq %rcx
movslq %esi, %rdi
incq %rax
cmpq %rdi, %rcx
jl 0x2f409
movq 0x13065(%rip), %rdi     # 0x424e0
callq 0x6660
movq 0x13051(%rip), %rdi     # 0x424d8
movl $0x10, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xff, %r8d
callq 0x6690
testl %eax, %eax
je 0x2f4be
callq 0x6380
movq %rbx, %rdi
leaq 0x62e1(%rip), %rsi      # 0x35795
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq 0x13013(%rip), %rdi     # 0x424d8
callq 0x6480
testl %eax, %eax
je 0x2f4e7
callq 0x6380
movq %rbx, %rdi
leaq 0x62dc(%rip), %rsi      # 0x357b9
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq 0x12fea(%rip), %rdi     # 0x424d8
movq 0x12feb(%rip), %rsi     # 0x424e0
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6520
testl %eax, %eax
je 0x2f51b
callq 0x6380
movq %rbx, %rdi
leaq 0x62e2(%rip), %rsi      # 0x357f3
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq 0x12fb6(%rip), %rdi     # 0x424d8
callq 0x60e0
jmp 0x2f590
movq 0x12fa8(%rip), %rdi     # 0x424d8
movl $0x40, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xff, %r8d
callq 0x6690
testl %eax, %eax
je 0x2f567
callq 0x6380
movq %rbx, %rdi
leaq 0x6238(%rip), %rsi      # 0x35795
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
movq 0x12f6a(%rip), %rdi     # 0x424d8
callq 0x6480
testl %eax, %eax
je 0x2f590
callq 0x6380
movq %rbx, %rdi
leaq 0x6233(%rip), %rsi      # 0x357b9
movq %rax, %rdx
xorl %eax, %eax
callq 0xdb8f
cmpl $0x0, 0x1135a9(%rip)    # 0x142b40
movl (%rsp), %eax
jne 0x2f024
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq