#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 hex2number(char const *, int);
int /*<<< orphan*/ isxdigit(int);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int, int);
int pdu_get_timestamp(const char *buffer) {
  int i;
  for (i = 0; i < 14; i++) {
    if (!isxdigit((int)buffer[i]))
      return -1;
  }
  printf("Date: %d-%d-%d %d:%d:%d TZ=%d\n", hex2number(buffer + 0, 2),
         hex2number(buffer + 2, 2), hex2number(buffer + 4, 2),
         hex2number(buffer + 6, 2), hex2number(buffer + 8, 2),
         hex2number(buffer + 10, 2), hex2number(buffer + 12, 2));
  return 14;
}


x86 assembly (clang, -O0):
<pdu_get_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xe,-0x14(%rbp)
jge    1186 <pdu_get_timestamp+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isxdigit@plt>
cmp    $0x0,%eax
jne    1173 <pdu_get_timestamp+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    1242 <pdu_get_timestamp+0x112>
jmp    1178 <pdu_get_timestamp+0x48>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <pdu_get_timestamp+0x13>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
add    $0xa,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0xc,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x18(%rbp),%r10d
lea    0xdd2(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <printf@plt>
movl   $0xe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdu_get_timestamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <isxdigit@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x1(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x2(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x3(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x4(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x5(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x6(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x7(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x8(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0x9(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0xa(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0xb(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0xc(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
movsbl 0xd(%rbx),%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     12e7 <pdu_get_timestamp+0x1b7>
lea    0x2(%rbx),%rbp
lea    0x4(%rbx),%r13
lea    0x6(%rbx),%r14
lea    0x8(%rbx),%r15
lea    0xa(%rbx),%r12
lea    0xc(%rbx),%rax
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,0x8(%rsp)
mov    %r13,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,%r13d
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,%r14d
mov    %r15,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rdi
mov    $0x2,%esi
call   1030 <hex2number@plt>
lea    0xd3a(%rip),%rdi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r13d,%ecx
mov    %r14d,%r8d
mov    %ebp,%r9d
push   %rax
push   %rbx
call   1040 <printf@plt>
add    $0x10,%rsp
mov    $0xe,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Date: %d-%d-%d %d:%d:%d TZ=%d\0A\00"
define i32 @pdu_get_timestamp(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 14
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 @isxdigit(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %8
store i32 -1, i32* %2
br label %45
18: ; preds = %8
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %5
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = call i32 @hex2number(i8* %24, i32 2)
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = call i32 @hex2number(i8* %27, i32 2)
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 4
%31 = call i32 @hex2number(i8* %30, i32 2)
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 6
%34 = call i32 @hex2number(i8* %33, i32 2)
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 8
%37 = call i32 @hex2number(i8* %36, i32 2)
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 10
%40 = call i32 @hex2number(i8* %39, i32 2)
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 12
%43 = call i32 @hex2number(i8* %42, i32 2)
%44 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28, i32 %31, i32 %34, i32 %37, i32 %40, i32 %43)
store i32 14, i32* %2
br label %45
45: ; preds = %22, %17
%46 = load i32, i32* %2
ret i32 %46
}

LLVM IR (-O2):
@.str = [31 x i8] c"Date: %d-%d-%d %d:%d:%d TZ=%d\0A\00"
define i32 @pdu_get_timestamp(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = tail call i32 @isxdigit(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %93, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = tail call i32 @isxdigit(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %93, label %12
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = tail call i32 @isxdigit(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %93, label %18
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = tail call i32 @isxdigit(i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %93, label %24
24: ; preds = %18
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 @isxdigit(i32 %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %93, label %30
30: ; preds = %24
%31 = getelementptr inbounds i8, i8* %0, i64 5
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = tail call i32 @isxdigit(i32 %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %93, label %36
36: ; preds = %30
%37 = getelementptr inbounds i8, i8* %0, i64 6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = tail call i32 @isxdigit(i32 %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %93, label %42
42: ; preds = %36
%43 = getelementptr inbounds i8, i8* %0, i64 7
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 @isxdigit(i32 %45)
%47 = icmp eq i32 %46, 0
br i1 %47, label %93, label %48
48: ; preds = %42
%49 = getelementptr inbounds i8, i8* %0, i64 8
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = tail call i32 @isxdigit(i32 %51)
%53 = icmp eq i32 %52, 0
br i1 %53, label %93, label %54
54: ; preds = %48
%55 = getelementptr inbounds i8, i8* %0, i64 9
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = tail call i32 @isxdigit(i32 %57)
%59 = icmp eq i32 %58, 0
br i1 %59, label %93, label %60
60: ; preds = %54
%61 = getelementptr inbounds i8, i8* %0, i64 10
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = tail call i32 @isxdigit(i32 %63)
%65 = icmp eq i32 %64, 0
br i1 %65, label %93, label %66
66: ; preds = %60
%67 = getelementptr inbounds i8, i8* %0, i64 11
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = tail call i32 @isxdigit(i32 %69)
%71 = icmp eq i32 %70, 0
br i1 %71, label %93, label %72
72: ; preds = %66
%73 = getelementptr inbounds i8, i8* %0, i64 12
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = tail call i32 @isxdigit(i32 %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %93, label %78
78: ; preds = %72
%79 = getelementptr inbounds i8, i8* %0, i64 13
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = tail call i32 @isxdigit(i32 %81)
%83 = icmp eq i32 %82, 0
br i1 %83, label %93, label %84
84: ; preds = %78
%85 = tail call i32 @hex2number(i8* %0, i32 2)
%86 = tail call i32 @hex2number(i8* %13, i32 2)
%87 = tail call i32 @hex2number(i8* %25, i32 2)
%88 = tail call i32 @hex2number(i8* %37, i32 2)
%89 = tail call i32 @hex2number(i8* %49, i32 2)
%90 = tail call i32 @hex2number(i8* %61, i32 2)
%91 = tail call i32 @hex2number(i8* %73, i32 2)
%92 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %85, i32 %86, i32 %87, i32 %88, i32 %89, i32 %90, i32 %91)
br label %93
93: ; preds = %1, %6, %12, %18, %24, %30, %36, %42, %48, %54, %60, %66, %72, %78, %84
%94 = phi i32 [ 14, %84 ], [ -1, %78 ], [ -1, %72 ], [ -1, %66 ], [ -1, %60 ], [ -1, %54 ], [ -1, %48 ], [ -1, %42 ], [ -1, %36 ], [ -1, %30 ], [ -1, %24 ], [ -1, %18 ], [ -1, %12 ], [ -1, %6 ], [ -1, %1 ]
ret i32 %94
}