// File: /workspace/github_c_makefile_star2_O1/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 0x5c58(%rip), %rdi      # 0x32798
callq 0x2e8a2
testl %eax, %eax
je 0x2cb62
incl %eax
cmpl 0x1299b(%rip), %eax     # 0x3f4ec
jge 0x2cb62
movq 0x12996(%rip), %rcx     # 0x3f4f0
cltq
movq (%rcx,%rax,8), %rsi
jmp 0x2cb64
xorl %esi, %esi
testq %rsi, %rsi
je 0x2cb75
leaq 0x5c2f(%rip), %rdi      # 0x3279f
callq 0x67a0
leaq 0x5c35(%rip), %rdi      # 0x327b1
callq 0x2e8a2
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl $0x1021, %eax           # imm = 0x1021
movl $0x20, %ebp
cmovel %eax, %ebp
movl %ecx, 0x112fa9(%rip)    # 0x13fb44
movl $0xffffffff, 0x112fa7(%rip) # imm = 0xFFFFFFFF
movl $0xf231, %edi           # imm = 0xF231
callq 0x6450
testl %eax, %eax
je 0x2cbcc
callq 0x6390
leaq 0x5bfa(%rip), %rsi      # 0x327b9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
leaq 0x5bfc(%rip), %rdi      # 0x327cf
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, 0x128d9(%rip)     # 0x3f4d0
testq %rax, %rax
jne 0x2cc15
callq 0x6390
leaq 0x5bd3(%rip), %rsi      # 0x327db
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq 0x128b4(%rip), %rdi     # 0x3f4d0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x6, %edx
callq 0x6050
movq %rax, 0x128a6(%rip)     # 0x3f4d8
testq %rax, %rax
jne 0x2cc50
callq 0x6390
leaq 0x5bb6(%rip), %rsi      # 0x327f9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xf0, %edx
callq 0x2e73c
xorl %edi, %edi
callq 0x68a0
leaq 0x5ba9(%rip), %rdi      # 0x32819
callq 0x2e8a2
testl %eax, %eax
jne 0x2cd85
leaq 0x68(%rsp), %r15
xorl %r14d, %r14d
movl $0x20, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6250
leaq 0x48(%rsp), %rdi
movl $0x20, %edx
xorl %esi, %esi
callq 0x6250
leaq 0x1c42(%rip), %rax      # 0x2e8ee
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 0x5b51(%rip), %rdi      # 0x32822
callq 0x2e8a2
testl %eax, %eax
je 0x2ccf6
incl %eax
cmpl 0x1280a(%rip), %eax     # 0x3f4ec
jge 0x2ccf3
movq 0x12805(%rip), %rcx     # 0x3f4f0
cltq
movq (%rcx,%rax,8), %r14
jmp 0x2ccf6
xorl %r14d, %r14d
leaq 0x68(%rsp), %rdx
leaq 0x48(%rsp), %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x65c0
movl %eax, 0x127d2(%rip)     # 0x3f4e8
cmpw $0x8008, 0x4(%r15)      # imm = 0x8008
je 0x2cd30
leaq 0x5b03(%rip), %rsi      # 0x32829
movq %rbx, %rdi
xorl %eax, %eax
callq 0xbda0
cmpb $0x1, 0x4e(%rsp)
je 0x2cd48
leaq 0x5b20(%rip), %rsi      # 0x3285e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xbda0
cmpl $0x0, 0x12799(%rip)     # 0x3f4e8
jne 0x2cd6a
callq 0x6390
leaq 0x5b35(%rip), %rsi      # 0x32892
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
cvtsi2ssl 0x48(%rsp), %xmm0
movss %xmm0, 0x112d58(%rip)   # 0x13fad0
movl 0x1276a(%rip), %edi     # 0x3f4e8
xorl %esi, %esi
callq 0x6620
movl $0x1000, 0x112db9(%rip) # imm = 0x1000
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 0x2cd99
movl %eax, 0x112d90(%rip)    # 0x13fb48
xorl %ecx, %ecx
leaq 0x11290f(%rip), %rdx    # 0x13f6d0
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 0x2cdc1
movl %eax, 0x112d54(%rip)    # 0x13fb48
xorl %r14d, %r14d
leaq 0x112712(%rip), %r15    # 0x13f510
leaq (%r15,%r14), %rdi
movl $0x38, %edx
xorl %esi, %esi
callq 0x6250
addq $0x38, %r14
cmpq $0x1c0, %r14            # imm = 0x1C0
jne 0x2cdfe
movl $0x1, 0x112d1b(%rip)    # 0x13fb40
leaq 0x112cb4(%rip), %r14    # 0x13fae0
movl $0x60, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x6250
leaq 0x1126be(%rip), %rdi    # 0x13f500
movl $0x8, %edx
xorl %esi, %esi
callq 0x6250
movq %rbx, %rdi
callq 0x2ec2d
movl $0xbc00, 0x112ce8(%rip) # imm = 0xBC00
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 0x2ce6a
movl %ecx, 0x112cbf(%rip)    # 0x13fb48
leaq 0x5a23(%rip), %rdi      # 0x328b3
callq 0x2e8a2
testl %eax, %eax
je 0x2ceb2
incl %eax
cmpl 0x1264b(%rip), %eax     # 0x3f4ec
jge 0x2ceb2
movq 0x12646(%rip), %rcx     # 0x3f4f0
cltq
movq (%rcx,%rax,8), %rax
jmp 0x2ceb4
xorl %eax, %eax
testq %rax, %rax
leaq 0x59fb(%rip), %rsi      # 0x328b9
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xcaf2
testl %eax, %eax
je 0x2ced8
movq %rbx, %rdi
callq 0xa9e4
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xa086
leaq 0x4159(%rip), %rsi      # 0x31049
movq %rbx, %rdi
callq 0x8fc9
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x2cf10
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xa086
jmp 0x2cf1a
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7275
callq 0x64f0
cmpl $0x0, 0x112c1a(%rip)    # 0x13fb40
je 0x2d404
leaq 0x10(%rsp), %r15
leaq 0x59ae(%rip), %r12      # 0x328e6
leaq 0x5551(%rip), %rbp      # 0x32490
xorl %r13d, %r13d
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x6320
testl %eax, %eax
je 0x2d1b7
movl 0x10(%rsp), %eax
cmpl $0x400, %eax            # imm = 0x400
jg 0x2cf87
leal -0x300(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2cfb5
cmpl $0x100, %eax            # imm = 0x100
je 0x2cfd1
cmpl $0x400, %eax            # imm = 0x400
jne 0x2cf45
movq 0x24(%rsp), %rax
movq %rax, 0x112b5f(%rip)    # 0x13fae4
jmp 0x2cf45
leal -0x401(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2d078
leal -0x651(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2d015
addl $0xfffff9ad, %eax       # imm = 0xFFFFF9AD
cmpl $0x2, %eax
jae 0x2cf45
movq %rbx, %rdi
callq 0x2ec2d
jmp 0x2cf45
cmpl $0x300, %eax            # imm = 0x300
jne 0x2cfe0
movl 0x24(%rsp), %ecx
cmpl $0x40000045, %ecx       # imm = 0x40000045
je 0x2d0cb
cmpl $0x1b, %ecx
jne 0x2cfe0
movl $0x0, 0x112b65(%rip)    # 0x13fb40
jmp 0x2cf45
movl 0x24(%rsp), %ecx
cmpl $0x77, %ecx
jle 0x2d098
leal -0x4000004f(%rcx), %edx
cmpl $0x3, %edx
ja 0x2d0b8
leaq 0x4eed(%rip), %rsi      # 0x31ef0
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movw $0x5, %cx
jmp 0x2d181
movzbl 0x1c(%rsp), %ecx
cmpw $0xe, %cx
ja 0x2cf45
movl $0x784f, %edx           # imm = 0x784F
btl %ecx, %edx
jae 0x2cf45
movl 0x18(%rsp), %esi
cmpq $0x7, %rsi
ja 0x2cf45
movzwl %cx, %ecx
leaq 0x5486(%rip), %rdx      # 0x324d0
movb (%rdx,%rcx,4), %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 0x2d1ab
orl %edx, %esi
movw %si, (%rcx)
orw %dx, 0x2(%rcx)
jmp 0x2cf45
movzbl 0x20(%rsp), %ecx
cmpl $0x1, %ecx
je 0x2d11e
cmpl $0x3, %ecx
jne 0x2cf45
movw $0x1, %cx
jmp 0x2d120
cmpl $0x60, %ecx
jg 0x2d148
cmpl $0xd, %ecx
je 0x2d0af
cmpl $0x20, %ecx
jne 0x2cf45
movw $0x8, %cx
jmp 0x2d181
leal -0x79(%rcx), %edx
cmpl $0x2, %edx
jae 0x2d15c
xorl %ecx, %ecx
jmp 0x2d181
xorl %eax, %eax
cmpl $0x0, 0x112a70(%rip)    # 0x13fb44
sete %al
movl %eax, 0x112a67(%rip)    # 0x13fb44
movq 0x123ec(%rip), %rdi     # 0x3f4d0
movl $0x0, %esi
movl $0x1001, %eax           # imm = 0x1001
cmovel %eax, %esi
callq 0x6550
cmpl $0x0, 0x112a47(%rip)    # 0x13fb44
jne 0x2cf45
movq 0x123c6(%rip), %rdi     # 0x3f4d0
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
callq 0x6080
jmp 0x2cf45
xorl %ecx, %ecx
movl $0x1, %edx
shll %cl, %edx
movzwl 0x1129b2(%rip), %ecx    # 0x13fae0
movzwl %dx, %edx
cmpl $0x401, %eax            # imm = 0x401
je 0x2d196
notl %edx
andl %edx, %ecx
movw %cx, 0x11299d(%rip)     # 0x13fae0
jmp 0x2cf45
cmpl $0x61, %ecx
je 0x2d16b
cmpl $0x73, %ecx
jne 0x2cf45
movw $0x3, %cx
jmp 0x2d181
cmpl $0x78, %ecx
jne 0x2cf45
movw $0x1, %cx
jmp 0x2d181
movw $0x2, %cx
jmp 0x2d181
movw $0x7, %cx
jmp 0x2d181
movw $0x6, %cx
jmp 0x2d181
movw $0x4, %cx
movl $0x1, %edx
shll %cl, %edx
movzwl 0x112951(%rip), %ecx    # 0x13fae0
cmpl $0x300, %eax            # imm = 0x300
jne 0x2d138
orl %edx, %ecx
movw %cx, 0x112941(%rip)     # 0x13fae0
orw %dx, 0x11293c(%rip)     # 0x13fae2
jmp 0x2cf45
notl %edx
andl %edx, %esi
movw %si, (%rcx)
jmp 0x2cf45
callq 0x64f0
subl (%rsp), %r13d
movl %eax, (%rsp)
addl %eax, %r13d
cmpl $0x21, %r13d
jb 0x2d219
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8fc9
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x2d1ef
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xa086
jmp 0x2d1f9
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7275
movl $0x2, %eax
movw $0x0, (%rax,%r14)
addq $0xc, %rax
cmpq $0x62, %rax
jne 0x2d1fe
addl $-0x21, %r13d
cmpl $0x20, %r13d
ja 0x2d1cc
movq 0x122c0(%rip), %rdi     # 0x3f4e0
testq %rdi, %rdi
je 0x2d38d
xorl %esi, %esi
leaq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x65e0
testl %eax, %eax
je 0x2d257
callq 0x6390
movq %rbx, %rdi
leaq 0x56e1(%rip), %rsi      # 0x3292e
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
cmpl $0x0, 0x1122ae(%rip)    # 0x13f50c
jle 0x2d2d8
leaq 0x12299(%rip), %rax     # 0x3f500
xorl %ecx, %ecx
cmpl $0x0, 0x112298(%rip)    # 0x13f508
jle 0x2d2c6
movl 0x4(%rsp), %edx
imull %ecx, %edx
movslq %edx, %rdx
addq 0x8(%rsp), %rdx
movq %rax, %rsi
xorl %edi, %edi
movzbl (%rsi), %r8d
andl $0xf, %r8d
movb $-0x1, (%rdx,%rdi,4)
movb 0x2(%rbp,%r8,4), %r9b
movb %r9b, 0x1(%rdx,%rdi,4)
movb (%rbp,%r8,4), %r9b
movb 0x1(%rbp,%r8,4), %r8b
movb %r8b, 0x2(%rdx,%rdi,4)
movb %r9b, 0x3(%rdx,%rdi,4)
incq %rdi
movslq 0x11224e(%rip), %r8     # 0x13f508
addq $0x400, %rsi            # imm = 0x400
cmpq %r8, %rdi
jl 0x2d286
incq %rcx
movslq 0x11223c(%rip), %rdx    # 0x13f50c
incq %rax
cmpq %rdx, %rcx
jl 0x2d269
movq 0x12201(%rip), %rdi     # 0x3f4e0
callq 0x6670
movq 0x121ed(%rip), %rdi     # 0x3f4d8
movl $0x10, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xff, %r8d
callq 0x66a0
testl %eax, %eax
je 0x2d322
callq 0x6390
movq %rbx, %rdi
leaq 0x55d5(%rip), %rsi      # 0x328ed
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq 0x121af(%rip), %rdi     # 0x3f4d8
callq 0x6490
testl %eax, %eax
je 0x2d34b
callq 0x6390
movq %rbx, %rdi
leaq 0x55d0(%rip), %rsi      # 0x32911
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq 0x12186(%rip), %rdi     # 0x3f4d8
movq 0x12187(%rip), %rsi     # 0x3f4e0
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6530
testl %eax, %eax
je 0x2d37f
callq 0x6390
movq %rbx, %rdi
leaq 0x55d6(%rip), %rsi      # 0x3294b
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq 0x12152(%rip), %rdi     # 0x3f4d8
callq 0x60e0
jmp 0x2d3f4
movq 0x12144(%rip), %rdi     # 0x3f4d8
movl $0x40, %esi
movl $0x10, %edx
movl $0x10, %ecx
movl $0xff, %r8d
callq 0x66a0
testl %eax, %eax
je 0x2d3cb
callq 0x6390
movq %rbx, %rdi
leaq 0x552c(%rip), %rsi      # 0x328ed
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
movq 0x12106(%rip), %rdi     # 0x3f4d8
callq 0x6490
testl %eax, %eax
je 0x2d3f4
callq 0x6390
movq %rbx, %rdi
leaq 0x5527(%rip), %rsi      # 0x32911
movq %rax, %rdx
xorl %eax, %eax
callq 0xbda0
cmpl $0x0, 0x112745(%rip)    # 0x13fb40
movl (%rsp), %eax
jne 0x2cf42
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq