// File: tomfunkhouser[P]gaps/pkgs/fglut/freeglut_gamemode.c
// Function: glutGameModeString
void FGAPIENTRY glutGameModeString( const char* string )
{
    int width = 640, height = 480, depth = 16, refresh = 72;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );

    /*
     * This one seems a bit easier than glutInitDisplayString. The bad thing
     * about it that I was unable to find the game mode string definition, so
     * that I assumed it is: "[width]x[height]:[depth]@[refresh rate]", which
     * appears in all GLUT game mode programs I have seen to date.
     */
    if( sscanf( string, "%ix%i:%i@%i", &width, &height, &depth, &refresh ) !=
        4 )
        if( sscanf( string, "%ix%i:%i", &width, &height, &depth ) != 3 )
            if( sscanf( string, "%ix%i@%i", &width, &height, &refresh ) != 3 )
                if( sscanf( string, "%ix%i", &width, &height ) != 2 )
                    if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 )
                        if( sscanf( string, ":%i", &depth ) != 1 )
                            if( sscanf( string, "@%i", &refresh ) != 1 )
                                fgWarning(
                                    "unable to parse game mode string `%s'",
                                    string
                                );

    /* Hopefully it worked, and if not, we still have the default values */
    fgState.GameModeSize.X  = width;
    fgState.GameModeSize.Y  = height;
    fgState.GameModeDepth   = depth;
    fgState.GameModeRefresh = refresh;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl $0x280, 0xc(%rsp)       # imm = 0x280
movl $0x1e0, 0x8(%rsp)       # imm = 0x1E0
movl $0x10, 0x4(%rsp)
movl $0x48, (%rsp)
leaq 0x73861(%rip), %rax     # 0x1fa390
cmpb $0x0, 0x1c(%rax)
jne 0x186b4a
leaq 0x16d96(%rip), %rdi     # 0x19d8d2
leaq 0x28835(%rip), %rsi     # 0x1af378
movb $0x0, %al
callq 0x17de70
movq 0x10(%rsp), %rdi
leaq 0x2895a(%rip), %rsi     # 0x1af4b0
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x4(%rsp), %r8
movq %rsp, %r9
movb $0x0, %al
callq 0x229a0
cmpl $0x4, %eax
je 0x186c65
movq 0x10(%rsp), %rdi
leaq 0x28938(%rip), %rsi     # 0x1af4bc
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x4(%rsp), %r8
movb $0x0, %al
callq 0x229a0
cmpl $0x3, %eax
je 0x186c63
movq 0x10(%rsp), %rdi
leaq 0x28916(%rip), %rsi     # 0x1af4c5
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rsp, %r8
movb $0x0, %al
callq 0x229a0
cmpl $0x3, %eax
je 0x186c61
movq 0x10(%rsp), %rdi
leaq 0x288f6(%rip), %rsi     # 0x1af4ce
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x186c5f
movq 0x10(%rsp), %rdi
leaq 0x288bb(%rip), %rsi     # 0x1af4b5
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
movb $0x0, %al
callq 0x229a0
cmpl $0x2, %eax
je 0x186c5d
movq 0x10(%rsp), %rdi
leaq 0x288a7(%rip), %rsi     # 0x1af4c1
leaq 0x4(%rsp), %rdx
movb $0x0, %al
callq 0x229a0
cmpl $0x1, %eax
je 0x186c5b
movq 0x10(%rsp), %rdi
leaq 0x28881(%rip), %rsi     # 0x1af4b8
movq %rsp, %rdx
movb $0x0, %al
callq 0x229a0
cmpl $0x1, %eax
je 0x186c59
movq 0x10(%rsp), %rsi
leaq 0x28882(%rip), %rdi     # 0x1af4d4
movb $0x0, %al
callq 0x17dfa0
jmp 0x186c5b
jmp 0x186c5d
jmp 0x186c5f
jmp 0x186c61
jmp 0x186c63
jmp 0x186c65
movl 0xc(%rsp), %ecx
leaq 0x73720(%rip), %rax     # 0x1fa390
movl %ecx, 0x88(%rax)
movl 0x8(%rsp), %ecx
leaq 0x7370f(%rip), %rax     # 0x1fa390
movl %ecx, 0x8c(%rax)
movl 0x4(%rsp), %ecx
leaq 0x736fe(%rip), %rax     # 0x1fa390
movl %ecx, 0x94(%rax)
movl (%rsp), %ecx
leaq 0x736ee(%rip), %rax     # 0x1fa390
movl %ecx, 0x98(%rax)
addq $0x18, %rsp
retq
nopl (%rax)