#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*/ assert(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int skiboot_snprintf(char *, int, int, char *, ...);
scalar_t__ strncmp(char *, char *, int);
int test1();
int /*<<< orphan*/ test_printf_0u(int);
int /*<<< orphan*/ test_printf_c();
int /*<<< orphan*/ test_printf_d(int);
int /*<<< orphan*/ test_printf_h(int);
int /*<<< orphan*/ test_printf_o();
int /*<<< orphan*/ test_printf_p();
int /*<<< orphan*/ test_printf_u(int);
int /*<<< orphan*/ test_printf_x(char *);
int /*<<< orphan*/ test_printf_z(int);
int main(void) {
  char *buf;
  int r;
  buf = (char *)malloc(50);
  memset(buf, 0, 50);
  assert(-1 == test1());
  r = skiboot_snprintf(buf, 50, 2, "%%");
  assert(r == 1);
  assert(buf[0] == '%' && buf[1] == 0);
  r = skiboot_snprintf(buf, 50, 2, "%d", 137);
  assert(0 == r);
  assert(0 == strncmp(buf, "", 3));
  r = skiboot_snprintf(buf, 50, 4, "%d", 137);
  assert(3 == r);
  assert(0 == strncmp(buf, "137", 3));
  assert(buf[3] == 0);
  r = skiboot_snprintf(buf, 50, 4, "Hello %d", 137);
  assert(3 == r);
  assert(0 == strncmp(buf, "Hel", 3));
  assert(buf[3] == 0);
  r = skiboot_snprintf(buf, 50, 7, "Hello %d", 137);
  assert(6 == r);
  assert(0 == strncmp(buf, "Hello ", 6));
  assert(buf[6] == 0);
  r = skiboot_snprintf(buf, 50, 10, "Hello %d", 137);
  assert(9 == r);
  assert(0 == strncmp(buf, "Hello 137", 10));
  assert(buf[9] == 0);
  free(buf);
  test_printf_u(1);
  test_printf_0u(1);
  test_printf_d(1);
  test_printf_d(-1);
  test_printf_x("%x");
  test_printf_x("%X");
  test_printf_c();
  test_printf_p();
  test_printf_o();
  test_printf_h(0);
  test_printf_h(128);
  test_printf_h(256);
  test_printf_h(-1);
  test_printf_h(32767);
  test_printf_h(32768);
  test_printf_h(65535);
  test_printf_z(0);
  test_printf_z(-1);
  test_printf_z(12345);
  test_printf_z(128000000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x32,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1090 <memset@plt>
mov    $0x0,%al
call   1070 <test1@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0x2,%edx
lea    0xda1(%rip),%rcx
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x25,%ecx
mov    %al,-0x15(%rbp)
jne    12a0 <main+0xa0>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0x2,%edx
lea    0xd47(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xd27(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0x4,%edx
lea    0xce6(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
mov    $0x3,%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xcca(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0x4,%edx
lea    0xc64(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
mov    $0x3,%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xc3d(%rip),%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0x7,%edx
lea    0xbe8(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
mov    $0x6,%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xbc5(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
mov    $0xa,%edx
lea    0xb6c(%rip),%rcx
mov    $0x89,%r8d
mov    $0x0,%al
call   1040 <skiboot_snprintf@plt>
mov    %eax,-0x14(%rbp)
mov    $0x9,%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xb50(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1080 <test_printf_u@plt>
mov    $0x1,%edi
call   1060 <test_printf_0u@plt>
mov    $0x1,%edi
call   1120 <test_printf_d@plt>
mov    $0xffffffff,%edi
call   1120 <test_printf_d@plt>
lea    0xaeb(%rip),%rdi
call   10e0 <test_printf_x@plt>
lea    0xae2(%rip),%rdi
call   10e0 <test_printf_x@plt>
mov    $0x0,%al
call   10b0 <test_printf_c@plt>
mov    $0x0,%al
call   1110 <test_printf_p@plt>
mov    $0x0,%al
call   10a0 <test_printf_o@plt>
xor    %edi,%edi
call   1100 <test_printf_h@plt>
mov    $0x80,%edi
call   1100 <test_printf_h@plt>
mov    $0x100,%edi
call   1100 <test_printf_h@plt>
mov    $0xffffffff,%edi
call   1100 <test_printf_h@plt>
mov    $0x7fff,%edi
call   1100 <test_printf_h@plt>
mov    $0x8000,%edi
call   1100 <test_printf_h@plt>
mov    $0xffff,%edi
call   1100 <test_printf_h@plt>
xor    %edi,%edi
call   10f0 <test_printf_z@plt>
mov    $0xffffffff,%edi
call   10f0 <test_printf_z@plt>
mov    $0x3039,%edi
call   10f0 <test_printf_z@plt>
mov    $0x7a12000,%edi
call   10f0 <test_printf_z@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x32,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1090 <memset@plt>
xor    %eax,%eax
call   1070 <test1@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xdc2(%rip),%rcx
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   10c0 <assert@plt>
cmpb   $0x25,(%rbx)
jne    126f <main+0x6f>
xor    %ebp,%ebp
cmpb   $0x0,0x1(%rbx)
sete   %bpl
mov    %ebp,%edi
call   10c0 <assert@plt>
lea    0xd8c(%rip),%rbp
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x2,%edx
mov    %rbp,%rcx
mov    $0x89,%r8d
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xd68(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x4,%edx
mov    %rbp,%rcx
mov    $0x89,%r8d
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xd22(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x3(%rbx)
sete   %dil
call   10c0 <assert@plt>
lea    0xcd7(%rip),%r14
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x4,%edx
mov    %r14,%rcx
mov    $0x89,%r8d
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xcae(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x3(%rbx)
sete   %dil
call   10c0 <assert@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0x7,%edx
mov    %r14,%rcx
mov    $0x89,%r8d
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xc56(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x6(%rbx)
sete   %dil
call   10c0 <assert@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
mov    $0xa,%edx
mov    %r14,%rcx
mov    $0x89,%r8d
xor    %eax,%eax
call   1040 <skiboot_snprintf@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
call   10c0 <assert@plt>
lea    0xc01(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1050 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   10c0 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x9(%rbx)
sete   %dil
call   10c0 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1080 <test_printf_u@plt>
mov    $0x1,%edi
call   1060 <test_printf_0u@plt>
mov    $0x1,%edi
call   1120 <test_printf_d@plt>
mov    $0xffffffff,%edi
call   1120 <test_printf_d@plt>
lea    0xbaa(%rip),%rdi
call   10e0 <test_printf_x@plt>
lea    0xba1(%rip),%rdi
call   10e0 <test_printf_x@plt>
xor    %eax,%eax
call   10b0 <test_printf_c@plt>
xor    %eax,%eax
call   1110 <test_printf_p@plt>
xor    %eax,%eax
call   10a0 <test_printf_o@plt>
xor    %edi,%edi
call   1100 <test_printf_h@plt>
mov    $0x80,%edi
call   1100 <test_printf_h@plt>
mov    $0x100,%edi
call   1100 <test_printf_h@plt>
mov    $0xffffffff,%edi
call   1100 <test_printf_h@plt>
mov    $0x7fff,%edi
call   1100 <test_printf_h@plt>
mov    $0x8000,%edi
call   1100 <test_printf_h@plt>
mov    $0xffff,%edi
call   1100 <test_printf_h@plt>
xor    %edi,%edi
call   10f0 <test_printf_z@plt>
mov    $0xffffffff,%edi
call   10f0 <test_printf_z@plt>
mov    $0x3039,%edi
call   10f0 <test_printf_z@plt>
mov    $0x7a12000,%edi
call   10f0 <test_printf_z@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%%\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"137\00"
@.str.4 = [9 x i8] c"Hello %d\00"
@.str.5 = [4 x i8] c"Hel\00"
@.str.6 = [7 x i8] c"Hello \00"
@.str.7 = [10 x i8] c"Hello 137\00"
@.str.8 = [3 x i8] c"%x\00"
@.str.9 = [3 x i8] c"%X\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @malloc(i32 50)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @memset(i8* %6, i32 0, i32 50)
%8 = call i32 (...) @test1()
%9 = icmp eq i32 -1, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %2
%13 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %12, i32 50, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 37
br i1 %22, label %23, label %29
23: ; preds = %0
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br label %29
29: ; preds = %23, %0
%30 = phi i1 [ false, %0 ], [ %28, %23 ]
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i8*, i8** %2
%34 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %33, i32 50, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 137)
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = icmp eq i32 0, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i8*, i8** %2
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 3)
%41 = icmp eq i64 0, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = load i8*, i8** %2
%45 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %44, i32 50, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 137)
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = icmp eq i32 3, %46
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i8*, i8** %2
%51 = call i64 @strncmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%52 = icmp eq i64 0, %51
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i8*, i8** %2
%56 = getelementptr inbounds i8, i8* %55, i64 3
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 0
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = load i8*, i8** %2
%63 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %62, i32 50, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
store i32 %63, i32* %3
%64 = load i32, i32* %3
%65 = icmp eq i32 3, %64
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load i8*, i8** %2
%69 = call i64 @strncmp(i8* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%70 = icmp eq i64 0, %69
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = load i8*, i8** %2
%74 = getelementptr inbounds i8, i8* %73, i64 3
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = load i8*, i8** %2
%81 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %80, i32 50, i32 7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
store i32 %81, i32* %3
%82 = load i32, i32* %3
%83 = icmp eq i32 6, %82
%84 = zext i1 %83 to i32
%85 = call i32 @assert(i32 %84)
%86 = load i8*, i8** %2
%87 = call i64 @strncmp(i8* %86, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%88 = icmp eq i64 0, %87
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
%91 = load i8*, i8** %2
%92 = getelementptr inbounds i8, i8* %91, i64 6
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 0
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
%98 = load i8*, i8** %2
%99 = call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %98, i32 50, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
store i32 %99, i32* %3
%100 = load i32, i32* %3
%101 = icmp eq i32 9, %100
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
%104 = load i8*, i8** %2
%105 = call i64 @strncmp(i8* %104, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 10)
%106 = icmp eq i64 0, %105
%107 = zext i1 %106 to i32
%108 = call i32 @assert(i32 %107)
%109 = load i8*, i8** %2
%110 = getelementptr inbounds i8, i8* %109, i64 9
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 0
%114 = zext i1 %113 to i32
%115 = call i32 @assert(i32 %114)
%116 = load i8*, i8** %2
%117 = call i32 @free(i8* %116)
%118 = call i32 @test_printf_u(i32 1)
%119 = call i32 @test_printf_0u(i32 1)
%120 = call i32 @test_printf_d(i32 1)
%121 = call i32 @test_printf_d(i32 -1)
%122 = call i32 @test_printf_x(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%123 = call i32 @test_printf_x(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%124 = call i32 (...) @test_printf_c()
%125 = call i32 (...) @test_printf_p()
%126 = call i32 (...) @test_printf_o()
%127 = call i32 @test_printf_h(i32 0)
%128 = call i32 @test_printf_h(i32 128)
%129 = call i32 @test_printf_h(i32 256)
%130 = call i32 @test_printf_h(i32 -1)
%131 = call i32 @test_printf_h(i32 32767)
%132 = call i32 @test_printf_h(i32 32768)
%133 = call i32 @test_printf_h(i32 65535)
%134 = call i32 @test_printf_z(i32 0)
%135 = call i32 @test_printf_z(i32 -1)
%136 = call i32 @test_printf_z(i32 12345)
%137 = call i32 @test_printf_z(i32 128000000)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%%\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"137\00"
@.str.4 = [9 x i8] c"Hello %d\00"
@.str.5 = [4 x i8] c"Hel\00"
@.str.6 = [7 x i8] c"Hello \00"
@.str.7 = [10 x i8] c"Hello 137\00"
@.str.8 = [3 x i8] c"%x\00"
@.str.9 = [3 x i8] c"%X\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 50)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @memset(i8* %2, i32 0, i32 50)
%4 = tail call i32 (...) @test1()
%5 = icmp eq i32 %4, -1
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 37
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = getelementptr inbounds i8, i8* %2, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %0
%20 = phi i32 [ 0, %0 ], [ %18, %14 ]
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 137)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i32 3)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 137)
%31 = icmp eq i32 %30, 3
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i32
%37 = tail call i32 @assert(i32 %36)
%38 = getelementptr inbounds i8, i8* %2, i64 3
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
%44 = icmp eq i32 %43, 3
%45 = zext i1 %44 to i32
%46 = tail call i32 @assert(i32 %45)
%47 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%48 = icmp eq i64 %47, 0
%49 = zext i1 %48 to i32
%50 = tail call i32 @assert(i32 %49)
%51 = load i8, i8* %38
%52 = icmp eq i8 %51, 0
%53 = zext i1 %52 to i32
%54 = tail call i32 @assert(i32 %53)
%55 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
%56 = icmp eq i32 %55, 6
%57 = zext i1 %56 to i32
%58 = tail call i32 @assert(i32 %57)
%59 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%60 = icmp eq i64 %59, 0
%61 = zext i1 %60 to i32
%62 = tail call i32 @assert(i32 %61)
%63 = getelementptr inbounds i8, i8* %2, i64 6
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 0
%66 = zext i1 %65 to i32
%67 = tail call i32 @assert(i32 %66)
%68 = tail call i32 (i8*, i32, i32, i8*, ...) @skiboot_snprintf(i8* %2, i32 50, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 137)
%69 = icmp eq i32 %68, 9
%70 = zext i1 %69 to i32
%71 = tail call i32 @assert(i32 %70)
%72 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 10)
%73 = icmp eq i64 %72, 0
%74 = zext i1 %73 to i32
%75 = tail call i32 @assert(i32 %74)
%76 = getelementptr inbounds i8, i8* %2, i64 9
%77 = load i8, i8* %76
%78 = icmp eq i8 %77, 0
%79 = zext i1 %78 to i32
%80 = tail call i32 @assert(i32 %79)
%81 = tail call i32 @free(i8* %2)
%82 = tail call i32 @test_printf_u(i32 1)
%83 = tail call i32 @test_printf_0u(i32 1)
%84 = tail call i32 @test_printf_d(i32 1)
%85 = tail call i32 @test_printf_d(i32 -1)
%86 = tail call i32 @test_printf_x(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%87 = tail call i32 @test_printf_x(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%88 = tail call i32 (...) @test_printf_c()
%89 = tail call i32 (...) @test_printf_p()
%90 = tail call i32 (...) @test_printf_o()
%91 = tail call i32 @test_printf_h(i32 0)
%92 = tail call i32 @test_printf_h(i32 128)
%93 = tail call i32 @test_printf_h(i32 256)
%94 = tail call i32 @test_printf_h(i32 -1)
%95 = tail call i32 @test_printf_h(i32 32767)
%96 = tail call i32 @test_printf_h(i32 32768)
%97 = tail call i32 @test_printf_h(i32 65535)
%98 = tail call i32 @test_printf_z(i32 0)
%99 = tail call i32 @test_printf_z(i32 -1)
%100 = tail call i32 @test_printf_z(i32 12345)
%101 = tail call i32 @test_printf_z(i32 128000000)
ret i32 0
}