Datasets:
id int64 0 14.1k | problem_id int64 1 1.31k | problem_title stringclasses 441
values | difficulty stringclasses 3
values | c_source stringclasses 441
values | architecture stringclasses 4
values | optimization stringclasses 4
values | compiler stringclasses 8
values | assembly stringlengths 31 174k |
|---|---|---|---|---|---|---|---|---|
0 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O0 | ARM64 gcc 15.2.0 | cmp:
sub sp, sp, #16
str x0, [sp, 8]
str x1, [sp]
ldr x0, [sp, 8]
ldr w1, [x0]
ldr x0, [sp]
ldr w0, [x0]
sub w0, w1, w0
add sp, sp, 16
ret
twoSum:
stp x29, x30, [sp, -64]!
mov x29,... |
1 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O1 | ARM64 gcc 15.2.0 | cmp:
ldr w2, [x0]
ldr w0, [x1]
sub w0, w2, w0
ret
twoSum:
stp x29, x30, [sp, -48]!
mov x29, sp
stp x19, x20, [sp, 16]
stp x21, x22, [sp, 32]
mov x22, x0
mov w20, w1
mov w21, w2
add ... |
2 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O2 | ARM64 gcc 15.2.0 | cmp:
ldr w2, [x0]
ldr w0, [x1]
sub w0, w2, w0
ret
twoSum:
stp x29, x30, [sp, -48]!
mov x29, sp
stp x21, x22, [sp, 32]
mov x22, x0
add w0, w1, 1
stp x19, x20, [sp, 16]
mov w20, w1
mov ... |
3 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O3 | ARM64 gcc 15.2.0 | cmp:
ldr w2, [x0]
ldr w0, [x1]
sub w0, w2, w0
ret
twoSum:
stp x29, x30, [sp, -64]!
mov x29, sp
str x23, [sp, 48]
mov x23, x0
add w0, w1, 1
stp x21, x22, [sp, 32]
mov w22, w1
mov w2... |
4 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O0 | armv8-a clang 21.1.0 | cmp:
sub sp, sp, #16
str x0, [sp, #8]
str x1, [sp]
ldr x8, [sp, #8]
ldr w8, [x8]
ldr x9, [sp]
ldr w9, [x9]
subs w0, w8, w9
add sp, sp, #16
ret
twoSum:
sub sp, sp, #80
stp x29, x30,... |
5 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O1 | armv8-a clang 21.1.0 | cmp:
ldr w8, [x0]
ldr w9, [x1]
sub w0, w8, w9
ret
twoSum:
stp x29, x30, [sp, #-48]!
stp x22, x21, [sp, #16]
stp x20, x19, [sp, #32]
mov x29, sp
mov w8, w1
mov x22, x0
mov w20, w2
sbfi... |
6 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O2 | armv8-a clang 21.1.0 | cmp:
ldr w8, [x0]
ldr w9, [x1]
sub w0, w8, w9
ret
.LCPI1_0:
.word 0
.word 1
.word 2
.word 3
twoSum:
stp x29, x30, [sp, #-48]!
stp x22, x21, [sp, #16]
stp x20, x19, [sp, #32]
mov x29, sp
... |
7 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | aarch64 | -O3 | armv8-a clang 21.1.0 | cmp:
ldr w8, [x0]
ldr w9, [x1]
sub w0, w8, w9
ret
.LCPI1_0:
.word 0
.word 1
.word 2
.word 3
twoSum:
stp x29, x30, [sp, #-48]!
stp x22, x21, [sp, #16]
stp x20, x19, [sp, #32]
mov x29, sp
... |
8 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O0 | mips64 clang 21.1.0 | cmp:
.Lfunc_begin0 = .Ltmp0
daddiu $sp, $sp, -32
sd $ra, 24($sp)
sd $fp, 16($sp)
move $fp, $sp
sd $4, 8($fp)
sd $5, 0($fp)
ld $1, 8($fp)
lw $1, 0($1)
ld $2, 0($fp)
lw $2, 0($2)
subu $1,... |
9 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O1 | mips64 clang 21.1.0 | cmp:
.Lfunc_begin0 = .Ltmp0
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $fp, 0($sp)
move $fp, $sp
lw $1, 0($5)
lw $2, 0($4)
subu $2, $2, $1
move $sp, $fp
ld $fp, 0($sp)
ld $ra, 8($sp)
jr $ra
... |
10 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O2 | mips64 clang 21.1.0 | cmp:
.Lfunc_begin0 = .Ltmp0
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $fp, 0($sp)
move $fp, $sp
lw $1, 0($5)
lw $2, 0($4)
subu $2, $2, $1
move $sp, $fp
ld $fp, 0($sp)
ld $ra, 8($sp)
jr $ra
... |
11 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O3 | mips64 clang 21.1.0 | cmp:
.Lfunc_begin0 = .Ltmp0
daddiu $sp, $sp, -16
sd $ra, 8($sp)
sd $fp, 0($sp)
move $fp, $sp
lw $1, 0($5)
lw $2, 0($4)
subu $2, $2, $1
move $sp, $fp
ld $fp, 0($sp)
ld $ra, 8($sp)
jr $ra
... |
12 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O0 | mips64 gcc 15.2.0 | cmp:
daddiu $sp,$sp,-32
sd $fp,24($sp)
move $fp,$sp
sd $4,0($fp)
sd $5,8($fp)
ld $2,0($fp)
lw $3,0($2)
ld $2,8($fp)
lw $2,0($2)
subu $2,$3,$2
move $sp,$fp
ld $fp,24($sp)
... |
13 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O1 | mips64 gcc 15.2.0 | cmp:
lw $3,0($4)
lw $2,0($5)
jr $31
subu $2,$3,$2
twoSum:
daddiu $sp,$sp,-64
sd $31,56($sp)
sd $28,48($sp)
sd $20,40($sp)
sd $19,32($sp)
sd $18,24($sp)
sd $17,16($sp)
sd ... |
14 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O2 | mips64 gcc 15.2.0 | cmp:
lw $3,0($4)
lw $2,0($5)
jr $31
subu $2,$3,$2
twoSum:
daddiu $sp,$sp,-80
sd $28,64($sp)
lui $28,%hi(%neg(%gp_rel(twoSum)))
daddu $28,$28,$25
daddiu $28,$28,%lo(%neg(%gp_rel(twoSum)))
ld $25,%call16(m... |
15 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | mips64 | -O3 | mips64 gcc 15.2.0 | cmp:
lw $3,0($4)
lw $2,0($5)
jr $31
subu $2,$3,$2
twoSum:
daddiu $sp,$sp,-80
sd $28,64($sp)
lui $28,%hi(%neg(%gp_rel(twoSum)))
daddu $28,$28,$25
daddiu $28,$28,%lo(%neg(%gp_rel(twoSum)))
ld $25,%call16(m... |
16 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O0 | RISC-V 64 clang 21.1.0 | cmp:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
addi s0, sp, 32
sd a0, -24(s0)
sd a1, -32(s0)
ld a0, -24(s0)
lw a0, 0(a0)
ld a1, -32(s0)
lw a1, 0(a1)
subw a0, a0, a1
ld ... |
17 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O1 | RISC-V 64 clang 21.1.0 | cmp:
lw a0, 0(a0)
lw a1, 0(a1)
subw a0, a0, a1
ret
twoSum:
addi sp, sp, -48
sd ra, 40(sp)
sd s0, 32(sp)
sd s1, 24(sp)
sd s2, 16(sp)
sd s3, 8(sp)
sd s4, 0(sp)
mv s3, a2
... |
18 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O2 | RISC-V 64 clang 21.1.0 | cmp:
lw a0, 0(a0)
lw a1, 0(a1)
subw a0, a0, a1
ret
twoSum:
addi sp, sp, -64
sd ra, 56(sp)
sd s0, 48(sp)
sd s1, 40(sp)
sd s2, 32(sp)
sd s3, 24(sp)
sd s4, 16(sp)
sd s5, 8(sp)... |
19 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O3 | RISC-V 64 clang 21.1.0 | cmp:
lw a0, 0(a0)
lw a1, 0(a1)
subw a0, a0, a1
ret
twoSum:
addi sp, sp, -64
sd ra, 56(sp)
sd s0, 48(sp)
sd s1, 40(sp)
sd s2, 32(sp)
sd s3, 24(sp)
sd s4, 16(sp)
sd s5, 8(sp)... |
20 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O0 | RISC-V 64 gcc 15.2.0 | cmp:
addi sp,sp,-32
sd ra,24(sp)
sd s0,16(sp)
addi s0,sp,32
sd a0,-24(s0)
sd a1,-32(s0)
ld a5,-24(s0)
lw a4,0(a5)
ld a5,-32(s0)
lw a5,0(a5)
subw a5,a4,a5
sext.w a5,a5
... |
21 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O1 | RISC-V 64 gcc 15.2.0 | cmp:
lw a0,0(a0)
lw a5,0(a1)
subw a0,a0,a5
ret
twoSum:
addi sp,sp,-48
sd ra,40(sp)
sd s0,32(sp)
sd s1,24(sp)
sd s2,16(sp)
sd s3,8(sp)
sd s4,0(sp)
mv s0,a0
mv s1... |
22 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O2 | RISC-V 64 gcc 15.2.0 | cmp:
lw a0,0(a0)
lw a5,0(a1)
subw a0,a0,a5
ret
twoSum:
addi sp,sp,-48
addiw a5,a1,1
sd s2,16(sp)
mv s2,a0
slli a0,a5,3
sd s0,32(sp)
sd s1,24(sp)
sd a1,0(sp)
sd ra,40... |
23 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | riscv64 | -O3 | RISC-V 64 gcc 15.2.0 | cmp:
lw a0,0(a0)
lw a5,0(a1)
subw a0,a0,a5
ret
twoSum:
addi sp,sp,-48
addiw a5,a1,1
sd s2,16(sp)
mv s2,a0
slli a0,a5,3
sd s0,32(sp)
sd s1,24(sp)
sd a1,0(sp)
sd ra,40... |
24 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O0 | x86-64 clang 21.1.0 | cmp:
push rbp
mov rbp, rsp
mov qword ptr [rbp - 8], rdi
mov qword ptr [rbp - 16], rsi
mov rax, qword ptr [rbp - 8]
mov eax, dword ptr [rax]
mov rcx, qword ptr [rbp - 16]
sub eax, dword ptr [rcx]
pop rbp
re... |
25 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O1 | x86-64 clang 21.1.0 | cmp:
mov eax, dword ptr [rdi]
sub eax, dword ptr [rsi]
ret
twoSum:
push rbp
push r15
push r14
push r13
push r12
push rbx
push rax
mov ebp, edx
mov r14d, esi
mov r12, rdi
... |
26 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O2 | x86-64 clang 21.1.0 | cmp:
mov eax, dword ptr [rdi]
sub eax, dword ptr [rsi]
ret
.LCPI1_1:
.long 2
.long 2
.zero 4
.zero 4
.LCPI1_2:
.long 4
.long 4
.zero 4
.zero 4
.LCPI1_3:
.long 0
.long 1
.long 0
... |
27 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O3 | x86-64 clang 21.1.0 | cmp:
mov eax, dword ptr [rdi]
sub eax, dword ptr [rsi]
ret
.LCPI1_1:
.long 2
.long 2
.zero 4
.zero 4
.LCPI1_2:
.long 4
.long 4
.zero 4
.zero 4
.LCPI1_3:
.long 0
.long 1
.long 0
... |
28 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O0 | x86-64 gcc 15.2 | cmp:
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov QWORD PTR [rbp-16], rsi
mov rax, QWORD PTR [rbp-8]
mov edx, DWORD PTR [rax]
mov rax, QWORD PTR [rbp-16]
mov eax, DWORD PTR [rax]
sub edx, eax
mov ... |
29 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O1 | x86-64 gcc 15.2 | cmp:
mov eax, DWORD PTR [rdi]
sub eax, DWORD PTR [rsi]
ret
twoSum:
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov r13, rdi
mov r12d, esi
mov ebp, edx
lea edi, [rsi+1]
movsx... |
30 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O2 | x86-64 gcc 15.2 | cmp:
mov eax, DWORD PTR [rdi]
sub eax, DWORD PTR [rsi]
ret
twoSum:
push r14
mov r14d, esi
push r13
mov r13, rdi
lea edi, [rsi+1]
push r12
movsx rdi, edi
mov r12d, edx
push rbp
sa... |
31 | 1 | Two Sum | Easy | /*
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9... | x86-64 | -O3 | x86-64 gcc 15.2 | cmp:
mov eax, DWORD PTR [rdi]
sub eax, DWORD PTR [rsi]
ret
twoSum:
push r14
mov r14d, esi
push r13
mov r13, rdi
lea edi, [rsi+1]
push r12
movsx rdi, edi
mov r12d, edx
push rbp
sa... |
32 | 2 | Add Two Numbers | Medium | /*
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the n... | aarch64 | -O0 | ARM64 gcc 15.2.0 | addTwoNumbers:
stp x29, x30, [sp, -64]!
mov x29, sp
str x0, [sp, 24]
str x1, [sp, 16]
str xzr, [sp, 56]
str wzr, [sp, 44]
b .L2
.L7:
mov x0, 16
bl malloc
str x0, [sp, 32]
ldr x0, [sp, 2... |
33 | 2 | Add Two Numbers | Medium | /*
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the n... | aarch64 | -O1 | ARM64 gcc 15.2.0 | addTwoNumbers:
stp x29, x30, [sp, -80]!
mov x29, sp
stp x19, x20, [sp, 16]
stp x21, x22, [sp, 32]
mov x20, x0
orr x0, x0, x1
cbz x0, .L8
stp x23, x24, [sp, 48]
stp x25, x26, [sp, 64]
mov x21, x1
... |
34 | 2 | Add Two Numbers | Medium | /*
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the n... | aarch64 | -O2 | ARM64 gcc 15.2.0 | addTwoNumbers:
stp x29, x30, [sp, -80]!
mov x29, sp
stp x19, x20, [sp, 16]
mov x20, x1
mov w19, 0
stp x21, x22, [sp, 32]
mov w21, 26215
mov w22, 10
stp x23, x24, [sp, 48]
mov x23, x0
orr x... |
35 | 2 | Add Two Numbers | Medium | /*
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the n... | aarch64 | -O3 | ARM64 gcc 15.2.0 | addTwoNumbers:
stp x29, x30, [sp, -80]!
mov x29, sp
stp x19, x20, [sp, 16]
mov x20, x1
mov w19, 0
stp x21, x22, [sp, 32]
mov w21, 26215
mov w22, 10
stp x23, x24, [sp, 48]
mov x23, x0
orr x... |
End of preview. Expand in Data Studio
LeetCode Assembly Dataset
441 LeetCode problems solved in C, compiled to assembly across 4 architectures, 2 compilers, and 4 optimization levels using GCC and Clang via the Godbolt Compiler Explorer API.
Dataset Summary
| Stat | Value |
|---|---|
| Total rows | 14,112 |
| Unique problems | 441 |
| Architectures | x86-64, AArch64, MIPS64, RISC-V 64 |
| Compilers | GCC 15.2, Clang 21.1.0 |
| Optimization levels | -O0, -O1, -O2, -O3 |
| Compilation success rate | 100% |
| Difficulty split | Easy: 98, Medium: 259, Hard: 84 |
Each problem has 32 assembly variants (4 architectures x 2 compilers x 4 optimization levels), making this useful for studying how the same algorithm compiles differently across ISAs, compilers, and optimization settings.
Key Insights
- -O3 often produces more code than -O0, not less. Across all architectures, -O3 output is 37-73% larger on average due to aggressive inlining and loop unrolling.
- -O1 consistently produces the most compact assembly across all four architectures.
- Recursive tree problems see extreme -O3 blowup. The top 10 largest O3-vs-O0 ratios are all binary tree problems. Worst case: Longest Univalue Path goes from 90 lines (O0) to 3,809 lines (O3) -- a 42x increase.
- Iterative and math problems shrink dramatically at -O3. Flip String to Monotone Increasing drops from 89 to 8 lines (91% reduction). Nim Game compiles down to just 4 lines.
- AArch64 produces the most compact assembly at -O2 (avg 153 lines), followed by x86-64 (170), RISC-V (170), and MIPS64 (236). MIPS is 39% more verbose than AArch64.
- Hard problems produce 2x more assembly than Easy problems at -O2 on x86-64 (247 vs 121 avg lines). Algorithmic complexity maps directly to code size.
- The largest output is LFU Cache (1,121 lines at -O0 on x86-64), a complex doubly-linked list plus hash table implementation.
- The smallest output is Nim Game at -O3 (4 lines on x86-64) -- the entire solution optimizes to a single bitwise AND.
Use Cases
- Training or evaluating models on C-to-assembly translation
- Studying how optimization levels affect generated code
- Compiler behavior research
Schema
| Column | Type | Description |
|---|---|---|
id |
int | Unique row identifier (0-14111) |
problem_id |
int | LeetCode problem number |
problem_title |
string | Problem name (e.g. "Two Sum") |
difficulty |
string | Easy, Medium, or Hard |
c_source |
string | Complete C source code |
architecture |
string | Target ISA: x86-64, aarch64, mips64, riscv64 |
optimization |
string | Optimization flag: -O0, -O1, -O2, -O3 |
compiler |
string | Compiler version used (e.g. x86-64 gcc 15.2, x86-64 clang 21.1.0) |
assembly |
string | Compiled assembly output |
Usage
from datasets import load_dataset
ds = load_dataset("ronantakizawa/leetcode-assembly", split="train")
# Get all x86-64 GCC assembly at -O2
x86_gcc_O2 = ds.filter(lambda r: r["architecture"] == "x86-64" and r["compiler"].startswith("x86-64 gcc") and r["optimization"] == "-O2")
# Compare GCC vs Clang for the same problem
two_sum = ds.filter(lambda r: r["problem_id"] == 1 and r["architecture"] == "x86-64" and r["optimization"] == "-O2")
for row in two_sum:
print(f"--- {row['compiler']} ---")
print(row["assembly"][:200])
print()
Sources
C solutions were collected from three open-source GitHub repositories of pure-C LeetCode solutions:
- vli02/leetcode (383 solutions)
- begeekmyfriend/leetcode (215 solutions)
- lennylxx/leetcode (159 solutions)
After deduplication, 441 unique problems remained. Solutions are self-contained C files using only the standard library (no C++ STL), producing clean and readable assembly output.
- Downloads last month
- 55