#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*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int main(int argc, char **argv) {
  char buffer[256];
  snprintf(buffer, 5, "123456789");
  printf("%s\n", buffer);
  snprintf(buffer, 6, "123456789");
  printf("%s\n", buffer);
  snprintf(buffer, 7, "123456789");
  printf("%s\n", buffer);
  snprintf(buffer, 7, "123%s", "mooooooooooo");
  printf("%s\n", buffer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x5,%esi
lea    0xebb(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x6,%esi
lea    0xe8e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x7,%esi
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    $0x7,%esi
lea    0xe42(%rip),%rdx
lea    0xe41(%rip),%rcx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xecd(%rip),%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xebb(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe73(%rip),%rdx
lea    0xe72(%rip),%rcx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"123456789\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"123%s\00"
@.str.3 = [13 x i8] c"mooooooooooo\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [256 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %18, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"123456789\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"123%s\00"
@.str.3 = [13 x i8] c"mooooooooooo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}