// File: /workspace/github_c_makefile_star2_O2/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 0x653d(%rip), %rdi      # 0x2c698
callq 0x27a65
testq %rax, %rax
je 0x26174
leaq 0x6533(%rip), %rdi      # 0x2c69f
movq %rax, %rsi
callq 0x6790
leaq 0x6536(%rip), %rdi      # 0x2c6b1
callq 0x27a8c
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl $0x1021, %eax           # imm = 0x1021
pushq $0x20
popq %rbp
cmovel %eax, %ebp
movl %ecx, 0x1159ac(%rip)    # 0x13bb44
orl $-0x1, 0x1159ad(%rip)   # 0x13bb4c
movl $0xf231, %edi           # imm = 0xF231
callq 0x6440
testl %eax, %eax
je 0x261c6
callq 0x6380
leaq 0x6500(%rip), %rsi      # 0x2c6b9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
leaq 0x6502(%rip), %rdi      # 0x2c6cf
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, 0x152df(%rip)     # 0x3b4d0
testq %rax, %rax
jne 0x26216
callq 0x6380
leaq 0x64d9(%rip), %rsi      # 0x2c6db
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq 0x152ba(%rip), %rax     # 0x3b4d0
pushq $-0x1
popq %rsi
pushq $0x6
popq %rdx
movq %rax, %rdi
callq 0x6050
movq %rax, 0x152ad(%rip)     # 0x3b4d8
testq %rax, %rax
jne 0x26249
callq 0x6380
leaq 0x64bd(%rip), %rsi      # 0x2c6f9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xf0, %edx
callq 0x27908
xorl %edi, %edi
callq 0x6890
leaq 0x64b0(%rip), %rdi      # 0x2c719
callq 0x27a8c
testl %eax, %eax
jne 0x26359
leaq 0x68(%rsp), %r14
pushq $0x20
popq %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x6250
leaq 0x48(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x6250
leaq 0x1825(%rip), %rax      # 0x27aca
movq %rax, 0x10(%r14)
movb $0x1, 0x6(%r14)
movw $0x8008, %bp            # imm = 0x8008
movw %bp, 0x4(%r14)
movl $0xac44, (%r14)         # imm = 0xAC44
movw $0x1000, 0x8(%r14)      # imm = 0x1000
leaq 0x6456(%rip), %rdi      # 0x2c722
callq 0x27a65
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x65b0
movl %eax, 0x151fe(%rip)     # 0x3b4e8
cmpw %bp, 0x4(%r12)
je 0x26303
leaq 0x6430(%rip), %rsi      # 0x2c729
movq %rbx, %rdi
xorl %eax, %eax
callq 0xaa53
cmpb $0x1, 0x4e(%rsp)
je 0x2631b
leaq 0x644d(%rip), %rsi      # 0x2c75e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xaa53
movl 0x151c7(%rip), %edi     # 0x3b4e8
testl %edi, %edi
jne 0x26344
callq 0x6380
leaq 0x6461(%rip), %rsi      # 0x2c792
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movl 0x151a4(%rip), %edi     # 0x3b4e8
cvtsi2ssl 0x48(%rsp), %xmm0
movss %xmm0, 0x11577e(%rip)   # 0x13bad0
xorl %esi, %esi
callq 0x6610
movl $0x1000, %edi           # imm = 0x1000
callq 0x278c4
xorl %r14d, %r14d
leaq 0x115363(%rip), %r15    # 0x13b6d0
cmpq $0x400, %r14            # imm = 0x400
je 0x26388
callq 0x278e6
andb $0x7, %al
addb $-0x4, %al
movb %al, (%r14,%r15)
incq %r14
jmp 0x2636d
xorl %r15d, %r15d
leaq 0x11517e(%rip), %r12    # 0x13b510
pushq $0x38
popq %r14
cmpq $0x1c0, %r15            # imm = 0x1C0
je 0x263b3
leaq (%r12,%r15), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x6250
addq $0x38, %r15
jmp 0x26396
movl $0x1, 0x115783(%rip)    # 0x13bb40
leaq 0x11571c(%rip), %r14    # 0x13bae0
pushq $0x60
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x6250
leaq 0x115128(%rip), %rdi    # 0x13b500
pushq $0x8
popq %rdx
xorl %esi, %esi
callq 0x6250
movq %rbx, %rdi
callq 0x27de3
movl $0xbc00, %edi           # imm = 0xBC00
callq 0x278c4
leaq 0x63b8(%rip), %rdi      # 0x2c7b3
callq 0x27a65
testq %rax, %rax
leaq 0x63af(%rip), %rsi      # 0x2c7b9
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xb500
testl %eax, %eax
je 0x26424
movq %rbx, %rdi
callq 0x9a1c
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x9317
leaq 0x4cdc(%rip), %rsi      # 0x2b118
movq %rbx, %rdi
callq 0x83bf
cmpl $0x6, %eax
jne 0x2645c
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x9317
jmp 0x26467
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x6b49
callq 0x64e0
leaq 0x10(%rsp), %r15
pushq $0x2
popq %rbp
leaq 0x5f15(%rip), %r13      # 0x2c390
xorl %r12d, %r12d
cmpl $0x0, 0x1156bb(%rip)    # 0x13bb40
je 0x268d5
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x6310
testl %eax, %eax
je 0x266b0
movl 0x10(%rsp), %eax
leal -0x300(%rax), %ecx
cmpl $0x2, %ecx
jb 0x26553
leal -0x401(%rax), %ecx
cmpl $0x2, %ecx
jb 0x26534
leal -0x651(%rax), %ecx
cmpl $0x2, %ecx
jb 0x264ed
leal -0x653(%rax), %ecx
cmpl $0x2, %ecx
jb 0x26527
cmpl $0x400, %eax            # imm = 0x400
je 0x265bc
cmpl $0x100, %eax            # imm = 0x100
jne 0x2648e
andl $0x0, 0x115655(%rip)    # 0x13bb40
jmp 0x2648e
movzbl 0x1c(%rsp), %ecx
cmpw $0xe, %cx
ja 0x2648e
movl $0x784f, %edx           # imm = 0x784F
btl %ecx, %edx
jae 0x2648e
movzwl %cx, %ecx
leaq 0x5ec4(%rip), %rdx      # 0x2c3d0
movl (%rdx,%rcx,4), %esi
movl 0x18(%rsp), %edi
xorl %edx, %edx
cmpl $0x651, %eax            # imm = 0x651
sete %dl
callq 0x27ff2
jmp 0x2648e
movq %rbx, %rdi
callq 0x27de3
jmp 0x2648e
movzbl 0x20(%rsp), %ecx
cmpl $0x1, %ecx
je 0x265fb
cmpl $0x3, %ecx
jne 0x2648e
pushq $0x1
popq %rsi
jmp 0x265fd
movl 0x24(%rsp), %ecx
leal -0x4000004f(%rcx), %edx
cmpl $0x300, %eax            # imm = 0x300
jne 0x265cd
cmpl $0x3, %edx
jbe 0x26621
leal -0x79(%rcx), %edx
cmpl $0x2, %edx
jb 0x26619
cmpl $0xd, %ecx
je 0x2661d
cmpl $0x40000045, %ecx       # imm = 0x40000045
je 0x2665d
cmpl $0x20, %ecx
je 0x2661d
cmpl $0x61, %ecx
je 0x26640
cmpl $0x73, %ecx
je 0x26644
cmpl $0x78, %ecx
je 0x265f7
cmpl $0x1b, %ecx
jne 0x2648e
jmp 0x264e4
movq 0x24(%rsp), %rax
movq %rax, 0x11551c(%rip)    # 0x13bae4
jmp 0x2648e
cmpl $0x3, %edx
jbe 0x26606
leal -0x79(%rcx), %edx
cmpl $0x2, %edx
jb 0x26619
cmpl $0xd, %ecx
je 0x2661d
cmpl $0x20, %ecx
je 0x2661d
cmpl $0x61, %ecx
je 0x26640
cmpl $0x73, %ecx
je 0x26644
cmpl $0x78, %ecx
jne 0x2648e
pushq $0x1
jmp 0x26646
xorl %esi, %esi
xorl %edx, %edx
cmpl $0x401, %eax            # imm = 0x401
jmp 0x2664e
leaq 0x57d3(%rip), %rsi      # 0x2bde0
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
pushq $0x6
popq %rsi
jmpq *%rcx
xorl %esi, %esi
jmp 0x26647
pushq $0x8
jmp 0x26646
leaq 0x57c8(%rip), %rsi      # 0x2bdf0
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
pushq $0x6
popq %rsi
jmpq *%rcx
pushq $0x5
jmp 0x26646
pushq $0x4
jmp 0x26646
pushq $0x7
jmp 0x26646
pushq $0x2
jmp 0x26646
pushq $0x3
popq %rsi
xorl %edx, %edx
cmpl $0x300, %eax            # imm = 0x300
sete %dl
xorl %edi, %edi
callq 0x27ff2
jmp 0x2648e
xorl %eax, %eax
cmpl $0x0, 0x1154de(%rip)    # 0x13bb44
sete %al
movl %eax, 0x1154d5(%rip)    # 0x13bb44
movq 0x14e5a(%rip), %rdi     # 0x3b4d0
movl $0x0, %esi
movl $0x1001, %eax           # imm = 0x1001
cmovel %eax, %esi
callq 0x6540
cmpl $0x0, 0x1154b5(%rip)    # 0x13bb44
jne 0x2648e
movq 0x14e34(%rip), %rdi     # 0x3b4d0
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
callq 0x6080
jmp 0x2648e
callq 0x64e0
subl (%rsp), %r12d
movl %eax, (%rsp)
addl %eax, %r12d
cmpl $0x21, %r12d
jb 0x2670f
movq %rbx, %rdi
leaq 0x6117(%rip), %rsi      # 0x2c7e6
callq 0x83bf
movq %rbx, %rdi
cmpl $0x6, %eax
jne 0x266ec
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x9317
jmp 0x266f4
pushq $-0x2
popq %rsi
callq 0x6b49
movq %rbp, %rax
cmpq $0x62, %rax
je 0x26709
andw $0x0, (%rax,%r14)
addq $0xc, %rax
jmp 0x266f7
addl $-0x21, %r12d
jmp 0x266bf
movq 0x14dca(%rip), %rdi     # 0x3b4e0
testq %rdi, %rdi
je 0x2686d
xorl %esi, %esi
leaq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x65d0
testl %eax, %eax
je 0x2674d
callq 0x6380
movq %rbx, %rdi
leaq 0x60eb(%rip), %rsi      # 0x2c82e
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
leaq 0x14dac(%rip), %rax     # 0x3b500
xorl %ecx, %ecx
movslq 0x114daf(%rip), %rdx    # 0x13b50c
cmpq %rdx, %rcx
jge 0x267c0
movl 0x4(%rsp), %edx
imull %ecx, %edx
movslq %edx, %rdx
addq 0x8(%rsp), %rdx
movq %rax, %rsi
xorl %edi, %edi
movslq 0x114d8b(%rip), %r8     # 0x13b508
cmpq %r8, %rdi
jge 0x267b8
movzbl (%rsi), %r8d
andl $0xf, %r8d
movb $-0x1, (%rdx,%rdi,4)
movb 0x2(%r13,%r8,4), %r9b
movb %r9b, 0x1(%rdx,%rdi,4)
movb (%r13,%r8,4), %r9b
movb 0x1(%r13,%r8,4), %r8b
movb %r8b, 0x2(%rdx,%rdi,4)
movb %r9b, 0x3(%rdx,%rdi,4)
incq %rdi
addq $0x400, %rsi            # imm = 0x400
jmp 0x26776
incq %rcx
incq %rax
jmp 0x26756
movq 0x14d19(%rip), %rdi     # 0x3b4e0
callq 0x6660
movq 0x14d05(%rip), %rdi     # 0x3b4d8
pushq $0x10
popq %rcx
movl %ecx, %esi
movl %ecx, %edx
movl $0xff, %r8d
callq 0x6690
testl %eax, %eax
je 0x26802
callq 0x6380
movq %rbx, %rdi
leaq 0x5ff5(%rip), %rsi      # 0x2c7ed
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq 0x14ccf(%rip), %rdi     # 0x3b4d8
callq 0x6480
testl %eax, %eax
je 0x2682b
callq 0x6380
movq %rbx, %rdi
leaq 0x5ff0(%rip), %rsi      # 0x2c811
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq 0x14ca6(%rip), %rdi     # 0x3b4d8
movq 0x14ca7(%rip), %rsi     # 0x3b4e0
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6520
testl %eax, %eax
je 0x2685f
callq 0x6380
movq %rbx, %rdi
leaq 0x5ff6(%rip), %rsi      # 0x2c84b
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq 0x14c72(%rip), %rdi     # 0x3b4d8
callq 0x60e0
jmp 0x268cd
movq 0x14c64(%rip), %rdi     # 0x3b4d8
pushq $0x40
popq %rsi
pushq $0x10
popq %rcx
movl %ecx, %edx
movl $0xff, %r8d
callq 0x6690
testl %eax, %eax
je 0x268a4
callq 0x6380
movq %rbx, %rdi
leaq 0x5f53(%rip), %rsi      # 0x2c7ed
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movq 0x14c2d(%rip), %rdi     # 0x3b4d8
callq 0x6480
testl %eax, %eax
je 0x268cd
callq 0x6380
movq %rbx, %rdi
leaq 0x5f4e(%rip), %rsi      # 0x2c811
movq %rax, %rdx
xorl %eax, %eax
callq 0xaa53
movl (%rsp), %eax
jmp 0x2647e
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq