int main(int argc, char *argv[]) {
  printf("%s unit test begin\n", __func__);
  demo_foo();
  demo_foo2(2);
  demo_foo2(1);
  demo_foo2(0);
  demo_foo2(-1);
  printf("%s unit test end\n", __func__);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <demo_foo@plt>
mov    $0x2,%edi
mov    $0x0,%al
call   1040 <demo_foo2@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <demo_foo2@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1040 <demo_foo2@plt>
mov    $0xffffffff,%edi
mov    $0x0,%al
call   1040 <demo_foo2@plt>
lea    0xe83(%rip),%rdi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
lea    0xed5(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <demo_foo@plt>
mov    $0x2,%edi
xor    %eax,%eax
call   1040 <demo_foo2@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <demo_foo2@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1040 <demo_foo2@plt>
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1040 <demo_foo2@plt>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"%s unit test begin\0A\00"
@__func__.main = [5 x i8] c"main\00"
@.str.1 = [18 x i8] c"%s unit test end\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0))
%7 = call i32 (...) @demo_foo()
%8 = call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 2)
%9 = call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 1)
%10 = call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 0)
%11 = call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 -1)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"%s unit test begin\0A\00"
@__func__.main = [5 x i8] c"main\00"
@.str.1 = [18 x i8] c"%s unit test end\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0))
%4 = tail call i32 (...) @demo_foo()
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 2)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 1)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 0)
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @demo_foo2 to i32 (i32, ...)*)(i32 -1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__func__.main, i64 0, i64 0))
ret i32 0
}