#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 MPIU_Snprintf(char *, int, char *, ...);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argc, char *argv[]) {
  char buf[1000];
  int n;
  n = MPIU_Snprintf(buf, 100, "This is a test\n");
  printf("%d:%s", n, buf);
  n = MPIU_Snprintf(buf, 100, "This is a test %d\n", 3000000);
  printf("%d:%s", n, buf);
  n = MPIU_Snprintf(buf, 100, "This %s %% %d\n", "is a test for ", -3000);
  printf("%d:%s", n, buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x64,%esi
lea    0xeb4(%rip),%rdx
mov    $0x0,%al
call   1030 <MPIU_Snprintf@plt>
mov    %eax,-0x404(%rbp)
mov    -0x404(%rbp),%esi
lea    -0x400(%rbp),%rdx
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x64,%esi
lea    0xe91(%rip),%rdx
mov    $0x2dc6c0,%ecx
mov    $0x0,%al
call   1030 <MPIU_Snprintf@plt>
mov    %eax,-0x404(%rbp)
mov    -0x404(%rbp),%esi
lea    -0x400(%rbp),%rdx
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    $0x64,%esi
lea    0xe66(%rip),%rdx
lea    0xe6e(%rip),%rcx
mov    $0xfffff448,%r8d
mov    $0x0,%al
call   1030 <MPIU_Snprintf@plt>
mov    %eax,-0x404(%rbp)
mov    -0x404(%rbp),%esi
lea    -0x400(%rbp),%rdx
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
lea    0xecf(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1030 <MPIU_Snprintf@plt>
lea    0xec6(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x2dc6c0,%ecx
xor    %eax,%eax
call   1030 <MPIU_Snprintf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
lea    0xea3(%rip),%rdx
lea    0xeab(%rip),%rcx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0xfffff448,%r8d
xor    %eax,%eax
call   1030 <MPIU_Snprintf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"This is a test\0A\00"
@.str.1 = [6 x i8] c"%d:%s\00"
@.str.2 = [19 x i8] c"This is a test %d\0A\00"
@.str.3 = [15 x i8] c"This %s %% %d\0A\00"
@.str.4 = [15 x i8] c"is a test for \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%9 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %8, i32 100, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %11)
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %13, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 3000000)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%19 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %18, i32 100, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 -3000)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"This is a test\0A\00"
@.str.1 = [6 x i8] c"%d:%s\00"
@.str.2 = [19 x i8] c"This is a test %d\0A\00"
@.str.3 = [15 x i8] c"This %s %% %d\0A\00"
@.str.4 = [15 x i8] c"is a test for \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %5, i8* %4)
%7 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 3000000)
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %7, i8* %4)
%9 = call i32 (i8*, i32, i8*, ...) @MPIU_Snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 -3000)
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %4)
ret i32 0
}