void get_iso_date(char *iso_date, const char *buff) {
  char month[6];
  const char *tptr, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
  int day, year, m;
  printf("# %s", buff);
  if (sscanf(buff, "%4s %d, %d", month, &day, &year) != 3) {
    printf("Malformed date : '%s'\n", buff);
    exit(-1);
  }
  tptr = strstr(months, month);
  assert(tptr);
  m = tptr - months;
  assert(m % 3 == 0);
  m = m / 3 + 1;
  assert(m > 0 && m < 13);
  snprintf(iso_date, 20, "%4d-%02d-%02d", year, m, day);
}


x86 assembly (clang, -O0):
<get_iso_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x16(%rbp),%rdx
lea    0xe8e(%rip),%rsi
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
mov    $0x0,%al
call   1060 <sscanf@plt>
cmp    $0x3,%eax
je     11d0 <get_iso_date+0x70>
mov    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x34(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x35(%rbp)
jle    1241 <get_iso_date+0xe1>
cmpl   $0xd,-0x34(%rbp)
setl   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    $0x14,%esi
lea    0xde1(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_iso_date>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea5(%rip),%rsi
lea    0x12(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <sscanf@plt>
cmp    $0x3,%eax
jne    123c <get_iso_date+0xdc>
lea    0xe52(%rip),%r15
lea    0x12(%rsp),%rsi
mov    %r15,%rdi
call   1080 <strstr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
sub    %r15d,%ebx
movslq %ebx,%rbx
imul   $0x55555556,%rbx,%rbp
mov    %rbp,%r15
shr    $0x3f,%r15
shr    $0x20,%rbp
lea    (%r15,%rbp,1),%eax
lea    (%rax,%rax,2),%eax
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
xor    %eax,%eax
call   1050 <assert@plt>
add    %r15d,%ebp
add    $0x1,%ebp
add    $0x2,%ebx
xor    %edi,%edi
cmp    $0x26,%ebx
setb   %dil
xor    %eax,%eax
call   1050 <assert@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r9d
lea    0xe2d(%rip),%rdx
mov    $0x14,%esi
mov    %r14,%rdi
mov    %ebp,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDec\00"
@.str.1 = [5 x i8] c"# %s\00"
@.str.2 = [11 x i8] c"%4s %d, %d\00"
@.str.3 = [23 x i8] c"Malformed date : '%s'\0A\00"
@.str.4 = [14 x i8] c"%4d-%02d-%02d\00"
define void @get_iso_date(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [6 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %7
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %4
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32* %8, i32* %9)
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %18)
unreachable
20: ; preds = %2
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%23 = call i8* @strstr(i8* %21, i8* %22)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %24)
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = trunc i64 %30 to i32
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = srem i32 %32, 3
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = load i32, i32* %10
%38 = sdiv i32 %37, 3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
%40 = load i32, i32* %10
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %20
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 13
br label %45
45: ; preds = %42, %20
%46 = phi i1 [ false, %20 ], [ %44, %42 ]
%47 = zext i1 %46 to i32
%48 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %47)
%49 = load i8*, i8** %3
%50 = load i32, i32* %9
%51 = load i32, i32* %10
%52 = load i32, i32* %8
%53 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %49, i64 20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %50, i32 %51, i32 %52)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDec\00"
@.str.1 = [5 x i8] c"# %s\00"
@.str.2 = [11 x i8] c"%4s %d, %d\00"
@.str.3 = [23 x i8] c"Malformed date : '%s'\0A\00"
@.str.4 = [14 x i8] c"%4d-%02d-%02d\00"
define void @get_iso_date(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = call i32 (i8*, i8*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32* %4, i32* %5)
%11 = icmp eq i32 %10, 3
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %1)
unreachable
14: ; preds = %2
%15 = call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %6)
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %15)
%17 = ptrtoint i8* %15 to i64
%18 = trunc i64 %17 to i32
%19 = sub i32 %18, ptrtoint ([37 x i8]* @.str to i32)
%20 = srem i32 %19, 3
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %22)
%24 = sdiv i32 %19, 3
%25 = add nsw i32 %24, 1
%26 = add i32 %19, 2
%27 = icmp ult i32 %26, 38
%28 = zext i1 %27 to i32
%29 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %28)
%30 = load i32, i32* %5
%31 = load i32, i32* %4
%32 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* dereferenceable(1) %0, i64 20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %25, i32 %31)
ret void
}