#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 atol(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
long UTL_ConvertDatetoLong(const char *date) {
  char year[5], month[3], day[3];
  strncpy(year, date, 4);
  year[4] = '\000';
  strncpy(month, date + 4, 2);
  month[2] = '\000';
  strncpy(day, date + 6, 2);
  day[2] = '\000';
  return ((atol(year) * 10000) + (atol(month) * 100) + atol(day));
}


x86 assembly (clang, -O0):
<UTL_ConvertDatetoLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xd(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x9(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0xe(%rbp)
lea    -0x13(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x6,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x11(%rbp)
lea    -0xd(%rbp),%rdi
call   1040 <atol@plt>
imul   $0x2710,%eax,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <atol@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   $0x64,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
lea    -0x13(%rbp),%rdi
call   1040 <atol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
cltq
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UTL_ConvertDatetoLong>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xb(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
lea    0x4(%rbx),%rsi
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xa(%rsp)
add    $0x6,%rbx
lea    0x5(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x7(%rsp)
mov    %r14,%rdi
call   1040 <atol@plt>
imul   $0x2710,%eax,%ebx
mov    %r15,%rdi
call   1040 <atol@plt>
imul   $0x64,%eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
call   1040 <atol@plt>
add    %ebp,%eax
cltq
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @UTL_ConvertDatetoLong(i8* %0) {
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
store i8* %0, i8** %2
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strncpy(i8* %6, i8* %7, i32 4)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 0, i8* %9
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 4
%13 = call i32 @strncpy(i8* %10, i8* %12, i32 2)
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 6
%18 = call i32 @strncpy(i8* %15, i8* %17, i32 2)
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
store i8 0, i8* %19
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%21 = call i32 @atol(i8* %20)
%22 = mul nsw i32 %21, 10000
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%24 = call i32 @atol(i8* %23)
%25 = mul nsw i32 %24, 100
%26 = add nsw i32 %22, %25
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%28 = call i32 @atol(i8* %27)
%29 = add nsw i32 %26, %28
%30 = sext i32 %29 to i64
ret i64 %30
}

LLVM IR (-O2):
define i64 @UTL_ConvertDatetoLong(i8* %0) {
%2 = alloca [5 x i8]
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%8 = call i32 @strncpy(i8* %5, i8* %0, i32 4)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 4
%11 = call i32 @strncpy(i8* %6, i8* %10, i32 2)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 6
%14 = call i32 @strncpy(i8* %7, i8* %13, i32 2)
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %15
%16 = call i32 @atol(i8* %5)
%17 = mul nsw i32 %16, 10000
%18 = call i32 @atol(i8* %6)
%19 = mul nsw i32 %18, 100
%20 = add nsw i32 %19, %17
%21 = call i32 @atol(i8* %7)
%22 = add nsw i32 %20, %21
%23 = sext i32 %22 to i64
ret i64 %23
}