#include "randuint32.hpp" // In our Docker image, this would be <cs70/randuint32.hpp>
#include <cstddef>
#include <iostream>
constexpr size_t TOTAL_ROLLS = 6000;
constexpr size_t DICE_SIDES = 6;
int main() {
RandUInt32 rand;
size_t counts[DICE_SIDES] = {0, 0, 0, 0, 0, 0};
for (size_t i = 0; i < TOTAL_ROLLS; ++i) {
size_t roll = rand.get(DICE_SIDES);
++counts[roll];
}
std::cout << "Results from " << TOTAL_ROLLS << " dice rolls" << std::endl;
for (size_t i = 0; i < DICE_SIDES; ++i) {
std::cout << i << "\t" << counts[i] << std::endl;
}
return 0;
}
#ifndef RANDUINT32_HPP_INCLUDED
#define RANDUINT32_HPP_INCLUDED
#include <iostream>
#include <random>
#include <cstdint>
class RandUInt32 {
public:
RandUInt32();
RandUInt32(size_t seedval);
unsigned int get();
unsigned int get(size_t max);
private:
int32_t data[4];
};
#endif
#
#
# ###### ######## ####### ######## ####
# ## ## ## ## ## ## ## ####
# ## ## ## ## ## ## ####
# ###### ## ## ## ######## ##
# ## ## ## ## ##
# ## ## ## ## ## ## ####
# ###### ## ####### ## ####
#
#
# _ _ _ _ _ _
# | \ | | ___ | |_| |__ (_)_ __ __ _ | |_ ___ ___ ___ ___
# | \| |/ _ \| __| '_ \| | '_ \ / _` | | __/ _ \ / __|/ _ \/ _ \
# | |\ | (_) | |_| | | | | | | | (_| | | || (_) | \__ \ __/ __/_ _ _
# |_| \_|\___/ \__|_| |_|_|_| |_|\__, | \__\___/ |___/\___|\___(_|_|_)
# |___/
# ____ _ _ _ _ _
# / ___| ___ | |__ __ _ ___| | __ | |_ ___ _ __ ___ __ _(_)_ __ ___ _ __ _ __ | |
# | | _ / _ \ | '_ \ / _` |/ __| |/ / | __/ _ \ | '_ ` _ \ / _` | | '_ \ / __| '_ \| '_ \| |
# | |_| | (_) | | |_) | (_| | (__| < | || (_) | | | | | | | (_| | | | | || (__| |_) | |_) |_|
# \____|\___/ |_.__/ \__,_|\___|_|\_\ \__\___/ |_| |_| |_|\__,_|_|_| |_(_)___| .__/| .__/(_)
# |_| |_|
#
# Do not look at this file...
#
# It is only here because we can't easily link against a library in OnlineGDB
#
#
.file "randuint32.cpp"
.text
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.section .rodata
.type _ZN6__pstl9execution2v1L3seqE, @object
.size _ZN6__pstl9execution2v1L3seqE, 1
_ZN6__pstl9execution2v1L3seqE:
.zero 1
.type _ZN6__pstl9execution2v1L3parE, @object
.size _ZN6__pstl9execution2v1L3parE, 1
_ZN6__pstl9execution2v1L3parE:
.zero 1
.type _ZN6__pstl9execution2v1L9par_unseqE, @object
.size _ZN6__pstl9execution2v1L9par_unseqE, 1
_ZN6__pstl9execution2v1L9par_unseqE:
.zero 1
.type _ZN6__pstl9execution2v1L5unseqE, @object
.size _ZN6__pstl9execution2v1L5unseqE, 1
_ZN6__pstl9execution2v1L5unseqE:
.zero 1
.section .text._ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv,"axG",@progbits,_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv,comdat
.align 2
.weak _ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv
.type _ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv, @function
_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv:
.LFB3469:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq (%rax), %rax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3469:
.size _ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv, .-_ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv
.text
.align 2
.globl _ZN10RandUInt32C2Ev
.type _ZN10RandUInt32C2Ev, @function
_ZN10RandUInt32C2Ev:
.LFB3500:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
pushq %rbx
subq $56, %rsp
.cfi_offset 3, -24
movq %rdi, -56(%rbp)
movq %fs:40, %rax
movq %rax, -24(%rbp)
xorl %eax, %eax
movq -56(%rbp), %rbx
call _ZNSt6chrono3_V212system_clock3nowEv@PLT
movq %rax, -32(%rbp)
leaq -32(%rbp), %rax
movq %rax, %rdi
call _ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv
movq %rax, -40(%rbp)
leaq -40(%rbp), %rax
movq %rax, %rdi
call _ZNKSt6chrono8durationIlSt5ratioILl1ELl1000000000EEE5countEv
movl %eax, %esi
movq %rbx, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC1Ej
nop
movq -24(%rbp), %rax
subq %fs:40, %rax
je .L4
call __stack_chk_fail@PLT
.L4:
movq -8(%rbp), %rbx
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3500:
.size _ZN10RandUInt32C2Ev, .-_ZN10RandUInt32C2Ev
.globl _ZN10RandUInt32C1Ev
.set _ZN10RandUInt32C1Ev,_ZN10RandUInt32C2Ev
.align 2
.globl _ZN10RandUInt32C2Em
.type _ZN10RandUInt32C2Em, @function
_ZN10RandUInt32C2Em:
.LFB3503:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq -8(%rbp), %rax
movq -16(%rbp), %rdx
movl %edx, %esi
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC1Ej
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3503:
.size _ZN10RandUInt32C2Em, .-_ZN10RandUInt32C2Em
.globl _ZN10RandUInt32C1Em
.set _ZN10RandUInt32C1Em,_ZN10RandUInt32C2Em
.align 2
.globl _ZN10RandUInt323getEm
.type _ZN10RandUInt323getEm, @function
_ZN10RandUInt323getEm:
.LFB3505:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $48, %rsp
movq %rdi, -40(%rbp)
movq %rsi, -48(%rbp)
movq -40(%rbp), %rax
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv
movl %eax, -12(%rbp)
movl -12(%rbp), %eax
movq -48(%rbp), %rdx
imulq %rdx, %rax
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
movl %eax, -20(%rbp)
movl -20(%rbp), %eax
cmpq %rax, -48(%rbp)
jbe .L7
movq -48(%rbp), %rax
negl %eax
movl %eax, -16(%rbp)
movl -16(%rbp), %eax
cmpq %rax, -48(%rbp)
ja .L9
movq -48(%rbp), %rax
subl %eax, -16(%rbp)
movl -16(%rbp), %eax
cmpq %rax, -48(%rbp)
ja .L9
movl -16(%rbp), %eax
movl $0, %edx
divq -48(%rbp)
movq %rdx, %rax
movl %eax, -16(%rbp)
jmp .L9
.L10:
movq -40(%rbp), %rax
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv
movl %eax, -12(%rbp)
movl -12(%rbp), %eax
movq -48(%rbp), %rdx
imulq %rdx, %rax
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
movl %eax, -20(%rbp)
.L9:
movl -20(%rbp), %eax
cmpl -16(%rbp), %eax
jb .L10
.L7:
movq -8(%rbp), %rax
shrq $32, %rax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3505:
.size _ZN10RandUInt323getEm, .-_ZN10RandUInt323getEm
.align 2
.globl _ZN10RandUInt323getEv
.type _ZN10RandUInt323getEv, @function
_ZN10RandUInt323getEv:
.LFB3508:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3508:
.size _ZN10RandUInt323getEv, .-_ZN10RandUInt323getEv
.section .text._ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv,"axG",@progbits,_ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv,comdat
.align 2
.weak _ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv
.type _ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv, @function
_ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv:
.LFB3830:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq (%rax), %rax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3830:
.size _ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv, .-_ZNKSt6chrono10time_pointINS_3_V212system_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEE16time_since_epochEv
.section .text._ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej,"axG",@progbits,_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC5Ej,comdat
.align 2
.weak _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej
.type _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej, @function
_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej:
.LFB3858:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
movq %rdi, -24(%rbp)
movl %esi, -28(%rbp)
movq -24(%rbp), %rax
movl $-236298515, (%rax)
movq -24(%rbp), %rax
movl -28(%rbp), %edx
movl %edx, 4(%rax)
movq -24(%rbp), %rax
movl -28(%rbp), %edx
movl %edx, 8(%rax)
movq -24(%rbp), %rax
movl -28(%rbp), %edx
movl %edx, 12(%rax)
movl $0, -4(%rbp)
jmp .L17
.L18:
movq -24(%rbp), %rax
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv
addl $1, -4(%rbp)
.L17:
cmpl $19, -4(%rbp)
jbe .L18
nop
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3858:
.size _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej, .-_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej
.weak _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC1Ej
.set _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC1Ej,_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEC2Ej
.section .text._ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv,"axG",@progbits,_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv,comdat
.align 2
.weak _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv
.type _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv, @function
_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv:
.LFB3860:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movq %rdi, -8(%rbp)
movq -8(%rbp), %rax
movq %rax, %rdi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv
movq -8(%rbp), %rax
movl 12(%rax), %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE3860:
.size _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv, .-_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EEclEv
.section .text._ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv,"axG",@progbits,_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv,comdat
.align 2
.weak _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv
.type _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv, @function
_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv:
.LFB4000:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
pushq %rbx
subq $40, %rsp
.cfi_offset 3, -24
movq %rdi, -40(%rbp)
movq -40(%rbp), %rax
movl (%rax), %ebx
movq -40(%rbp), %rax
movl 4(%rax), %eax
movl $27, %esi
movl %eax, %edi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj
movl %eax, %edx
movl %ebx, %eax
subl %edx, %eax
movl %eax, -20(%rbp)
movq -40(%rbp), %rax
movl 4(%rax), %ebx
movq -40(%rbp), %rax
movl 8(%rax), %eax
movl $17, %esi
movl %eax, %edi
call _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj
xorl %eax, %ebx
movl %ebx, %edx
movq -40(%rbp), %rax
movl %edx, (%rax)
movq -40(%rbp), %rax
movl 8(%rax), %edx
movq -40(%rbp), %rax
movl 12(%rax), %eax
addl %eax, %edx
movq -40(%rbp), %rax
movl %edx, 4(%rax)
movq -40(%rbp), %rax
movl 12(%rax), %edx
movl -20(%rbp), %eax
addl %eax, %edx
movq -40(%rbp), %rax
movl %edx, 8(%rax)
movq -40(%rbp), %rax
movl (%rax), %edx
movl -20(%rbp), %eax
addl %eax, %edx
movq -40(%rbp), %rax
movl %edx, 12(%rax)
nop
movq -8(%rbp), %rbx
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4000:
.size _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv, .-_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE7advanceEv
.section .text._ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj,"axG",@progbits,_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj,comdat
.weak _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj
.type _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj, @function
_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj:
.LFB4069:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
movl -8(%rbp), %eax
movl -4(%rbp), %edx
movl %eax, %ecx
roll %cl, %edx
movl %edx, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4069:
.size _ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj, .-_ZN10jsf_detail3jsfIjjLj27ELj17ELj0EE6rotateEjj
.text
.type _Z41__static_initialization_and_destruction_0ii, @function
_Z41__static_initialization_and_destruction_0ii:
.LFB4202:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
cmpl $1, -4(%rbp)
jne .L26
cmpl $65535, -8(%rbp)
jne .L26
leaq _ZStL8__ioinit(%rip), %rax
movq %rax, %rdi
call _ZNSt8ios_base4InitC1Ev@PLT
leaq __dso_handle(%rip), %rax
movq %rax, %rdx
leaq _ZStL8__ioinit(%rip), %rax
movq %rax, %rsi
movq _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rax
movq %rax, %rdi
call __cxa_atexit@PLT
.L26:
nop
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4202:
.size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
.type _GLOBAL__sub_I__ZN10RandUInt32C2Ev, @function
_GLOBAL__sub_I__ZN10RandUInt32C2Ev:
.LFB4203:
.cfi_startproc
endbr64
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $65535, %esi
movl $1, %edi
call _Z41__static_initialization_and_destruction_0ii
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE4203:
.size _GLOBAL__sub_I__ZN10RandUInt32C2Ev, .-_GLOBAL__sub_I__ZN10RandUInt32C2Ev
.section .init_array,"aw"
.align 8
.quad _GLOBAL__sub_I__ZN10RandUInt32C2Ev
.hidden __dso_handle
.ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
/*
*
* ###### ######## ####### ######## ####
* ## ## ## ## ## ## ## ####
* ## ## ## ## ## ## ####
* ###### ## ## ## ######## ##
* ## ## ## ## ##
* ## ## ## ## ## ## ####
* ###### ## ####### ## ####
*
*
* _ _ _ _ _ _
* | \ | | ___ | |_| |__ (_)_ __ __ _ | |_ ___ ___ ___ ___
* | \| |/ _ \| __| '_ \| | '_ \ / _` | | __/ _ \ / __|/ _ \/ _ \
* | |\ | (_) | |_| | | | | | | | (_| | | || (_) | \__ \ __/ __/_ _ _
* |_| \_|\___/ \__|_| |_|_|_| |_|\__, | \__\___/ |___/\___|\___(_|_|_)
* |___/
* ____ _ _ _ _ _
* / ___| ___ | |__ __ _ ___| | __ | |_ ___ _ __ ___ __ _(_)_ __ ___ _ __ _ __ | |
* | | _ / _ \ | '_ \ / _` |/ __| |/ / | __/ _ \ | '_ ` _ \ / _` | | '_ \ / __| '_ \| '_ \| |
* | |_| | (_) | | |_) | (_| | (__| < | || (_) | | | | | | | (_| | | | | || (__| |_) | |_) |_|
* \____|\___/ |_.__/ \__,_|\___|_|\_\ \__\___/ |_| |_| |_|\__,_|_|_| |_(_)___| .__/| .__/(_)
* |_| |_|
*
* Do not look at this file...
*
* It is only here because we can't easily link against a library in OnlineGDB
*
*/
asm(".include \"randuint32.s\"");