#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint8_t;
typedef int uint64_t;
typedef int uint32_t;
typedef int uint16_t;
typedef int int8_t;
typedef int int64_t;
typedef int int32_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void _print_date(const void *data, size_t offset, char *format, uint8_t length,
                 uint16_t flags) {
  switch (length) {
  case 1:
    if (flags & (0x2000)) {
      switch (((signed char *)data)[offset]) {
      case '\0':
        printf("   \\0");
        return;
      case '\a':
        printf("   \\a");
        return;
      case '\b':
        printf("   \\b");
        return;
      case '\f':
        printf("   \\f");
        return;
      case '\n':
        printf("   \\n");
        return;
      case '\r':
        printf("   \\r");
        return;
      case '\t':
        printf("   \\t");
        return;
      case '\v':
        printf("   \\v");
        return;
      default:
        if (((signed char *)data)[offset] < 0) {
          printf("  %03o", ((unsigned char *)data)[offset]);
          return;
        } else if (((signed char *)data)[offset] < 32) {
          printf("  %03o", ((char *)data)[offset]);
          return;
        }
        break;
      }
    }
    if (flags & (0x1000)) {
      printf(format, ((int8_t *)data)[offset]);
    } else {
      printf(format, ((uint8_t *)data)[offset]);
    }
    break;
  case 2:
    if (flags & (0x1000)) {
      printf(format, ((int16_t *)data)[offset]);
    } else {
      printf(format, ((uint16_t *)data)[offset]);
    }
    break;
  case 4:
  default:
    if (flags & (0x1000)) {
      printf(format, ((int32_t *)data)[offset]);
    } else {
      printf(format, ((uint32_t *)data)[offset]);
    }
    break;
  case 8:
    if (flags & (0x1000)) {
      printf(format, ((int64_t *)data)[offset]);
    } else {
      printf(format, ((uint64_t *)data)[offset]);
    }
    break;
  }
}


