#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*/ _sys_printk(char *);
int /*<<< orphan*/ _sys_put_signed_Int(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ _sys_put_unsigned_Int(unsigned int, int, int);
int /*<<< orphan*/ _sys_putchar(char const);
void _sys_printf(const char *format, ...) {
  register int i;
  void **list = (void **)&format;
  list++;
  for (i = 0; format[i] != '\0'; i++) {
    if (format[i] == '%') {
      i++;
      switch (format[i]) {
      case 'd':
        _sys_put_signed_Int((int)*(int *)list, 10, 0);
        list++;
        break;
      case 'x':
        _sys_printk("0x");
        _sys_put_unsigned_Int((unsigned)*(int *)list, 16, 0);
        list++;
        break;
      case 'X':
        _sys_printk("0x");
        _sys_put_unsigned_Int((unsigned)*(int *)list, 16, 1);
        list++;
        break;
      case 'o':
        _sys_put_signed_Int(*(int *)list, 8, 0);
        list++;
        break;
      case 'c':
        _sys_putchar((char)*(int *)(list));
        list++;
        break;
      case 's':
        _sys_printk((char *)*(int *)(list));
        list++;
        break;
      case 'u':
        _sys_put_unsigned_Int((unsigned int)*(int *)list, 10, 0);
        list++;
        break;
      case '%':
        _sys_putchar('%');
        break;
      }
    } else {
      _sys_putchar(format[i]);
    }
  }
}


x86 assembly (clang, -O0):
<_sys_printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1367 <_sys_printf+0x227>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
jne    1343 <_sys_printf+0x203>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x25,%eax
je     1334 <_sys_printf+0x1f4>
jmp    11b7 <_sys_printf+0x77>
mov    -0x1c(%rbp),%eax
sub    $0x58,%eax
je     1280 <_sys_printf+0x140>
jmp    11c8 <_sys_printf+0x88>
mov    -0x1c(%rbp),%eax
sub    $0x63,%eax
je     12d5 <_sys_printf+0x195>
jmp    11d9 <_sys_printf+0x99>
mov    -0x1c(%rbp),%eax
sub    $0x64,%eax
je     122e <_sys_printf+0xee>
jmp    11ea <_sys_printf+0xaa>
mov    -0x1c(%rbp),%eax
sub    $0x6f,%eax
je     12b2 <_sys_printf+0x172>
jmp    11fb <_sys_printf+0xbb>
mov    -0x1c(%rbp),%eax
sub    $0x73,%eax
je     12f4 <_sys_printf+0x1b4>
jmp    120c <_sys_printf+0xcc>
mov    -0x1c(%rbp),%eax
sub    $0x75,%eax
je     1311 <_sys_printf+0x1d1>
jmp    121d <_sys_printf+0xdd>
mov    -0x1c(%rbp),%eax
sub    $0x78,%eax
je     1251 <_sys_printf+0x111>
jmp    133e <_sys_printf+0x1fe>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1050 <_sys_put_signed_Int@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
lea    0xda8(%rip),%rdi
call   1030 <_sys_printk@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1040 <_sys_put_unsigned_Int@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
lea    0xd79(%rip),%rdi
call   1030 <_sys_printk@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x10,%esi
mov    $0x1,%edx
call   1040 <_sys_put_unsigned_Int@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1050 <_sys_put_signed_Int@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
movsbl %al,%edi
call   1060 <_sys_putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
mov    -0x18(%rbp),%rax
movslq (%rax),%rdi
call   1030 <_sys_printk@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1040 <_sys_put_unsigned_Int@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    133e <_sys_printf+0x1fe>
mov    $0x25,%edi
call   1060 <_sys_putchar@plt>
jmp    1354 <_sys_printf+0x214>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <_sys_putchar@plt>
jmp    1359 <_sys_printf+0x219>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <_sys_printf+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sys_printf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rdi,0x8(%rsp)
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
lea    0xe9e(%rip),%r12
lea    0xf1b(%rip),%r14
jmp    1181 <_sys_printf+0x41>
mov    (%r15),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1040 <_sys_put_unsigned_Int@plt>
add    $0x8,%r15
add    $0x1,%ebp
movslq %ebp,%rcx
movzbl (%rbx,%rcx,1),%eax
cmp    $0x25,%al
je     11b0 <_sys_printf+0x70>
test   %al,%al
je     1245 <_sys_printf+0x105>
movsbl %al,%edi
call   1060 <_sys_putchar@plt>
add    $0x1,%ebp
jmp    1181 <_sys_printf+0x41>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx,%rcx,1),%eax
add    $0x1,%rcx
mov    %ecx,%ebp
lea    -0x58(%rax),%ecx
cmp    $0x20,%ecx
ja     11e3 <_sys_printf+0xa3>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %r14,%rdi
call   1030 <_sys_printk@plt>
mov    (%r15),%edi
mov    $0x10,%esi
mov    $0x1,%edx
jmp    1175 <_sys_printf+0x35>
cmp    $0x25,%eax
jne    117e <_sys_printf+0x3e>
mov    $0x25,%edi
call   1060 <_sys_putchar@plt>
add    $0x1,%ebp
jmp    1181 <_sys_printf+0x41>
movsbl (%r15),%edi
call   1060 <_sys_putchar@plt>
jmp    117a <_sys_printf+0x3a>
mov    (%r15),%edi
mov    $0xa,%esi
jmp    1217 <_sys_printf+0xd7>
mov    (%r15),%edi
mov    $0x8,%esi
xor    %edx,%edx
call   1050 <_sys_put_signed_Int@plt>
jmp    117a <_sys_printf+0x3a>
movslq (%r15),%rdi
call   1030 <_sys_printk@plt>
jmp    117a <_sys_printf+0x3a>
mov    %r14,%rdi
call   1030 <_sys_printk@plt>
mov    (%r15),%edi
mov    $0x10,%esi
jmp    1173 <_sys_printf+0x33>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
define void @_sys_printf(i8* %0, ...) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8**
store i8* %0, i8** %2
store i8** %2, i8*** %4
%5 = load i8**, i8*** %4
%6 = getelementptr inbounds i8*, i8** %5, i32 1
store i8** %6, i8*** %4
store i32 0, i32* %3
br label %7
7: ; preds = %97, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %100
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 37
br i1 %22, label %23, label %89
23: ; preds = %15
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %88 [
i32 100, label %32
i32 120, label %39
i32 88, label %47
i32 111, label %55
i32 99, label %62
i32 115, label %70
i32 117, label %79
i32 37, label %86
]
32: ; preds = %23
%33 = load i8**, i8*** %4
%34 = bitcast i8** %33 to i32*
%35 = load i32, i32* %34
%36 = call i32 @_sys_put_signed_Int(i32 %35, i32 10, i32 0)
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i32 1
store i8** %38, i8*** %4
br label %88
39: ; preds = %23
%40 = call i32 @_sys_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%41 = load i8**, i8*** %4
%42 = bitcast i8** %41 to i32*
%43 = load i32, i32* %42
%44 = call i32 @_sys_put_unsigned_Int(i32 %43, i32 16, i32 0)
%45 = load i8**, i8*** %4
%46 = getelementptr inbounds i8*, i8** %45, i32 1
store i8** %46, i8*** %4
br label %88
47: ; preds = %23
%48 = call i32 @_sys_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%49 = load i8**, i8*** %4
%50 = bitcast i8** %49 to i32*
%51 = load i32, i32* %50
%52 = call i32 @_sys_put_unsigned_Int(i32 %51, i32 16, i32 1)
%53 = load i8**, i8*** %4
%54 = getelementptr inbounds i8*, i8** %53, i32 1
store i8** %54, i8*** %4
br label %88
55: ; preds = %23
%56 = load i8**, i8*** %4
%57 = bitcast i8** %56 to i32*
%58 = load i32, i32* %57
%59 = call i32 @_sys_put_signed_Int(i32 %58, i32 8, i32 0)
%60 = load i8**, i8*** %4
%61 = getelementptr inbounds i8*, i8** %60, i32 1
store i8** %61, i8*** %4
br label %88
62: ; preds = %23
%63 = load i8**, i8*** %4
%64 = bitcast i8** %63 to i32*
%65 = load i32, i32* %64
%66 = trunc i32 %65 to i8
%67 = call i32 @_sys_putchar(i8 signext %66)
%68 = load i8**, i8*** %4
%69 = getelementptr inbounds i8*, i8** %68, i32 1
store i8** %69, i8*** %4
br label %88
70: ; preds = %23
%71 = load i8**, i8*** %4
%72 = bitcast i8** %71 to i32*
%73 = load i32, i32* %72
%74 = sext i32 %73 to i64
%75 = inttoptr i64 %74 to i8*
%76 = call i32 @_sys_printk(i8* %75)
%77 = load i8**, i8*** %4
%78 = getelementptr inbounds i8*, i8** %77, i32 1
store i8** %78, i8*** %4
br label %88
79: ; preds = %23
%80 = load i8**, i8*** %4
%81 = bitcast i8** %80 to i32*
%82 = load i32, i32* %81
%83 = call i32 @_sys_put_unsigned_Int(i32 %82, i32 10, i32 0)
%84 = load i8**, i8*** %4
%85 = getelementptr inbounds i8*, i8** %84, i32 1
store i8** %85, i8*** %4
br label %88
86: ; preds = %23
%87 = call i32 @_sys_putchar(i8 signext 37)
br label %88
88: ; preds = %23, %86, %79, %70, %62, %55, %47, %39, %32
br label %96
89: ; preds = %15
%90 = load i8*, i8** %2
%91 = load i32, i32* %3
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = call i32 @_sys_putchar(i8 signext %94)
br label %96
96: ; preds = %89, %88
br label %97
97: ; preds = %96
%98 = load i32, i32* %3
%99 = add nsw i32 %98, 1
store i32 %99, i32* %3
br label %7
100: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
define void @_sys_printf(i8* %0, ...) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = getelementptr inbounds i8*, i8** %2, i64 1
br label %4
4: ; preds = %60, %1
%5 = phi i32 [ 0, %1 ], [ %63, %60 ]
%6 = phi i8** [ %3, %1 ], [ %62, %60 ]
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %58 [
i8 0, label %64
i8 37, label %10
]
10: ; preds = %4
%11 = add nsw i32 %5, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %60 [
i32 100, label %16
i32 120, label %21
i32 88, label %27
i32 111, label %33
i32 99, label %38
i32 115, label %44
i32 117, label %51
i32 37, label %56
]
16: ; preds = %10
%17 = bitcast i8** %6 to i32*
%18 = load i32, i32* %17
%19 = tail call i32 @_sys_put_signed_Int(i32 %18, i32 10, i32 0)
%20 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
21: ; preds = %10
%22 = tail call i32 @_sys_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = bitcast i8** %6 to i32*
%24 = load i32, i32* %23
%25 = tail call i32 @_sys_put_unsigned_Int(i32 %24, i32 16, i32 0)
%26 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
27: ; preds = %10
%28 = tail call i32 @_sys_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%29 = bitcast i8** %6 to i32*
%30 = load i32, i32* %29
%31 = tail call i32 @_sys_put_unsigned_Int(i32 %30, i32 16, i32 1)
%32 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
33: ; preds = %10
%34 = bitcast i8** %6 to i32*
%35 = load i32, i32* %34
%36 = tail call i32 @_sys_put_signed_Int(i32 %35, i32 8, i32 0)
%37 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
38: ; preds = %10
%39 = bitcast i8** %6 to i32*
%40 = load i32, i32* %39
%41 = trunc i32 %40 to i8
%42 = tail call i32 @_sys_putchar(i8 signext %41)
%43 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
44: ; preds = %10
%45 = bitcast i8** %6 to i32*
%46 = load i32, i32* %45
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i8*
%49 = tail call i32 @_sys_printk(i8* %48)
%50 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
51: ; preds = %10
%52 = bitcast i8** %6 to i32*
%53 = load i32, i32* %52
%54 = tail call i32 @_sys_put_unsigned_Int(i32 %53, i32 10, i32 0)
%55 = getelementptr inbounds i8*, i8** %6, i64 1
br label %60
56: ; preds = %10
%57 = tail call i32 @_sys_putchar(i8 signext 37)
br label %60
58: ; preds = %4
%59 = tail call i32 @_sys_putchar(i8 signext %9)
br label %60
60: ; preds = %58, %10, %56, %51, %44, %38, %33, %27, %21, %16
%61 = phi i32 [ %11, %10 ], [ %11, %56 ], [ %11, %51 ], [ %11, %44 ], [ %11, %38 ], [ %11, %33 ], [ %11, %27 ], [ %11, %21 ], [ %11, %16 ], [ %5, %58 ]
%62 = phi i8** [ %6, %10 ], [ %6, %56 ], [ %55, %51 ], [ %50, %44 ], [ %43, %38 ], [ %37, %33 ], [ %32, %27 ], [ %26, %21 ], [ %20, %16 ], [ %6, %58 ]
%63 = add nsw i32 %61, 1
br label %4
64: ; preds = %4
ret void
}