void test_strfmt(void) {
  char str1[1024], str2[1024];
  int n1, n2;
  n1 = strfmt(str1, sizeof(str1), "%06ld", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%06ld", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06d", 123);
  n2 = snprintf(str2, sizeof(str2), "%06d", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%d", -123);
  n2 = snprintf(str2, sizeof(str2), "%d", -123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06lu", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%06lu", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06u", 123);
  n2 = snprintf(str2, sizeof(str2), "%06u", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%lx", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%lx", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%x", 123);
  n2 = snprintf(str2, sizeof(str2), "%x", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%6x", 0x123);
  n2 = snprintf(str2, sizeof(str2), "%6x", 0x123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %5s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %5s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %-29s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %-29s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %29s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %29s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, 10, "test %s this", "hello world");
  n2 = hack_snprintf(str2, 10, "test %s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%s%c%s%c", "hello", ' ', "world", '.');
  n2 = snprintf(str2, sizeof(str2), "%s%c%s%c", "hello", ' ', "world", '.');
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
}


x86 assembly (clang, -O0):
<test_strfmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xe92(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xe68(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xe04(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xddf(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xd7f(%rip),%rdx
mov    $0xffffff85,%ecx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xd5a(%rip),%rdx
mov    $0xffffff85,%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xcf8(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xcce(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xc6a(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xc45(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xbe5(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xbbb(%rip),%rdx
movabs $0x1b69b4bacd05f15,%rcx
9b b6 01
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xb55(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xb30(%rip),%rdx
mov    $0x7b,%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xace(%rip),%rdx
mov    $0x123,%ecx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xaa9(%rip),%rdx
mov    $0x123,%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0xa48(%rip),%rdx
lea    0xa4e(%rip),%rcx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0xa21(%rip),%rdx
lea    0xa27(%rip),%rcx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0x9d3(%rip),%rdx
lea    0x9c0(%rip),%rcx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0x9ac(%rip),%rdx
lea    0x999(%rip),%rcx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0x953(%rip),%rdx
lea    0x932(%rip),%rcx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0x92c(%rip),%rdx
lea    0x90b(%rip),%rcx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0x8d5(%rip),%rdx
lea    0x8a4(%rip),%rcx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0x8ae(%rip),%rdx
lea    0x87d(%rip),%rcx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0xa,%esi
lea    0x810(%rip),%rdx
lea    0x816(%rip),%rcx
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0xa,%esi
lea    0x7e9(%rip),%rdx
lea    0x7ef(%rip),%rcx
mov    $0x0,%al
call   1070 <hack_snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    $0x400,%esi
lea    0x7c8(%rip),%rdx
lea    0x7ca(%rip),%rcx
mov    $0x20,%r8d
lea    0x781(%rip),%r9
movl   $0x2e,(%rsp)
mov    $0x0,%al
call   1060 <strfmt@plt>
mov    %eax,-0x804(%rbp)
lea    -0x800(%rbp),%rdi
mov    $0x400,%esi
lea    0x78d(%rip),%rdx
lea    0x78f(%rip),%rcx
mov    $0x20,%r8d
lea    0x746(%rip),%r9
movl   $0x2e,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x808(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strfmt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0xe98(%rip),%rbx
lea    0x410(%rsp),%r14
movabs $0x1b69b4bacd05f15,%r15
9b b6 01
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%r12
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xe2b(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xdd0(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0xffffff85,%ecx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0xffffff85,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xd73(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xd1d(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xcc2(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xc6a(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x7b,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xc0d(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    $0x123,%ecx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x123,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xbb1(%rip),%r15
lea    0xbb7(%rip),%r13
mov    $0x400,%esi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xb67(%rip),%rbp
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbp,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebx
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbp,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xb19(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
lea    0xacd(%rip),%rbx
mov    $0x400,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebp
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1070 <hack_snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
movl   $0x2e,(%rsp)
lea    0xa24(%rip),%r13
lea    0xa26(%rip),%rbp
lea    0x9e3(%rip),%r15
mov    $0x400,%esi
mov    %r14,%rdi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    $0x20,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1060 <strfmt@plt>
mov    %eax,%ebx
movl   $0x2e,(%rsp)
mov    $0x400,%esi
mov    %r12,%rdi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    $0x20,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1030 <snprintf@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%06ld\00"
@.str.1 = [5 x i8] c"%06d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%06lu\00"
@.str.4 = [5 x i8] c"%06u\00"
@.str.5 = [4 x i8] c"%lx\00"
@.str.6 = [3 x i8] c"%x\00"
@.str.7 = [4 x i8] c"%6x\00"
@.str.8 = [13 x i8] c"test %s this\00"
@.str.9 = [12 x i8] c"hello world\00"
@.str.10 = [14 x i8] c"test %5s this\00"
@.str.11 = [16 x i8] c"test %-29s this\00"
@.str.12 = [15 x i8] c"test %29s this\00"
@.str.13 = [9 x i8] c"%s%c%s%c\00"
@.str.14 = [6 x i8] c"hello\00"
@.str.15 = [6 x i8] c"world\00"
define void @test_strfmt() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %5, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 123456789123456789)
store i32 %6, i32* %3
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %7, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 123456789123456789)
store i32 %8, i32* %4
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp eq i32 %9, %10
%12 = zext i1 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%16 = call i32 @strcmp(i8* %14, i8* %15)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%21 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %20, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123)
store i32 %21, i32* %3
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%23 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %22, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123)
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = icmp eq i32 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %27)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%31 = call i32 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i32 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %33)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%36 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %35, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 -123)
store i32 %36, i32* %3
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%38 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %37, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 -123)
store i32 %38, i32* %4
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = icmp eq i32 %39, %40
%42 = zext i1 %41 to i32
%43 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %42)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%46 = call i32 @strcmp(i8* %44, i8* %45)
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %48)
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%51 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %50, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 123456789123456789)
store i32 %51, i32* %3
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%53 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %52, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 123456789123456789)
store i32 %53, i32* %4
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = icmp eq i32 %54, %55
%57 = zext i1 %56 to i32
%58 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %57)
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%61 = call i32 @strcmp(i8* %59, i8* %60)
%62 = icmp eq i32 %61, 0
%63 = zext i1 %62 to i32
%64 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %63)
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%66 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %65, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 123)
store i32 %66, i32* %3
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%68 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %67, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 123)
store i32 %68, i32* %4
%69 = load i32, i32* %3
%70 = load i32, i32* %4
%71 = icmp eq i32 %69, %70
%72 = zext i1 %71 to i32
%73 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %72)
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%76 = call i32 @strcmp(i8* %74, i8* %75)
%77 = icmp eq i32 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %78)
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%81 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %80, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 123456789123456789)
store i32 %81, i32* %3
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%83 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %82, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 123456789123456789)
store i32 %83, i32* %4
%84 = load i32, i32* %3
%85 = load i32, i32* %4
%86 = icmp eq i32 %84, %85
%87 = zext i1 %86 to i32
%88 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %87)
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%91 = call i32 @strcmp(i8* %89, i8* %90)
%92 = icmp eq i32 %91, 0
%93 = zext i1 %92 to i32
%94 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %93)
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%96 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %95, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 123)
store i32 %96, i32* %3
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%98 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %97, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 123)
store i32 %98, i32* %4
%99 = load i32, i32* %3
%100 = load i32, i32* %4
%101 = icmp eq i32 %99, %100
%102 = zext i1 %101 to i32
%103 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %102)
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%106 = call i32 @strcmp(i8* %104, i8* %105)
%107 = icmp eq i32 %106, 0
%108 = zext i1 %107 to i32
%109 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %108)
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%111 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %110, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 291)
store i32 %111, i32* %3
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%113 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %112, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 291)
store i32 %113, i32* %4
%114 = load i32, i32* %3
%115 = load i32, i32* %4
%116 = icmp eq i32 %114, %115
%117 = zext i1 %116 to i32
%118 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %117)
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%121 = call i32 @strcmp(i8* %119, i8* %120)
%122 = icmp eq i32 %121, 0
%123 = zext i1 %122 to i32
%124 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %123)
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%126 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %125, i64 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %126, i32* %3
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%128 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %127, i64 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %128, i32* %4
%129 = load i32, i32* %3
%130 = load i32, i32* %4
%131 = icmp eq i32 %129, %130
%132 = zext i1 %131 to i32
%133 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %132)
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%136 = call i32 @strcmp(i8* %134, i8* %135)
%137 = icmp eq i32 %136, 0
%138 = zext i1 %137 to i32
%139 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %138)
%140 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%141 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %140, i64 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %141, i32* %3
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%143 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %142, i64 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %143, i32* %4
%144 = load i32, i32* %3
%145 = load i32, i32* %4
%146 = icmp eq i32 %144, %145
%147 = zext i1 %146 to i32
%148 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %147)
%149 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%150 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%151 = call i32 @strcmp(i8* %149, i8* %150)
%152 = icmp eq i32 %151, 0
%153 = zext i1 %152 to i32
%154 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %153)
%155 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%156 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %155, i64 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %156, i32* %3
%157 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%158 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %157, i64 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %158, i32* %4
%159 = load i32, i32* %3
%160 = load i32, i32* %4
%161 = icmp eq i32 %159, %160
%162 = zext i1 %161 to i32
%163 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %162)
%164 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%166 = call i32 @strcmp(i8* %164, i8* %165)
%167 = icmp eq i32 %166, 0
%168 = zext i1 %167 to i32
%169 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %168)
%170 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%171 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %170, i64 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %171, i32* %3
%172 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%173 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %172, i64 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %173, i32* %4
%174 = load i32, i32* %3
%175 = load i32, i32* %4
%176 = icmp eq i32 %174, %175
%177 = zext i1 %176 to i32
%178 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %177)
%179 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%180 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%181 = call i32 @strcmp(i8* %179, i8* %180)
%182 = icmp eq i32 %181, 0
%183 = zext i1 %182 to i32
%184 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %183)
%185 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%186 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %185, i32 10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %186, i32* %3
%187 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%188 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @hack_snprintf to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %187, i32 10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i32 %188, i32* %4
%189 = load i32, i32* %3
%190 = load i32, i32* %4
%191 = icmp eq i32 %189, %190
%192 = zext i1 %191 to i32
%193 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %192)
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%195 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%196 = call i32 @strcmp(i8* %194, i8* %195)
%197 = icmp eq i32 %196, 0
%198 = zext i1 %197 to i32
%199 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %198)
%200 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%201 = call i32 (i8*, i64, i8*, i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, i32, i8*, i32, ...)*)(i8* %200, i64 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 46)
store i32 %201, i32* %3
%202 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%203 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %202, i64 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 46)
store i32 %203, i32* %4
%204 = load i32, i32* %3
%205 = load i32, i32* %4
%206 = icmp eq i32 %204, %205
%207 = zext i1 %206 to i32
%208 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %207)
%209 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%210 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%211 = call i32 @strcmp(i8* %209, i8* %210)
%212 = icmp eq i32 %211, 0
%213 = zext i1 %212 to i32
%214 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %213)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%06ld\00"
@.str.1 = [5 x i8] c"%06d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%06lu\00"
@.str.4 = [5 x i8] c"%06u\00"
@.str.5 = [4 x i8] c"%lx\00"
@.str.6 = [3 x i8] c"%x\00"
@.str.7 = [4 x i8] c"%6x\00"
@.str.8 = [13 x i8] c"test %s this\00"
@.str.9 = [12 x i8] c"hello world\00"
@.str.10 = [14 x i8] c"test %5s this\00"
@.str.11 = [16 x i8] c"test %-29s this\00"
@.str.12 = [15 x i8] c"test %29s this\00"
@.str.13 = [9 x i8] c"%s%c%s%c\00"
@.str.14 = [6 x i8] c"hello\00"
@.str.15 = [6 x i8] c"world\00"
define void @test_strfmt() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 123456789123456789)
%6 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 123456789123456789)
%7 = icmp eq i32 %5, %6
%8 = zext i1 %7 to i32
%9 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %8)
%10 = call i32 @strcmp(i8* %3, i8* %4)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %12)
%14 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123)
%15 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 123)
%16 = icmp eq i32 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %17)
%19 = call i32 @strcmp(i8* %3, i8* %4)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %21)
%23 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 -123)
%24 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 -123)
%25 = icmp eq i32 %23, %24
%26 = zext i1 %25 to i32
%27 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %26)
%28 = call i32 @strcmp(i8* %3, i8* %4)
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %30)
%32 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 123456789123456789)
%33 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 123456789123456789)
%34 = icmp eq i32 %32, %33
%35 = zext i1 %34 to i32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = call i32 @strcmp(i8* %3, i8* %4)
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %39)
%41 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 123)
%42 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 123)
%43 = icmp eq i32 %41, %42
%44 = zext i1 %43 to i32
%45 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %44)
%46 = call i32 @strcmp(i8* %3, i8* %4)
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %48)
%50 = call i32 (i8*, i64, i8*, i64, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i64, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 123456789123456789)
%51 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 123456789123456789)
%52 = icmp eq i32 %50, %51
%53 = zext i1 %52 to i32
%54 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %53)
%55 = call i32 @strcmp(i8* %3, i8* %4)
%56 = icmp eq i32 %55, 0
%57 = zext i1 %56 to i32
%58 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %57)
%59 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 123)
%60 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 123)
%61 = icmp eq i32 %59, %60
%62 = zext i1 %61 to i32
%63 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %62)
%64 = call i32 @strcmp(i8* %3, i8* %4)
%65 = icmp eq i32 %64, 0
%66 = zext i1 %65 to i32
%67 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %66)
%68 = call i32 (i8*, i64, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 291)
%69 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 291)
%70 = icmp eq i32 %68, %69
%71 = zext i1 %70 to i32
%72 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %71)
%73 = call i32 @strcmp(i8* %3, i8* %4)
%74 = icmp eq i32 %73, 0
%75 = zext i1 %74 to i32
%76 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %75)
%77 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%78 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%79 = icmp eq i32 %77, %78
%80 = zext i1 %79 to i32
%81 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %80)
%82 = call i32 @strcmp(i8* %3, i8* %4)
%83 = icmp eq i32 %82, 0
%84 = zext i1 %83 to i32
%85 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %84)
%86 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%87 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%88 = icmp eq i32 %86, %87
%89 = zext i1 %88 to i32
%90 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %89)
%91 = call i32 @strcmp(i8* %3, i8* %4)
%92 = icmp eq i32 %91, 0
%93 = zext i1 %92 to i32
%94 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %93)
%95 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%96 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%97 = icmp eq i32 %95, %96
%98 = zext i1 %97 to i32
%99 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %98)
%100 = call i32 @strcmp(i8* %3, i8* %4)
%101 = icmp eq i32 %100, 0
%102 = zext i1 %101 to i32
%103 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %102)
%104 = call i32 (i8*, i64, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%105 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%106 = icmp eq i32 %104, %105
%107 = zext i1 %106 to i32
%108 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %107)
%109 = call i32 @strcmp(i8* %3, i8* %4)
%110 = icmp eq i32 %109, 0
%111 = zext i1 %110 to i32
%112 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %111)
%113 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %3, i32 10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%114 = call i32 (i8*, i32, i8*, i8*, ...) bitcast (i32 (...)* @hack_snprintf to i32 (i8*, i32, i8*, i8*, ...)*)(i8* %4, i32 10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%115 = icmp eq i32 %113, %114
%116 = zext i1 %115 to i32
%117 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %116)
%118 = call i32 @strcmp(i8* %3, i8* %4)
%119 = icmp eq i32 %118, 0
%120 = zext i1 %119 to i32
%121 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %120)
%122 = call i32 (i8*, i64, i8*, i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @strfmt to i32 (i8*, i64, i8*, i8*, i32, i8*, i32, ...)*)(i8* %3, i64 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 46)
%123 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %4, i64 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 46)
%124 = icmp eq i32 %122, %123
%125 = zext i1 %124 to i32
%126 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %125)
%127 = call i32 @strcmp(i8* %3, i8* %4)
%128 = icmp eq i32 %127, 0
%129 = zext i1 %128 to i32
%130 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %129)
ret void
}