void printf(char *fmt, ...) {
  char buff[2] = {0, 0};
  __builtin_va_list va;
  char ch;
  __builtin_va_start(va, fmt);
  while ((ch = *(fmt++))) {
    if (ch == '%' && fmt[0] != 0) {
      switch (fmt[0]) {
      case 'u':
        print_u64(__builtin_va_arg(va, unsigned long int));
        break;
      case 's':
        puts(__builtin_va_arg(va, char *));
        break;
      default:
        break;
      }
      fmt++;
    } else {
      buff[0] = ch;
      puts(buff);
    }
  }
  __builtin_va_end(va);
}


x86 assembly (clang, -O0):
<printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
test   %al,%al
je     116f <printf+0x3f>
movaps %xmm0,-0xc0(%rbp)
movaps %xmm1,-0xb0(%rbp)
movaps %xmm2,-0xa0(%rbp)
movaps %xmm3,-0x90(%rbp)
movaps %xmm4,-0x80(%rbp)
movaps %xmm5,-0x70(%rbp)
movaps %xmm6,-0x60(%rbp)
movaps %xmm7,-0x50(%rbp)
mov    %r9,-0xc8(%rbp)
mov    %r8,-0xd0(%rbp)
mov    %rcx,-0xd8(%rbp)
mov    %rdx,-0xe0(%rbp)
mov    %rsi,-0xe8(%rbp)
mov    %rdi,-0x8(%rbp)
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rax
lea    -0xf0(%rbp),%rcx
mov    %rcx,0x10(%rax)
lea    0x10(%rbp),%rcx
mov    %rcx,0x8(%rax)
movl   $0x30,0x4(%rax)
movl   $0x8,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x31(%rbp)
cmp    $0x0,%al
je     1348 <printf+0x218>
movsbl -0x31(%rbp),%eax
cmp    $0x25,%eax
jne    1332 <printf+0x202>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1332 <printf+0x202>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xf4(%rbp)
sub    $0x73,%eax
je     12a7 <printf+0x177>
jmp    121e <printf+0xee>
mov    -0xf4(%rbp),%eax
sub    $0x75,%eax
jne    131c <printf+0x1ec>
jmp    1232 <printf+0x102>
lea    -0x30(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0xf8(%rbp)
cmp    $0x28,%eax
ja     1274 <printf+0x144>
mov    -0x100(%rbp),%rcx
mov    -0xf8(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0x108(%rbp)
jmp    1291 <printf+0x161>
mov    -0x100(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1040 <print_u64@plt>
jmp    1321 <printf+0x1f1>
lea    -0x30(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x10c(%rbp)
cmp    $0x28,%eax
ja     12e9 <printf+0x1b9>
mov    -0x118(%rbp),%rcx
mov    -0x10c(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0x120(%rbp)
jmp    1306 <printf+0x1d6>
mov    -0x118(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1030 <puts@plt>
jmp    1321 <printf+0x1f1>
jmp    1321 <printf+0x1f1>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1343 <printf+0x213>
mov    -0x31(%rbp),%al
mov    %al,-0xa(%rbp)
lea    -0xa(%rbp),%rdi
mov    $0x0,%al
call   1030 <puts@plt>
jmp    11ca <printf+0x9a>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,%r15
mov    %rsi,0x38(%rsp)
mov    %rdx,0x40(%rsp)
mov    %rcx,0x48(%rsp)
mov    %r8,0x50(%rsp)
mov    %r9,0x58(%rsp)
test   %al,%al
je     1186 <printf+0x66>
movaps %xmm0,0x60(%rsp)
movaps %xmm1,0x70(%rsp)
movaps %xmm2,0x80(%rsp)
movaps %xmm3,0x90(%rsp)
movaps %xmm4,0xa0(%rsp)
movaps %xmm5,0xb0(%rsp)
movaps %xmm6,0xc0(%rsp)
movaps %xmm7,0xd0(%rsp)
movw   $0x0,0xe(%rsp)
lea    0x30(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x100(%rsp),%rax
mov    %rax,0x18(%rsp)
movabs $0x3000000008,%rax
mov    %rax,0x10(%rsp)
lea    0xe(%rsp),%r14
jmp    11d9 <printf+0xb9>
nopw   0x0(%rax,%rax,1)
test   %al,%al
je     126b <printf+0x14b>
mov    %al,0xe(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <puts@plt>
mov    %rbx,%r15
lea    0x1(%r15),%rbx
movzbl (%r15),%eax
cmp    $0x25,%al
jne    11c0 <printf+0xa0>
movsbl (%rbx),%ecx
test   %ecx,%ecx
je     11c8 <printf+0xa8>
cmp    $0x73,%ecx
je     1211 <printf+0xf1>
cmp    $0x75,%ecx
jne    1262 <printf+0x142>
mov    0x10(%rsp),%ecx
cmp    $0x28,%rcx
ja     122c <printf+0x10c>
mov    %rcx,%rax
add    0x20(%rsp),%rax
add    $0x8,%ecx
mov    %ecx,0x10(%rsp)
jmp    123a <printf+0x11a>
mov    0x10(%rsp),%ecx
cmp    $0x28,%rcx
ja     124a <printf+0x12a>
mov    %rcx,%rax
add    0x20(%rsp),%rax
add    $0x8,%ecx
mov    %ecx,0x10(%rsp)
jmp    1258 <printf+0x138>
mov    0x18(%rsp),%rax
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rsp)
mov    (%rax),%rdi
xor    %eax,%eax
call   1040 <print_u64@plt>
add    $0x2,%r15
jmp    11d9 <printf+0xb9>
mov    0x18(%rsp),%rax
lea    0x8(%rax),%rcx
mov    %rcx,0x18(%rsp)
mov    (%rax),%rdi
xor    %eax,%eax
call   1030 <puts@plt>
add    $0x2,%r15
jmp    11d9 <printf+0xb9>
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define void @printf(i8* %0, ...) {
%2 = alloca i8*
%3 = alloca [2 x i8]
%4 = alloca [1 x %struct.__va_list_tag]
%5 = alloca i8
store i8* %0, i8** %2
%6 = bitcast [2 x i8]* %3 to i8*
%7 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%8 = bitcast %struct.__va_list_tag* %7 to i8*
br label %9
9: ; preds = %78, %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %2
%12 = load i8, i8* %10
store i8 %12, i8* %5
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %79
14: ; preds = %9
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 37
br i1 %17, label %18, label %73
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %73
24: ; preds = %18
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
switch i32 %28, label %69 [
i32 117, label %29
i32 115, label %49
]
29: ; preds = %24
%30 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%31 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = icmp ule i32 %32, 40
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %30, i32 0, i32 3
%36 = load i8*, i8** %35
%37 = getelementptr i8, i8* %36, i32 %32
%38 = bitcast i8* %37 to i64*
%39 = add i32 %32, 8
store i32 %39, i32* %31
br label %45
40: ; preds = %29
%41 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %30, i32 0, i32 2
%42 = load i8*, i8** %41
%43 = bitcast i8* %42 to i64*
%44 = getelementptr i8, i8* %42, i32 8
store i8* %44, i8** %41
br label %45
45: ; preds = %40, %34
%46 = phi i64* [ %38, %34 ], [ %43, %40 ]
%47 = load i64, i64* %46
%48 = call i32 (i64, ...) bitcast (i32 (...)* @print_u64 to i32 (i64, ...)*)(i64 %47)
br label %70
49: ; preds = %24
%50 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%51 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %50, i32 0, i32 0
%52 = load i32, i32* %51
%53 = icmp ule i32 %52, 40
br i1 %53, label %54, label %60
54: ; preds = %49
%55 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %50, i32 0, i32 3
%56 = load i8*, i8** %55
%57 = getelementptr i8, i8* %56, i32 %52
%58 = bitcast i8* %57 to i8**
%59 = add i32 %52, 8
store i32 %59, i32* %51
br label %65
60: ; preds = %49
%61 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %50, i32 0, i32 2
%62 = load i8*, i8** %61
%63 = bitcast i8* %62 to i8**
%64 = getelementptr i8, i8* %62, i32 8
store i8* %64, i8** %61
br label %65
65: ; preds = %60, %54
%66 = phi i8** [ %58, %54 ], [ %63, %60 ]
%67 = load i8*, i8** %66
%68 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %67)
br label %70
69: ; preds = %24
br label %70
70: ; preds = %69, %65, %45
%71 = load i8*, i8** %2
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %2
br label %78
73: ; preds = %18, %14
%74 = load i8, i8* %5
%75 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
store i8 %74, i8* %75
%76 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%77 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %76)
br label %78
78: ; preds = %73, %70
br label %9
79: ; preds = %9
%80 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%81 = bitcast %struct.__va_list_tag* %80 to i8*
ret void
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define void @printf(i8* nocapture %0, ...) {
%2 = alloca i16
%3 = alloca [1 x %struct.__va_list_tag]
%4 = bitcast i16* %2 to i8*
store i16 0, i16* %2
%5 = bitcast [1 x %struct.__va_list_tag]* %3 to i8*
%6 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0, i32 0
%7 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0, i32 2
%8 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0, i32 3
br label %9
9: ; preds = %54, %1
%10 = phi i8* [ %0, %1 ], [ %55, %54 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %10
switch i8 %12, label %52 [
i8 0, label %56
i8 37, label %13
]
13: ; preds = %9
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %52, label %16
16: ; preds = %13
%17 = sext i8 %14 to i32
switch i32 %17, label %50 [
i32 117, label %18
i32 115, label %34
]
18: ; preds = %16
%19 = load i32, i32* %6
%20 = icmp ult i32 %19, 41
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8*, i8** %8
%23 = zext i32 %19 to i64
%24 = getelementptr i8, i8* %22, i64 %23
%25 = add nuw nsw i32 %19, 8
store i32 %25, i32* %6
br label %29
26: ; preds = %18
%27 = load i8*, i8** %7
%28 = getelementptr i8, i8* %27, i64 8
store i8* %28, i8** %7
br label %29
29: ; preds = %26, %21
%30 = phi i8* [ %24, %21 ], [ %27, %26 ]
%31 = bitcast i8* %30 to i64*
%32 = load i64, i64* %31
%33 = call i32 (i64, ...) bitcast (i32 (...)* @print_u64 to i32 (i64, ...)*)(i64 %32)
br label %50
34: ; preds = %16
%35 = load i32, i32* %6
%36 = icmp ult i32 %35, 41
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i8*, i8** %8
%39 = zext i32 %35 to i64
%40 = getelementptr i8, i8* %38, i64 %39
%41 = add nuw nsw i32 %35, 8
store i32 %41, i32* %6
br label %45
42: ; preds = %34
%43 = load i8*, i8** %7
%44 = getelementptr i8, i8* %43, i64 8
store i8* %44, i8** %7
br label %45
45: ; preds = %42, %37
%46 = phi i8* [ %40, %37 ], [ %43, %42 ]
%47 = bitcast i8* %46 to i8**
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %48)
br label %50
50: ; preds = %16, %45, %29
%51 = getelementptr inbounds i8, i8* %10, i64 2
br label %54
52: ; preds = %9, %13
store i8 %12, i8* %4
%53 = call i32 (i8*, ...) bitcast (i32 (...)* @puts to i32 (i8*, ...)*)(i8* %4)
br label %54
54: ; preds = %52, %50
%55 = phi i8* [ %51, %50 ], [ %11, %52 ]
br label %9
56: ; preds = %9
ret void
}