#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*/ printf(char *, ...);
char *timestr(unsigned long);
void printserial(const char *fname, unsigned long serial) {
  if (fname && *fname)
    printf("%-30s\t", fname);
  printf("%10lu", serial);
  if (serial < 1136070000L)
    ;
  else if (serial > 2006010100L) {
    int y, m, d, v;
    v = serial % 100;
    serial /= 100;
    d = serial % 100;
    serial /= 100;
    m = serial % 100;
    serial /= 100;
    y = serial;
    printf("\t%d-%02d-%02d Version %02d", y, m, d, v);
  } else
    printf("\t%s\n", timestr(serial));
  printf("\n");
}


x86 assembly (clang, -O0):
<printserial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     115d <printserial+0x3d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     115d <printserial+0x3d>
mov    -0x8(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x43b70d70,-0x10(%rbp)
43
jae    1182 <printserial+0x62>
jmp    1245 <printserial+0x125>
cmpq   $0x779148f4,-0x10(%rbp)
77
jbe    1226 <printserial+0x106>
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1240 <printserial+0x120>
mov    -0x10(%rbp),%rdi
call   1030 <timestr@plt>
mov    %rax,%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <printserial+0x125>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printserial>:
push   %rbx
mov    %rsi,%rbx
test   %rdi,%rdi
je     114f <printserial+0x1f>
mov    %rdi,%rsi
cmpb   $0x0,(%rdi)
je     114f <printserial+0x1f>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x43b70d70,%rbx
jb     1221 <printserial+0xf1>
cmp    $0x779148f5,%rbx
jb     1208 <printserial+0xd8>
mov    %rbx,%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rdi
c2 f5 28
mul    %rdi
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0x2,%rcx
imul   $0x64,%ecx,%edx
mov    %ebx,%r8d
sub    %edx,%r8d
shr    $0x4,%rax
mul    %rdi
mov    %rdx,%rsi
movabs $0x346dc5d63886594b,%rdx
c5 6d 34
mov    %rbx,%rax
mul    %rdx
mov    %rdx,%rax
shr    $0x2,%rsi
imul   $0x64,%esi,%edx
sub    %edx,%ecx
mov    %rax,%r9
shr    $0xd,%rax
mul    %rdi
shr    $0xb,%r9
shr    $0x2,%rdx
imul   $0x64,%edx,%eax
sub    %eax,%r9d
movabs $0x431bde82d7b634db,%rdx
de 1b 43
mov    %rbx,%rax
mul    %rdx
shr    $0x12,%rdx
lea    0xe13(%rip),%rdi
mov    %edx,%esi
mov    %r9d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1221 <printserial+0xf1>
mov    %rbx,%rdi
call   1040 <timestr@plt>
lea    0xe11(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%-30s\09\00"
@.str.1 = [6 x i8] c"%10lu\00"
@.str.2 = [27 x i8] c"\09%d-%02d-%02d Version %02d\00"
@.str.3 = [5 x i8] c"\09%s\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @printserial(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %11, %2
%20 = load i64, i64* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %4
%23 = icmp ult i64 %22, 1136070000
br i1 %23, label %24, label %25
24: ; preds = %19
br label %56
25: ; preds = %19
%26 = load i64, i64* %4
%27 = icmp ugt i64 %26, 2006010100
br i1 %27, label %28, label %51
28: ; preds = %25
%29 = load i64, i64* %4
%30 = urem i64 %29, 100
%31 = trunc i64 %30 to i32
store i32 %31, i32* %8
%32 = load i64, i64* %4
%33 = udiv i64 %32, 100
store i64 %33, i64* %4
%34 = load i64, i64* %4
%35 = urem i64 %34, 100
%36 = trunc i64 %35 to i32
store i32 %36, i32* %7
%37 = load i64, i64* %4
%38 = udiv i64 %37, 100
store i64 %38, i64* %4
%39 = load i64, i64* %4
%40 = urem i64 %39, 100
%41 = trunc i64 %40 to i32
store i32 %41, i32* %6
%42 = load i64, i64* %4
%43 = udiv i64 %42, 100
store i64 %43, i64* %4
%44 = load i64, i64* %4
%45 = trunc i64 %44 to i32
store i32 %45, i32* %5
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %46, i32 %47, i32 %48, i32 %49)
br label %55
51: ; preds = %25
%52 = load i64, i64* %4
%53 = call i8* @timestr(i64 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %51, %28
br label %56
56: ; preds = %55, %24
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%-30s\09\00"
@.str.1 = [6 x i8] c"%10lu\00"
@.str.2 = [27 x i8] c"\09%d-%02d-%02d Version %02d\00"
@.str.3 = [5 x i8] c"\09%s\0A\00"
define void @printserial(i8* %0, i64 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %4, %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %1)
%11 = icmp ult i64 %1, 1136070000
br i1 %11, label %29, label %12
12: ; preds = %9
%13 = icmp ugt i64 %1, 2006010100
br i1 %13, label %14, label %26
14: ; preds = %12
%15 = urem i64 %1, 100
%16 = trunc i64 %15 to i32
%17 = udiv i64 %1, 100
%18 = urem i64 %17, 100
%19 = trunc i64 %18 to i32
%20 = udiv i64 %1, 10000
%21 = urem i64 %20, 100
%22 = trunc i64 %21 to i32
%23 = udiv i64 %1, 1000000
%24 = trunc i64 %23 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %22, i32 %19, i32 %16)
br label %29
26: ; preds = %12
%27 = tail call i8* @timestr(i64 %1)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %14, %26, %9
%30 = tail call i32 @putchar(i32 10)
ret void
}