#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*/ memcpy(unsigned char *, unsigned char **, int);
long strtol(char *, int /*<<< orphan*/ *, int);
int genSuppliedDate(char *argv[], unsigned char *dateData) {
  int year;
  unsigned char month;
  unsigned char day;
  long int a = strtol(argv[1], NULL, 10);
  month = a / 1000000;
  day = a / 10000 % 100;
  year = a % 10000;
  year = (year & 0xff) + 0x30;
  day = (day / 7) * 7;
  unsigned char combined[] = {year, month, day};
  memcpy(dateData, &combined, 4);
  return 1;
}


x86 assembly (clang, -O0):
<genSuppliedDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %al,-0x15(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %dl,%al
mov    %al,-0x16(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xff,%eax
add    $0x30,%eax
mov    %eax,-0x14(%rbp)
movzbl -0x16(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
imul   $0x7,%eax,%eax
mov    %al,-0x16(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,-0x23(%rbp)
mov    -0x15(%rbp),%al
mov    %al,-0x22(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x23(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genSuppliedDate>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x8(%rdi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,%rcx
movabs $0x431bde82d7b634db,%rdx
de 1b 43
imul   %rdx
mov    %rdx,%rsi
movabs $0x346dc5d63886594b,%rdx
c5 6d 34
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xb,%rdi
add    %rax,%rdi
movabs $0xa3d70a3d70a3d70b,%rdx
0a d7 a3
mov    %rdi,%rax
imul   %rdx
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x12,%esi
add    %eax,%esi
add    %rdi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
imul   $0x64,%rdx,%rax
imul   $0x2710,%edi,%edx
sub    %rax,%rdi
sub    %edx,%ecx
add    $0x30,%cl
movzbl %dil,%eax
lea    (%rax,%rax,8),%edx
lea    (%rax,%rdx,4),%eax
shr    $0x8,%eax
sub    %al,%dil
shr    %dil
add    %al,%dil
shr    $0x2,%dil
movzbl %dil,%eax
lea    0x0(,%rax,8),%edx
sub    %eax,%edx
mov    %cl,0xd(%rsp)
mov    %sil,0xe(%rsp)
mov    %dl,0xf(%rsp)
lea    0xd(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @genSuppliedDate(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i64
%9 = alloca [3 x i8]
store i8** %0, i8*** %3
store i8* %1, i8** %4
%10 = load i8**, i8*** %3
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strtol(i8* %12, i32* null, i32 10)
store i64 %13, i64* %8
%14 = load i64, i64* %8
%15 = sdiv i64 %14, 1000000
%16 = trunc i64 %15 to i8
store i8 %16, i8* %6
%17 = load i64, i64* %8
%18 = sdiv i64 %17, 10000
%19 = srem i64 %18, 100
%20 = trunc i64 %19 to i8
store i8 %20, i8* %7
%21 = load i64, i64* %8
%22 = srem i64 %21, 10000
%23 = trunc i64 %22 to i32
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = and i32 %24, 255
%26 = add nsw i32 %25, 48
store i32 %26, i32* %5
%27 = load i8, i8* %7
%28 = zext i8 %27 to i32
%29 = sdiv i32 %28, 7
%30 = mul nsw i32 %29, 7
%31 = trunc i32 %30 to i8
store i8 %31, i8* %7
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%33 = load i32, i32* %5
%34 = trunc i32 %33 to i8
store i8 %34, i8* %32
%35 = getelementptr inbounds i8, i8* %32, i64 1
%36 = load i8, i8* %6
store i8 %36, i8* %35
%37 = getelementptr inbounds i8, i8* %35, i64 1
%38 = load i8, i8* %7
store i8 %38, i8* %37
%39 = load i8*, i8** %4
%40 = bitcast [3 x i8]* %9 to i8**
%41 = call i32 @memcpy(i8* %39, i8** %40, i32 4)
ret i32 1
}

LLVM IR (-O2):
define i32 @genSuppliedDate(i8** nocapture %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds i8*, i8** %0, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strtol(i8* nocapture %5, i32* null, i32 10)
%7 = sdiv i64 %6, 1000000
%8 = trunc i64 %7 to i8
%9 = sdiv i64 %6, 10000
%10 = srem i64 %9, 100
%11 = trunc i64 %10 to i8
%12 = srem i64 %6, 10000
%13 = trunc i64 %12 to i8
%14 = add i8 %13, 48
%15 = urem i8 %11, 7
%16 = sub nsw i8 %11, %15
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8 %14, i8* %17
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 %8, i8* %18
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 %16, i8* %19
%20 = bitcast [3 x i8]* %3 to i8**
%21 = call i32 @memcpy(i8* %1, i8** %20, i32 4)
ret i32 1
}