#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 atoi(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int get_num_month(char *date) {
  char year[5];
  char month[3];
  int iyear, imonth;
  strncpy(year, date, 4);
  year[4] = '\0';
  strncpy(month, date + 5, 2);
  month[2] = '\0';
  iyear = atoi(year);
  imonth = atoi(month);
  return (iyear * 100 + imonth);
}


x86 assembly (clang, -O0):
<get_num_month>:
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    $0x5,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0xe(%rbp)
lea    -0xd(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
imul   $0x64,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_num_month>:
push   %r15
push   %r14
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)
add    $0x5,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xa(%rsp)
mov    %r14,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <atoi@plt>
imul   $0x64,%ebx,%ecx
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @get_num_month(i8* %0) {
%2 = alloca [5 x i8]
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = call i32 @strncpy(i8* %4, i8* %0, i32 4)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 0, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 5
%9 = call i32 @strncpy(i8* %5, i8* %8, i32 2)
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %10
%11 = call i32 @atoi(i8* %4)
%12 = call i32 @atoi(i8* %5)
%13 = mul nsw i32 %11, 100
%14 = add nsw i32 %13, %12
ret i32 %14
}