// File: chai2010[P]defer/hello.cc
// Function: main
int main() {
	defer done;

	defer []{ printf("lambda 1\n"); };
	defer []{ printf("lambda 2\n"); };

	defer std::bind(&MyStruct::MethodA, MyStruct());
	defer std::bind(&MyStruct::MethodB, MyStruct());
	defer std::bind(printf, "printf %s %d\n", "hello world", 2015);

	FILE* fp = fopen("defer.h", "rt");
	if(fp == NULL) {
		printf("open \"defer.h\" failed!\n");
		return -1;
	}
	defer [&]{ printf("fclose(\"defer.h\")\n"); fclose(fp); }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movl $0x0, -0x4(%rbp)
leaq -0x39(%rip), %rdx       # 0x2270
leaq -0x28(%rbp), %rdi
leaq -0x29(%rbp), %rsi
callq 0x6e50
leaq -0x50(%rbp), %rdi
leaq -0x51(%rbp), %rsi
leaq -0x52(%rbp), %rdx
callq 0x2980
jmp 0x22c9
leaq -0x88(%rbp), %rdi
leaq -0x89(%rbp), %rsi
leaq -0x8a(%rbp), %rdx
callq 0x29b0
jmp 0x22e5
leaq 0x4c04(%rip), %rax      # 0x6ef0
movq %rax, -0xe0(%rbp)
movq $0x0, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0xe1(%rbp), %rdx
callq 0x6eb0
jmp 0x231a
leaq -0xb0(%rbp), %rdi
leaq -0xb1(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x6e80
jmp 0x2336
leaq 0x4bd3(%rip), %rax      # 0x6f10
movq %rax, -0x138(%rbp)
movq $0x0, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x139(%rbp), %rdx
callq 0x6eb0
jmp 0x236b
leaq -0x108(%rbp), %rdi
leaq -0x109(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0x6e80
jmp 0x2387
movl $0x7df, -0x18c(%rbp)    # imm = 0x7DF
movq 0xec30(%rip), %rsi      # 0x10fc8
leaq 0x7eff(%rip), %rdx      # 0xa29e
leaq 0x7f06(%rip), %rcx      # 0xa2ac
leaq -0x188(%rbp), %rdi
leaq -0x18c(%rbp), %r8
callq 0x6f60
jmp 0x23bb
leaq -0x160(%rbp), %rdi
leaq -0x161(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x6f30
jmp 0x23d7
leaq 0x7eda(%rip), %rdi      # 0xa2b8
leaq 0x7fba(%rip), %rsi      # 0xa39f
callq 0x2120
movq %rax, -0x3e0(%rbp)
jmp 0x23f3
movq -0x3e0(%rbp), %rax
movq %rax, -0x198(%rbp)
cmpq $0x0, -0x198(%rbp)
jne 0x249b
leaq 0x7eaa(%rip), %rdi      # 0xa2c0
xorl %eax, %eax
callq 0x2170
jmp 0x241f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x19c(%rbp)
jmp 0x28e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x296a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2955
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2949
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x293d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2931
leaq -0x198(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1c1(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x29e0
jmp 0x24c5
movl $0x400, %edi            # imm = 0x400
callq 0x2030
movq %rax, -0x3e8(%rbp)
jmp 0x24d8
movq -0x3e8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x1f9(%rbp), %rsi
leaq -0x208(%rbp), %rdx
callq 0x2a10
jmp 0x2510
leaq -0x228(%rbp), %rdi
leaq -0x229(%rbp), %rsi
leaq -0x22a(%rbp), %rdx
callq 0x2a40
jmp 0x252c
leaq -0x250(%rbp), %rdi
leaq -0x251(%rbp), %rsi
leaq -0x252(%rbp), %rdx
callq 0x2a70
jmp 0x2548
leaq -0x278(%rbp), %rdi
leaq -0x279(%rbp), %rsi
leaq -0x27a(%rbp), %rdx
callq 0x2aa0
jmp 0x2564
leaq -0x2a0(%rbp), %rdi
leaq -0x2a1(%rbp), %rsi
leaq -0x2a2(%rbp), %rdx
callq 0x2ad0
jmp 0x2580
leaq -0x2c8(%rbp), %rdi
leaq -0x2c9(%rbp), %rsi
leaq -0x2ca(%rbp), %rdx
callq 0x2b00
jmp 0x259c
leaq -0x2f0(%rbp), %rdi
leaq -0x2f1(%rbp), %rsi
leaq -0x2f2(%rbp), %rdx
callq 0x2b30
jmp 0x25b8
leaq -0x2f0(%rbp), %rdi
callq 0x6fb0
leaq -0x2c8(%rbp), %rdi
callq 0x6fb0
leaq -0x2a0(%rbp), %rdi
callq 0x6fb0
leaq -0x318(%rbp), %rdi
leaq -0x319(%rbp), %rsi
leaq -0x31a(%rbp), %rdx
callq 0x2b60
jmp 0x25f8
leaq -0x348(%rbp), %rdi
callq 0x7000
movl $0x0, -0x34c(%rbp)
leaq -0x34c(%rbp), %rax
movq %rax, -0x380(%rbp)
leaq -0x370(%rbp), %rdi
leaq -0x371(%rbp), %rsi
leaq -0x380(%rbp), %rdx
callq 0x2b90
jmp 0x2638
leaq -0x398(%rbp), %rdi
callq 0x7020
movl $0x1, -0x39c(%rbp)
cmpl $0x64, -0x39c(%rbp)
jg 0x2790
leaq -0x348(%rbp), %rax
movq %rax, -0x3b8(%rbp)
leaq -0x34c(%rbp), %rax
movq %rax, -0x3b0(%rbp)
leaq -0x3a8(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
leaq -0x39c(%rbp), %rdx
callq 0x2bc0
jmp 0x2693
leaq -0x398(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x7040
jmp 0x26a8
leaq -0x3a8(%rbp), %rdi
callq 0x7070
movl -0x39c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x39c(%rbp)
jmp 0x264e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x28a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x6fb0
leaq -0x2a0(%rbp), %rdi
callq 0x6fb0
jmp 0x28a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2899
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2881
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x7070
jmp 0x2881
leaq -0x398(%rbp), %rax
movq %rax, -0x3c0(%rbp)
movq -0x3c0(%rbp), %rdi
callq 0x70a0
movq %rax, -0x3c8(%rbp)
movq -0x3c0(%rbp), %rdi
callq 0x70d0
movq %rax, -0x3d0(%rbp)
leaq -0x3c8(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x7100
testb $0x1, %al
jne 0x27dd
jmp 0x280e
leaq -0x3c8(%rbp), %rdi
callq 0x7140
movq %rax, -0x3d8(%rbp)
movq -0x3d8(%rbp), %rdi
callq 0x2150
jmp 0x27fe
jmp 0x2800
leaq -0x3c8(%rbp), %rdi
callq 0x7160
jmp 0x27c4
movl $0x0, -0x4(%rbp)
movl $0x1, -0x19c(%rbp)
leaq -0x398(%rbp), %rdi
callq 0x7180
leaq -0x370(%rbp), %rdi
callq 0x6fb0
leaq -0x318(%rbp), %rdi
callq 0x6fb0
leaq -0x278(%rbp), %rdi
callq 0x6fb0
leaq -0x250(%rbp), %rdi
callq 0x6fb0
leaq -0x228(%rbp), %rdi
callq 0x6fb0
leaq -0x1f8(%rbp), %rdi
callq 0x6fb0
leaq -0x1c0(%rbp), %rdi
callq 0x6fb0
jmp 0x28e3
leaq -0x398(%rbp), %rdi
callq 0x7180
leaq -0x370(%rbp), %rdi
callq 0x6fb0
leaq -0x318(%rbp), %rdi
callq 0x6fb0
leaq -0x278(%rbp), %rdi
callq 0x6fb0
leaq -0x250(%rbp), %rdi
callq 0x6fb0
leaq -0x228(%rbp), %rdi
callq 0x6fb0
leaq -0x1f8(%rbp), %rdi
callq 0x6fb0
leaq -0x1c0(%rbp), %rdi
callq 0x6fb0
jmp 0x2931
leaq -0x160(%rbp), %rdi
callq 0x6fb0
leaq -0x108(%rbp), %rdi
callq 0x6fb0
leaq -0xb0(%rbp), %rdi
callq 0x6fb0
leaq -0x88(%rbp), %rdi
callq 0x6fb0
leaq -0x50(%rbp), %rdi
callq 0x6fb0
leaq -0x28(%rbp), %rdi
callq 0x6fb0
movl -0x4(%rbp), %eax
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
leaq -0x160(%rbp), %rdi
callq 0x6fb0
leaq -0x108(%rbp), %rdi
callq 0x6fb0
leaq -0xb0(%rbp), %rdi
callq 0x6fb0
leaq -0x88(%rbp), %rdi
callq 0x6fb0
leaq -0x50(%rbp), %rdi
callq 0x6fb0
leaq -0x28(%rbp), %rdi
callq 0x6fb0
movq -0x60(%rbp), %rdi
callq 0x2160
nopl (%rax)