export fn _start() noreturn { assert(add(3, 4) == 7); assert(add(20, 10) == 30); exit(); } fn add(a: u32, b: u32) u32 { var x: u32 = undefined; x = 0; x += a; x += b; return x; } pub fn assert(ok: bool) void { if (!ok) unreachable; // assertion failure } fn exit() noreturn { asm volatile ("syscall" : : [number] "{rax}" (231), [arg1] "{rdi}" (0) : "rcx", "r11", "memory" ); unreachable; } [nix-shell:~/dev/zig/build-release]$ ./zig-cache/bin/zig build-exe test.zig [info] (compiler): Update completed in 0 ms [nix-shell:~/dev/zig/build-release]$ objdump -d ./test -M intel ./test: file format elf64-x86-64 Disassembly of section .text: 0000000008000000 <_start>: 8000000: 55 push rbp 8000001: 48 89 e5 mov rbp,rsp 8000004: 48 81 ec 00 00 00 00 sub rsp,0x0 800000b: bf 03 00 00 00 mov edi,0x3 8000010: be 04 00 00 00 mov esi,0x4 8000015: ff 14 25 10 00 00 04 call QWORD PTR ds:0x4000010 800001c: 83 f8 07 cmp eax,0x7 800001f: 48 0f 94 c7 rex.W sete dil 8000023: ff 14 25 08 00 00 04 call QWORD PTR ds:0x4000008 800002a: bf 14 00 00 00 mov edi,0x14 800002f: be 0a 00 00 00 mov esi,0xa 8000034: ff 14 25 10 00 00 04 call QWORD PTR ds:0x4000010 800003b: 83 f8 1e cmp eax,0x1e 800003e: 48 0f 94 c7 rex.W sete dil 8000042: ff 14 25 08 00 00 04 call QWORD PTR ds:0x4000008 8000049: ff 14 25 18 00 00 04 call QWORD PTR ds:0x4000018 8000050: 5d pop rbp 8000051: c3 ret 000000000800006d : 800006d: 55 push rbp 800006e: 48 89 e5 mov rbp,rsp 8000071: 48 81 ec 00 00 00 00 sub rsp,0x0 8000078: 83 f7 01 xor edi,0x1 800007b: 48 f6 c7 01 rex.W test dil,0x1 800007f: 0f 84 01 00 00 00 je 8000086 8000085: cc int3 8000086: 5d pop rbp 8000087: c3 ret 0000000008000091 : 8000091: 55 push rbp 8000092: 48 89 e5 mov rbp,rsp 8000095: 48 81 ec 10 00 00 00 sub rsp,0x10 800009c: c7 45 00 aa aa aa aa mov DWORD PTR [rbp+0x0],0xaaaaaaaa 80000a3: c7 45 00 00 00 00 00 mov DWORD PTR [rbp+0x0],0x0 80000aa: 8b 45 00 mov eax,DWORD PTR [rbp+0x0] 80000ad: 01 f8 add eax,edi 80000af: 89 45 00 mov DWORD PTR [rbp+0x0],eax 80000b2: 8b 45 00 mov eax,DWORD PTR [rbp+0x0] 80000b5: 01 f0 add eax,esi 80000b7: 89 45 00 mov DWORD PTR [rbp+0x0],eax 80000ba: 8b 45 00 mov eax,DWORD PTR [rbp+0x0] 80000bd: 48 83 c4 10 add rsp,0x10 80000c1: 5d pop rbp 80000c2: c3 ret 00000000080000d3 : 80000d3: 55 push rbp 80000d4: 48 89 e5 mov rbp,rsp 80000d7: 48 81 ec 00 00 00 00 sub rsp,0x0 80000de: b8 e7 00 00 00 mov eax,0xe7 80000e3: 31 ff xor edi,edi 80000e5: 0f 05 syscall 80000e7: cc int3 80000e8: 5d pop rbp 80000e9: c3 ret 00000000080000f1 : 80000f1: 7b 72 61 78 7d 00 72 64 {rax}.rd 00000000080000f9 : 80000f9: 7b 72 64 69 7d 00 79 73 {rdi}.ys 0000000008000101 : 8000101: 73 79 73 63 61 6c 6c 00 syscall.