#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ minprintf(char *, ...);
int main(void) {
  minprintf("test of no format\n");
  minprintf("test of integer format ('%%d'): %d\n", 10);
  minprintf("test of double  format ('%%f'): %f\n", 3.14);
  minprintf("test of string  format ('%%s'): \"%s\"\n", "this is a string");
  minprintf("test of hex     format ('%%x'): %x\n", 65534);
  minprintf("test of complex format ('[%%-15.10s]'): [%-15.10s]\n",
            "hello world!");
  minprintf("test of multiple args: %d, %f, \"%s\"\n", 10, 3.14,
            "this is a string");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <minprintf@plt>
lea    0xee7(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <minprintf@plt>
lea    0xef8(%rip),%rdi
movsd  0xeb1(%rip),%xmm0
mov    $0x1,%al
call   1030 <minprintf@plt>
lea    0xf06(%rip),%rdi
lea    0xf25(%rip),%rsi
mov    $0x0,%al
call   1030 <minprintf@plt>
lea    0xf28(%rip),%rdi
mov    $0xfffe,%esi
mov    $0x0,%al
call   1030 <minprintf@plt>
lea    0xf39(%rip),%rdi
lea    0xf66(%rip),%rsi
mov    $0x0,%al
call   1030 <minprintf@plt>
lea    0xf65(%rip),%rdi
mov    $0xa,%esi
movsd  0xe59(%rip),%xmm0
lea    0xedb(%rip),%rdx
mov    $0x1,%al
call   1030 <minprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xef0(%rip),%rdi
xor    %eax,%eax
call   1030 <minprintf@plt>
lea    0xef5(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <minprintf@plt>
lea    0xf06(%rip),%rdi
movsd  0xebf(%rip),%xmm0
mov    $0x1,%al
call   1030 <minprintf@plt>
lea    0xf14(%rip),%rdi
lea    0xf33(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <minprintf@plt>
lea    0xf33(%rip),%rdi
mov    $0xfffe,%esi
xor    %eax,%eax
call   1030 <minprintf@plt>
lea    0xf44(%rip),%rdi
lea    0xf71(%rip),%rsi
xor    %eax,%eax
call   1030 <minprintf@plt>
lea    0xf70(%rip),%rdi
mov    $0xa,%esi
movsd  0xe64(%rip),%xmm0
mov    %rbx,%rdx
mov    $0x1,%al
call   1030 <minprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"test of no format\0A\00"
@.str.1 = [36 x i8] c"test of integer format ('%%d'): %d\0A\00"
@.str.2 = [36 x i8] c"test of double format ('%%f'): %f\0A\00"
@.str.3 = [38 x i8] c"test of string format ('%%s'): \22%s\22\0A\00"
@.str.4 = [17 x i8] c"this is a string\00"
@.str.5 = [36 x i8] c"test of hex format ('%%x'): %x\0A\00"
@.str.6 = [52 x i8] c"test of complex format ('[%%-15.10s]'): [%-15.10s]\0A\00"
@.str.7 = [13 x i8] c"hello world!\00"
@.str.8 = [37 x i8] c"test of multiple args: %d, %f, \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 10)
%4 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double 3.140000e+00)
%5 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 65534)
%7 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%8 = call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 10, double 3.140000e+00, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"test of no format\0A\00"
@.str.1 = [36 x i8] c"test of integer format ('%%d'): %d\0A\00"
@.str.2 = [36 x i8] c"test of double format ('%%f'): %f\0A\00"
@.str.3 = [38 x i8] c"test of string format ('%%s'): \22%s\22\0A\00"
@.str.4 = [17 x i8] c"this is a string\00"
@.str.5 = [36 x i8] c"test of hex format ('%%x'): %x\0A\00"
@.str.6 = [52 x i8] c"test of complex format ('[%%-15.10s]'): [%-15.10s]\0A\00"
@.str.7 = [13 x i8] c"hello world!\00"
@.str.8 = [37 x i8] c"test of multiple args: %d, %f, \22%s\22\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 10)
%3 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double 3.140000e+00)
%4 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 65534)
%6 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @minprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 10, double 3.140000e+00, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}