#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*/ assertStringsEqual(char *, char *);
int /*<<< orphan*/ snprintf(char *, unsigned int, char *, int);
void test_snprintf() {
  char buffer[100];
  snprintf(buffer, 100U, "%d", -1000);
  assertStringsEqual(buffer, "-1000");
  snprintf(buffer, 3U, "%d", -1000);
  assertStringsEqual(buffer, "-1");
}


x86 assembly (clang, -O0):
<test_snprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
lea    0xec8(%rip),%rdx
mov    $0xfffffc18,%ecx
call   1030 <snprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <assertStringsEqual@plt>
lea    -0x70(%rbp),%rdi
mov    $0x3,%esi
lea    0xe9e(%rip),%rdx
mov    $0xfffffc18,%ecx
call   1030 <snprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1040 <assertStringsEqual@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_snprintf>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xed2(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    $0xfffffc18,%ecx
call   1030 <snprintf@plt>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1040 <assertStringsEqual@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
mov    $0xfffffc18,%ecx
call   1030 <snprintf@plt>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1040 <assertStringsEqual@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"-1000\00"
@.str.2 = [3 x i8] c"-1\00"
define void @test_snprintf() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 -1000)
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = call i32 @assertStringsEqual(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 -1000)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%9 = call i32 @assertStringsEqual(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"-1000\00"
@.str.2 = [3 x i8] c"-1\00"
define void @test_snprintf() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 -1000)
%4 = call i32 @assertStringsEqual(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @snprintf(i8* %2, i32 3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 -1000)
%6 = call i32 @assertStringsEqual(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}