main() {
  printf("%d %s\n", 5, "hello");
  printf("%d %s\n", 5, L"hello");
  printf("%d %s\n", "hello", 5);
  not_variadic("hi");
  just_str_check("hi %");
  just_str_check("hi %d");
  bad_v_idx(1, 2, "hi %s", 3);
  bad_v_idx2(5, 5, 5, 5, "yo %d", "hi");
  bad_fmt_idx("hi %s", 3, 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xe95(%rip),%rdi
mov    $0x5,%esi
lea    0xe90(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x5,%esi
lea    0xe97(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
lea    0xe61(%rip),%rsi
mov    $0x5,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1070 <not_variadic@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1080 <just_str_check@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1080 <just_str_check@plt>
mov    $0x1,%edi
mov    $0x2,%esi
lea    0xe2e(%rip),%rdx
mov    $0x3,%ecx
mov    $0x0,%al
call   1050 <bad_v_idx@plt>
mov    $0x5,%ecx
lea    0xe1c(%rip),%r8
lea    0xe01(%rip),%r9
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
mov    $0x0,%al
call   1040 <bad_v_idx2@plt>
lea    0xdfb(%rip),%rdi
mov    $0x3,%esi
mov    $0x5,%edx
mov    $0x0,%al
call   1060 <bad_fmt_idx@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rbx
lea    0xe95(%rip),%r14
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5a(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <not_variadic@plt>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1080 <just_str_check@plt>
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1080 <just_str_check@plt>
lea    0xe3b(%rip),%rbx
mov    $0x1,%edi
mov    $0x2,%esi
mov    %rbx,%rdx
mov    $0x3,%ecx
xor    %eax,%eax
call   1050 <bad_v_idx@plt>
lea    0xe21(%rip),%r8
mov    $0x5,%edi
mov    $0x5,%esi
mov    $0x5,%edx
mov    $0x5,%ecx
mov    %r14,%r9
xor    %eax,%eax
call   1040 <bad_v_idx2@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1060 <bad_fmt_idx@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %s\0A\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [6 x i32] [i32 104, i32 101, i32 108, i32 108, i32 111, i32 0]
@.str.3 = [3 x i8] c"hi\00"
@.str.4 = [5 x i8] c"hi %\00"
@.str.5 = [6 x i8] c"hi %d\00"
@.str.6 = [6 x i8] c"hi %s\00"
@.str.7 = [6 x i8] c"yo %d\00"
define i32 @main() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @.str.2, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @not_variadic to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @just_str_check to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @just_str_check to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%7 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @bad_v_idx to i32 (i32, i32, i8*, i32, ...)*)(i32 1, i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 3)
%8 = call i32 (i32, i32, i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @bad_v_idx2 to i32 (i32, i32, i32, i32, i8*, i8*, ...)*)(i32 5, i32 5, i32 5, i32 5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @bad_fmt_idx to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 5)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %s\0A\00"
@.str.1 = [6 x i8] c"hello\00"
@.str.2 = [6 x i32] [i32 104, i32 101, i32 108, i32 108, i32 111, i32 0]
@.str.3 = [3 x i8] c"hi\00"
@.str.4 = [5 x i8] c"hi %\00"
@.str.5 = [6 x i8] c"hi %d\00"
@.str.6 = [6 x i8] c"hi %s\00"
@.str.7 = [6 x i8] c"yo %d\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 5, i32* getelementptr inbounds ([6 x i32], [6 x i32]* @.str.2, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @not_variadic to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @just_str_check to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @just_str_check to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%7 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @bad_v_idx to i32 (i32, i32, i8*, i32, ...)*)(i32 1, i32 2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 3)
%8 = tail call i32 (i32, i32, i32, i32, i8*, i8*, ...) bitcast (i32 (...)* @bad_v_idx2 to i32 (i32, i32, i32, i32, i8*, i8*, ...)*)(i32 5, i32 5, i32 5, i32 5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @bad_fmt_idx to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 5)
ret i32 0
}