#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 */
typedef int ssize_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ puts(char *);
int snprintf(char *, int, char *, int, char *, size_t, long long);
int /*<<< orphan*/ strcmp(char *, char *);
int ulz_snprintf(char *, int, char *, ...);
int main() {
  char buf[128];
  ssize_t ret;
  ret = ulz_snprintf(buf, sizeof(buf), "[%.4d] foo bar %s\n", 13, "baz");
  assert(ret == 19);
  puts(buf);
  ret = ulz_snprintf(NULL, 0, "[%.4d] foo bar %s\n", 13, "baz");
  assert(ret == 19);
  ret =
      ulz_snprintf(buf, sizeof(buf), "[%d] foo bar %s%%%zu,%lld\n", 13, "baz",
                   (size_t)0xFFFFFFFFFFFFFFFFL, (long long)0xFFFFFFFFFFFFFFFFL);
  puts(buf);
  assert(ret == snprintf(buf, sizeof(buf), "[%d] foo bar %s%%%zu,%lld\n", 13,
                         "baz", (size_t)0xFFFFFFFFFFFFFFFFL,
                         (long long)0xFFFFFFFFFFFFFFFFL));
  ret =
      ulz_snprintf(buf, sizeof(buf), "[%d] foo bar %s%%%zu,%lld\n%", 13, "baz",
                   (size_t)0xFFFFFFFFFFFFFFFFL, (long long)0xFFFFFFFFFFFFFFFFL);
  assert(ret == -1);
  ret = ulz_snprintf(NULL, 0, "[%.4d] foo bar %s\n", 13, "baz");
  assert(ret == 19);
  ret = ulz_snprintf(buf, 4, "%d", 1337);
  assert(ret == 3);
  assert(!strcmp(buf, "133"));
  puts(buf);
  ret = ulz_snprintf(NULL, 0, "%d", 1337);
  assert(ret == 4);
  ret = ulz_snprintf(buf, sizeof(buf), "%p", buf);
  puts(buf);
  ret = ulz_snprintf(NULL, 0, "%x", 0xa);
  assert(ret == 1);
  ret = ulz_snprintf(NULL, 0, "%X", 0xa);
  assert(ret == 1);
  ret = ulz_snprintf(buf, 10, "%x", 0xa);
  assert(ret == 1);
  assert(!strcmp(buf, "a"));
  puts(buf);
  ret = ulz_snprintf(buf, 10, "%X", 0xa);
  assert(ret == 1);
  assert(!strcmp(buf, "A"));
  puts(buf);
  ret = ulz_snprintf(NULL, 0, "%.2x", 0xa);
  assert(ret == 2);
  ret = ulz_snprintf(NULL, 0, "%.2X", 0xa);
  assert(ret == 2);
  ret = ulz_snprintf(buf, 10, "%.2x", 0xa);
  assert(ret == 2);
  assert(!strcmp(buf, "0a"));
  puts(buf);
  ret = ulz_snprintf(buf, 10, "%.2X", 0xa);
  assert(ret == 2);
  assert(!strcmp(buf, "0A"));
  puts(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
lea    0xe8b(%rip),%rdx
mov    $0xd,%ecx
lea    0xe92(%rip),%r8
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x13,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xe45(%rip),%rdx
mov    $0xd,%ecx
lea    0xe4c(%rip),%r8
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x13,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
lea    0xe1c(%rip),%rdx
mov    $0xd,%ecx
lea    0xe0c(%rip),%r8
mov    $0xffffffffffffffff,%r9
movq   $0xffffffffffffffff,(%rsp)
ff
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x94(%rbp),%eax
mov    %eax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
lea    0xdc9(%rip),%rdx
mov    $0xd,%ecx
lea    0xdb9(%rip),%r8
mov    $0xffffffffffffffff,%r9
movq   $0xffffffffffffffff,(%rsp)
ff
call   1040 <snprintf@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
lea    0xd9a(%rip),%rdx
mov    $0xd,%ecx
lea    0xd6f(%rip),%r8
mov    $0xffffffffffffffff,%r9
movq   $0xffffffffffffffff,(%rsp)
ff
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0xffffffff,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xd1f(%rip),%rdx
mov    $0xd,%ecx
lea    0xd26(%rip),%r8
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x13,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    $0x4,%esi
lea    0xd2d(%rip),%rdx
mov    $0x539,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x3,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    0xcfc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xcc9(%rip),%rdx
mov    $0x539,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x4,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rcx
mov    $0x80,%esi
lea    0xc90(%rip),%rdx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xc6d(%rip),%rdx
mov    $0xa,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xc3d(%rip),%rdx
mov    $0xa,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%ecx
lea    0xc01(%rip),%rdx
mov    %ecx,%esi
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    0xbe1(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%ecx
lea    0xb9d(%rip),%rdx
mov    %ecx,%esi
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    0xb7d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xb3f(%rip),%rdx
mov    $0xa,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x2,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
lea    0xb11(%rip),%rdx
mov    $0xa,%ecx
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x2,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%ecx
lea    0xad3(%rip),%rdx
mov    %ecx,%esi
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x2,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    0xaac(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%ecx
lea    0xa71(%rip),%rdx
mov    %ecx,%esi
mov    $0x0,%al
call   1070 <ulz_snprintf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x2,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
lea    0xa48(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x90(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
lea    0xeaa(%rip),%r15
lea    0xeb6(%rip),%r12
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
mov    $0xd,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x13,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    $0xd,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x13,%eax
sete   %dil
call   1050 <assert@plt>
movq   $0xffffffffffffffff,(%rsp)
ff
lea    0xe52(%rip),%rbx
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
mov    $0xd,%ecx
mov    %r12,%r8
mov    $0xffffffffffffffff,%r9
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <puts@plt>
movq   $0xffffffffffffffff,(%rsp)
ff
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
mov    $0xd,%ecx
mov    %r12,%r8
mov    $0xffffffffffffffff,%r9
call   1040 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1050 <assert@plt>
movq   $0xffffffffffffffff,(%rsp)
ff
lea    0xdff(%rip),%rdx
mov    %r14,%rdi
mov    $0x80,%esi
mov    $0xd,%ecx
mov    %r12,%r8
mov    $0xffffffffffffffff,%r9
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    $0xd,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x13,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xdc4(%rip),%rbx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
mov    $0x539,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x333331,0x10(%rsp)
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x539,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xd5f(%rip),%rdx
mov    %r14,%rdi
mov    $0x80,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xd41(%rip),%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xd1c(%rip),%r15
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpw   $0x61,0x10(%rsp)
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpw   $0x41,0x10(%rsp)
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xc7b(%rip),%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xc58(%rip),%r15
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x6130,%eax
xor    0x10(%rsp),%eax
movzbl 0x12(%rsp),%ecx
xor    %edi,%edi
or     %ax,%cx
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
mov    $0xa,%ecx
xor    %eax,%eax
call   1060 <ulz_snprintf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
mov    $0x4130,%eax
xor    0x10(%rsp),%eax
movzbl 0x12(%rsp),%ecx
xor    %edi,%edi
or     %ax,%cx
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"[%.4d] foo bar %s\0A\00"
@.str.1 = [4 x i8] c"baz\00"
@.str.2 = [27 x i8] c"[%d] foo bar %s%%%zu,%lld\0A\00"
@.str.3 = [28 x i8] c"[%d] foo bar %s%%%zu,%lld\0A%\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"133\00"
@.str.6 = [3 x i8] c"%p\00"
@.str.7 = [3 x i8] c"%x\00"
@.str.8 = [3 x i8] c"%X\00"
@.str.9 = [2 x i8] c"a\00"
@.str.10 = [2 x i8] c"A\00"
@.str.11 = [5 x i8] c"%.2x\00"
@.str.12 = [5 x i8] c"%.2X\00"
@.str.13 = [3 x i8] c"0a\00"
@.str.14 = [3 x i8] c"0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %4, i32 128, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 19
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i32 @puts(i8* %10)
%12 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 19
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %17, i32 128, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
store i32 %18, i32* %3
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%20 = call i32 @puts(i8* %19)
%21 = load i32, i32* %3
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%23 = call i32 @snprintf(i8* %22, i32 128, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
%24 = icmp eq i32 %21, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%28 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %27, i32 128, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, -1
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 19
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %38, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1337)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 3
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
%47 = xor i1 %46, true
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%51 = call i32 @puts(i8* %50)
%52 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1337)
store i32 %52, i32* %3
%53 = load i32, i32* %3
%54 = icmp eq i32 %53, 4
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%59 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %57, i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %58)
store i32 %59, i32* %3
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%61 = call i32 @puts(i8* %60)
%62 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 10)
store i32 %62, i32* %3
%63 = load i32, i32* %3
%64 = icmp eq i32 %63, 1
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 10)
store i32 %67, i32* %3
%68 = load i32, i32* %3
%69 = icmp eq i32 %68, 1
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%73 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %72, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 10)
store i32 %73, i32* %3
%74 = load i32, i32* %3
%75 = icmp eq i32 %74, 1
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
%78 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%79 = call i32 @strcmp(i8* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
%81 = xor i1 %80, true
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%85 = call i32 @puts(i8* %84)
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%87 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %86, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 10)
store i32 %87, i32* %3
%88 = load i32, i32* %3
%89 = icmp eq i32 %88, 1
%90 = zext i1 %89 to i32
%91 = call i32 @assert(i32 %90)
%92 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%93 = call i32 @strcmp(i8* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%94 = icmp ne i32 %93, 0
%95 = xor i1 %94, true
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
%98 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%99 = call i32 @puts(i8* %98)
%100 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 10)
store i32 %100, i32* %3
%101 = load i32, i32* %3
%102 = icmp eq i32 %101, 2
%103 = zext i1 %102 to i32
%104 = call i32 @assert(i32 %103)
%105 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 10)
store i32 %105, i32* %3
%106 = load i32, i32* %3
%107 = icmp eq i32 %106, 2
%108 = zext i1 %107 to i32
%109 = call i32 @assert(i32 %108)
%110 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%111 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %110, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 10)
store i32 %111, i32* %3
%112 = load i32, i32* %3
%113 = icmp eq i32 %112, 2
%114 = zext i1 %113 to i32
%115 = call i32 @assert(i32 %114)
%116 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%117 = call i32 @strcmp(i8* %116, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%118 = icmp ne i32 %117, 0
%119 = xor i1 %118, true
%120 = zext i1 %119 to i32
%121 = call i32 @assert(i32 %120)
%122 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%123 = call i32 @puts(i8* %122)
%124 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%125 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %124, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 10)
store i32 %125, i32* %3
%126 = load i32, i32* %3
%127 = icmp eq i32 %126, 2
%128 = zext i1 %127 to i32
%129 = call i32 @assert(i32 %128)
%130 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%131 = call i32 @strcmp(i8* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%132 = icmp ne i32 %131, 0
%133 = xor i1 %132, true
%134 = zext i1 %133 to i32
%135 = call i32 @assert(i32 %134)
%136 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%137 = call i32 @puts(i8* %136)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"[%.4d] foo bar %s\0A\00"
@.str.1 = [4 x i8] c"baz\00"
@.str.2 = [27 x i8] c"[%d] foo bar %s%%%zu,%lld\0A\00"
@.str.3 = [28 x i8] c"[%d] foo bar %s%%%zu,%lld\0A%\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"%p\00"
@.str.7 = [3 x i8] c"%x\00"
@.str.8 = [3 x i8] c"%X\00"
@.str.11 = [5 x i8] c"%.2x\00"
@.str.12 = [5 x i8] c"%.2X\00"
@.str.13 = [3 x i8] c"0a\00"
@.str.14 = [3 x i8] c"0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 128, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32 %3, 19
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i32 @puts(i8* %2)
%8 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 19
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 128, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
%13 = call i32 @puts(i8* %2)
%14 = call i32 @snprintf(i8* %2, i32 128, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
%15 = icmp eq i32 %12, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 128, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 -1, i64 -1)
%19 = icmp eq i32 %18, -1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32 %22, 19
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1337)
%27 = icmp eq i32 %26, 3
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = bitcast [128 x i8]* %1 to i32*
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 3355441
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = call i32 @puts(i8* %2)
%36 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 1337)
%37 = icmp eq i32 %36, 4
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%41 = call i32 @puts(i8* %2)
%42 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 10)
%43 = icmp eq i32 %42, 1
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 10)
%47 = icmp eq i32 %46, 1
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 10)
%51 = icmp eq i32 %50, 1
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = bitcast [128 x i8]* %1 to i16*
%55 = load i16, i16* %54
%56 = icmp eq i16 %55, 97
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = call i32 @puts(i8* %2)
%60 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 10)
%61 = icmp eq i32 %60, 1
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = load i16, i16* %54
%65 = icmp eq i16 %64, 65
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = call i32 @puts(i8* %2)
%69 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 10)
%70 = icmp eq i32 %69, 2
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* null, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 10)
%74 = icmp eq i32 %73, 2
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 10)
%78 = icmp eq i32 %77, 2
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = call i32 @bcmp(i8* dereferenceable(3) %2, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i64 3)
%82 = icmp eq i32 %81, 0
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
%85 = call i32 @puts(i8* %2)
%86 = call i32 (i8*, i32, i8*, ...) @ulz_snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 10)
%87 = icmp eq i32 %86, 2
%88 = zext i1 %87 to i32
%89 = call i32 @assert(i32 %88)
%90 = call i32 @bcmp(i8* dereferenceable(3) %2, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i64 3)
%91 = icmp eq i32 %90, 0
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = call i32 @puts(i8* %2)
ret i32 0
}