Source code: #include <iostream> static void Foo() { std::cout << "one" << std::endl;…
- User
Source code:
#include
static void Foo() { std::cout << "one" << std::endl; std::cout << "two" << std::endl; std::cout << "three" << std::endl; std::cout << "four" << std::endl; std::cout << "five" << std::endl; std::cout << "six" << std::endl; std::cout << "seven" << std::endl; std::cout << "eight" << std::endl; std::cout << "nine" << std::endl; std::cout << "ten" << std::endl; }
static void FooCopy() { std::cout << "one" << std::endl; std::cout << "two" << std::endl; std::cout << "three" << std::endl; std::cout << "four" << std::endl; std::cout << "five" << std::endl; std::cout << "six" << std::endl; std::cout << "seven" << std::endl; std::cout << "eight" << std::endl; std::cout << "nine" << std::endl; std::cout << "ten" << std::endl; }
int GetOne() { Foo(); return 1; }
int GetTwo() { FooCopy(); return 2; }
What clang produces:
_Z6GetOnev: push r14 push rbx push rax mov rbx, qword ptr [rip + _ZSt4cout@GOTPCREL] lea rsi, [rip + .L.str] mov edx, 3 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_3 movzx eax, byte ptr [r14 + 67] jmp .LBB0_4 .LBB0_3: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_4: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.1] mov edx, 3 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_7 movzx eax, byte ptr [r14 + 67] jmp .LBB0_8 .LBB0_7: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_8: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.2] mov edx, 5 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_11 movzx eax, byte ptr [r14 + 67] jmp .LBB0_12 .LBB0_11: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_12: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.3] mov edx, 4 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_15 movzx eax, byte ptr [r14 + 67] jmp .LBB0_16 .LBB0_15: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_16: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.4] mov edx, 4 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_19 movzx eax, byte ptr [r14 + 67] jmp .LBB0_20 .LBB0_19: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_20: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.5] mov edx, 3 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_23 movzx eax, byte ptr [r14 + 67] jmp .LBB0_24 .LBB0_23: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_24: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.6] mov edx, 5 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_27 movzx eax, byte ptr [r14 + 67] jmp .LBB0_28 .LBB0_27: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_28: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.7] mov edx, 5 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_31 movzx eax, byte ptr [r14 + 67] jmp .LBB0_32 .LBB0_31: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_32: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.8] mov edx, 4 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov r14, qword ptr [rbx + rax + 240] test r14, r14 je .LBB0_41 cmp byte ptr [r14 + 56], 0 je .LBB0_35 movzx eax, byte ptr [r14 + 67] jmp .LBB0_36 .LBB0_35: mov rdi, r14 call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [r14] mov rdi, r14 mov esi, 10 call qword ptr [rax + 48] .LBB0_36: movsx esi, al mov rdi, rbx call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT lea rsi, [rip + .L.str.9] mov edx, 3 mov rdi, rbx call _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT mov rax, qword ptr [rbx] mov rax, qword ptr [rax - 24] mov rbx, qword ptr [rbx + rax + 240] test rbx, rbx je .LBB0_41 cmp byte ptr [rbx + 56], 0 je .LBB0_39 movzx eax, byte ptr [rbx + 67] jmp .LBB0_40 .LBB0_39: mov rdi, rbx call _ZNKSt5ctypeIcE13_M_widen_initEv@PLT mov rax, qword ptr [rbx] mov rdi, rbx mov esi, 10 call qword ptr [rax + 48] .LBB0_40: movsx esi, al mov rdi, qword ptr [rip + _ZSt4cout@GOTPCREL] call _ZNSo3putEc@PLT mov rdi, rax call _ZNSo5flushEv@PLT mov eax, 1 add rsp, 8 pop rbx pop r14 ret .LBB0_41: call _ZSt16__throw_bad_castv@PLT
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.