x86 assembly (clang, -O0):
<_print_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x7,%eax
ja     1336 <_print_date+0x226>
mov    -0x28(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     12a3 <_print_date+0x193>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xd,%eax
ja     122c <_print_date+0x11c>
mov    -0x30(%rbp),%rax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jge    1260 <_print_date+0x150>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    1294 <_print_date+0x184>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
jmp    1299 <_print_date+0x189>
jmp    129e <_print_date+0x18e>
jmp    12a3 <_print_date+0x193>
mov    -0x20(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     12cf <_print_date+0x1bf>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e5 <_print_date+0x1d5>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
mov    -0x20(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1316 <_print_date+0x206>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132c <_print_date+0x21c>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
jmp    1336 <_print_date+0x226>
mov    -0x20(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1362 <_print_date+0x252>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1378 <_print_date+0x268>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
mov    -0x20(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     13a9 <_print_date+0x299>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13bf <_print_date+0x2af>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c4 <_print_date+0x2b4>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_print_date>:
cmp    $0x8,%ecx
je     1128 <_print_date+0x18>
cmp    $0x2,%ecx
je     1128 <_print_date+0x18>
cmp    $0x1,%ecx
jne    1128 <_print_date+0x18>
test   $0x2000,%r8d
jne    1135 <_print_date+0x25>
mov    (%rdi,%rsi,4),%esi
mov    %rdx,%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
movsbl (%rdi,%rsi,1),%eax
cmp    $0xd,%eax
ja     115c <_print_date+0x4c>
lea    0xebb(%rip),%r8
movslq (%r8,%rax,4),%rcx
add    %r8,%rcx
jmp    *%rcx
lea    0xee3(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
test   %al,%al
js     11d6 <_print_date+0xc6>
cmp    $0x1f,%al
ja     1128 <_print_date+0x18>
lea    0xefd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xec3(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
movzbl %al,%esi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c" \\0\00"
@.str.1 = [6 x i8] c" \\a\00"
@.str.2 = [6 x i8] c" \\b\00"
@.str.3 = [6 x i8] c" \\f\00"
@.str.4 = [6 x i8] c" \\n\00"
@.str.5 = [6 x i8] c" \\r\00"
@.str.6 = [6 x i8] c" \\t\00"
@.str.7 = [6 x i8] c" \\v\00"
@.str.8 = [7 x i8] c" %03o\00"
define void @_print_date(i8* %0, i64 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %9
switch i32 %11, label %112 [
i32 1, label %12
i32 2, label %90
i32 4, label %111
i32 8, label %133
]
12: ; preds = %5
%13 = load i32, i32* %10
%14 = and i32 %13, 8192
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %69
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %38 [
i32 0, label %22
i32 7, label %24
i32 8, label %26
i32 12, label %28
i32 10, label %30
i32 13, label %32
i32 9, label %34
i32 11, label %36
]
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %154
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %154
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %154
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %154
30: ; preds = %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %154
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %154
34: ; preds = %16
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %154
36: ; preds = %16
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %154
38: ; preds = %16
%39 = load i8*, i8** %6
%40 = load i64, i64* %7
%41 = getelementptr inbounds i8, i8* %39, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %38
%46 = load i8*, i8** %6
%47 = load i64, i64* %7
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %50)
br label %154
52: ; preds = %38
%53 = load i8*, i8** %6
%54 = load i64, i64* %7
%55 = getelementptr inbounds i8, i8* %53, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp slt i32 %57, 32
br i1 %58, label %59, label %66
59: ; preds = %52
%60 = load i8*, i8** %6
%61 = load i64, i64* %7
%62 = getelementptr inbounds i8, i8* %60, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %64)
br label %154
66: ; preds = %52
br label %67
67: ; preds = %66
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68, %12
%70 = load i32, i32* %10
%71 = and i32 %70, 4096
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %81
73: ; preds = %69
%74 = load i8*, i8** %8
%75 = load i8*, i8** %6
%76 = bitcast i8* %75 to i32*
%77 = load i64, i64* %7
%78 = getelementptr inbounds i32, i32* %76, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* %74, i32 %79)
br label %89
81: ; preds = %69
%82 = load i8*, i8** %8
%83 = load i8*, i8** %6
%84 = bitcast i8* %83 to i32*
%85 = load i64, i64* %7
%86 = getelementptr inbounds i32, i32* %84, i64 %85
%87 = load i32, i32* %86
%88 = call i32 (i8*, ...) @printf(i8* %82, i32 %87)
br label %89
89: ; preds = %81, %73
br label %154
90: ; preds = %5
%91 = load i32, i32* %10
%92 = and i32 %91, 4096
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %102
94: ; preds = %90
%95 = load i8*, i8** %8
%96 = load i8*, i8** %6
%97 = bitcast i8* %96 to i32*
%98 = load i64, i64* %7
%99 = getelementptr inbounds i32, i32* %97, i64 %98
%100 = load i32, i32* %99
%101 = call i32 (i8*, ...) @printf(i8* %95, i32 %100)
br label %110
102: ; preds = %90
%103 = load i8*, i8** %8
%104 = load i8*, i8** %6
%105 = bitcast i8* %104 to i32*
%106 = load i64, i64* %7
%107 = getelementptr inbounds i32, i32* %105, i64 %106
%108 = load i32, i32* %107
%109 = call i32 (i8*, ...) @printf(i8* %103, i32 %108)
br label %110
110: ; preds = %102, %94
br label %154
111: ; preds = %5
br label %112
112: ; preds = %5, %111
%113 = load i32, i32* %10
%114 = and i32 %113, 4096
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %124
116: ; preds = %112
%117 = load i8*, i8** %8
%118 = load i8*, i8** %6
%119 = bitcast i8* %118 to i32*
%120 = load i64, i64* %7
%121 = getelementptr inbounds i32, i32* %119, i64 %120
%122 = load i32, i32* %121
%123 = call i32 (i8*, ...) @printf(i8* %117, i32 %122)
br label %132
124: ; preds = %112
%125 = load i8*, i8** %8
%126 = load i8*, i8** %6
%127 = bitcast i8* %126 to i32*
%128 = load i64, i64* %7
%129 = getelementptr inbounds i32, i32* %127, i64 %128
%130 = load i32, i32* %129
%131 = call i32 (i8*, ...) @printf(i8* %125, i32 %130)
br label %132
132: ; preds = %124, %116
br label %154
133: ; preds = %5
%134 = load i32, i32* %10
%135 = and i32 %134, 4096
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %145
137: ; preds = %133
%138 = load i8*, i8** %8
%139 = load i8*, i8** %6
%140 = bitcast i8* %139 to i32*
%141 = load i64, i64* %7
%142 = getelementptr inbounds i32, i32* %140, i64 %141
%143 = load i32, i32* %142
%144 = call i32 (i8*, ...) @printf(i8* %138, i32 %143)
br label %153
145: ; preds = %133
%146 = load i8*, i8** %8
%147 = load i8*, i8** %6
%148 = bitcast i8* %147 to i32*
%149 = load i64, i64* %7
%150 = getelementptr inbounds i32, i32* %148, i64 %149
%151 = load i32, i32* %150
%152 = call i32 (i8*, ...) @printf(i8* %146, i32 %151)
br label %153
153: ; preds = %145, %137
br label %154
154: ; preds = %22, %24, %26, %28, %30, %32, %34, %36, %45, %59, %153, %132, %110, %89
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" \\0\00"
@.str.1 = [6 x i8] c" \\a\00"
@.str.2 = [6 x i8] c" \\b\00"
@.str.3 = [6 x i8] c" \\f\00"
@.str.4 = [6 x i8] c" \\n\00"
@.str.5 = [6 x i8] c" \\r\00"
@.str.6 = [6 x i8] c" \\t\00"
@.str.7 = [6 x i8] c" \\v\00"
@.str.8 = [7 x i8] c" %03o\00"
define void @_print_date(i8* nocapture %0, i64 %1, i8* nocapture %2, i32 %3, i32 %4) {
switch i32 %3, label %48 [
i32 1, label %6
i32 2, label %43
i32 8, label %53
]
6: ; preds = %5
%7 = and i32 %4, 8192
%8 = icmp eq i32 %7, 0
br i1 %8, label %38, label %9
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %0, i64 %1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %29 [
i32 0, label %13
i32 7, label %15
i32 8, label %17
i32 12, label %19
i32 10, label %21
i32 13, label %23
i32 9, label %25
i32 11, label %27
]
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %58
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %58
17: ; preds = %9
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %58
19: ; preds = %9
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %58
21: ; preds = %9
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %58
23: ; preds = %9
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %58
25: ; preds = %9
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %58
27: ; preds = %9
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %58
29: ; preds = %9
%30 = icmp slt i8 %11, 0
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = zext i8 %11 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %32)
br label %58
34: ; preds = %29
%35 = icmp ult i8 %11, 32
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %12)
br label %58
38: ; preds = %34, %6
%39 = bitcast i8* %0 to i32*
%40 = getelementptr inbounds i32, i32* %39, i64 %1
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2, i32 %41)
br label %58
43: ; preds = %5
%44 = bitcast i8* %0 to i32*
%45 = getelementptr inbounds i32, i32* %44, i64 %1
%46 = load i32, i32* %45
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2, i32 %46)
br label %58
48: ; preds = %5
%49 = bitcast i8* %0 to i32*
%50 = getelementptr inbounds i32, i32* %49, i64 %1
%51 = load i32, i32* %50
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2, i32 %51)
br label %58
53: ; preds = %5
%54 = bitcast i8* %0 to i32*
%55 = getelementptr inbounds i32, i32* %54, i64 %1
%56 = load i32, i32* %55
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2, i32 %56)
br label %58
58: ; preds = %53, %48, %43, %38, %13, %15, %17, %19, %21, %23, %25, %27, %31, %36
ret void
}