#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 */
typedef int time_t;
struct tm {
  scalar_t__ tm_sec;
  void *tm_min;
  void *tm_hour;
  void *tm_mday;
  void *tm_mon;
  void *tm_year;
};

/* Variables and functions */
void *atoi(char *);
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
time_t convert_argument_to_time(char *argument) {
  struct tm time;
  time_t time_converted = 0;
  char year[5];
  char month[3];
  char day[3];
  char hours[3];
  char minutes[3];
  if (strlen(argument) >= 12) {
    strncpy(year, argument, 4);
    strncpy(month, argument + 4, 6 - 4);
    strncpy(day, argument + 6, 8 - 6);
    strncpy(hours, argument + 8, 10 - 8);
    strncpy(minutes, argument + 10, 12 - 10);
    time.tm_year = atoi(year) - 1900;
    time.tm_mon = atoi(month) - 1;
    time.tm_mday = atoi(day);
    time.tm_hour = atoi(hours) - 1;
    time.tm_min = atoi(minutes);
    time.tm_sec = 0;
    time_converted = mktime(&time);
    if (time_converted == -1) {
      printf("Ocorreu um erro na conversão\n");
    }
  } else {
    printf("String inválida!\n");
    printf("Digite uma string no formato AAAAMMDDHHmm\n");
  }
  return time_converted;
}


x86 assembly (clang, -O0):
<convert_argument_to_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xc,%eax
jl     125d <convert_argument_to_time+0x10d>
lea    -0x41(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    -0x44(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x47(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x6,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x4a(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x4d(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0xa,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x41(%rbp),%rdi
call   1070 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,-0x10(%rbp)
lea    -0x44(%rbp),%rdi
call   1070 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
lea    -0x47(%rbp),%rdi
call   1070 <atoi@plt>
mov    %rax,-0x20(%rbp)
lea    -0x4a(%rbp),%rdi
call   1070 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
lea    -0x4d(%rbp),%rdi
call   1070 <atoi@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x38(%rbp),%rdi
call   1060 <mktime@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1258 <convert_argument_to_time+0x108>
lea    0xdad(%rip),%rdi
call   1050 <printf@plt>
jmp    1275 <convert_argument_to_time+0x125>
lea    0xdbb(%rip),%rdi
call   1050 <printf@plt>
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_argument_to_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
cmp    $0xc,%eax
jl     1264 <convert_argument_to_time+0x114>
lea    0x13(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
lea    0x4(%rbx),%rsi
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    0x6(%rbx),%rsi
lea    0xd(%rsp),%r15
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    0x8(%rbx),%rsi
lea    0xa(%rsp),%r12
mov    %r12,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
add    $0xa,%rbx
lea    0x7(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1070 <atoi@plt>
movq   %rbx,%xmm0
movq   %rax,%xmm1
punpcklqdq %xmm0,%xmm1
paddq  0xdf8(%rip),%xmm1
movdqu %xmm1,0x38(%rsp)
mov    %r15,%rdi
call   1070 <atoi@plt>
mov    %rax,0x30(%rsp)
mov    %r12,%rdi
call   1070 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,0x28(%rsp)
mov    %rbp,%rdi
call   1070 <atoi@plt>
mov    %rax,0x20(%rsp)
movq   $0x0,0x18(%rsp)
lea    0x18(%rsp),%rdi
call   1060 <mktime@plt>
cmp    $0xffffffff,%eax
jne    127e <convert_argument_to_time+0x12e>
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    127e <convert_argument_to_time+0x12e>
lea    0xda5(%rip),%rdi
call   1040 <puts@plt>
lea    0xdab(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i64, i8*, i8*, i8*, i8*, i8* }
@.str = [31 x i8] c"Ocorreu um erro na convers\C3\A3o\0A\00"
@.str.1 = [19 x i8] c"String inv\C3\A1lida!\0A\00"
@.str.2 = [43 x i8] c"Digite uma string no formato AAAAMMDDHHmm\0A\00"
define i32 @convert_argument_to_time(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca [5 x i8]
%6 = alloca [3 x i8]
%7 = alloca [3 x i8]
%8 = alloca [3 x i8]
%9 = alloca [3 x i8]
store i8* %0, i8** %2
store i32 0, i32* %4
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = icmp sge i32 %11, 12
br i1 %12, label %13, label %58
13: ; preds = %1
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @strncpy(i8* %14, i8* %15, i32 4)
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = call i32 @strncpy(i8* %17, i8* %19, i32 2)
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 6
%24 = call i32 @strncpy(i8* %21, i8* %23, i32 2)
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 8
%28 = call i32 @strncpy(i8* %25, i8* %27, i32 2)
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 10
%32 = call i32 @strncpy(i8* %29, i8* %31, i32 2)
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%34 = call i8* @atoi(i8* %33)
%35 = getelementptr i8, i8* %34, i64 -1900
%36 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
store i8* %35, i8** %36
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%38 = call i8* @atoi(i8* %37)
%39 = getelementptr i8, i8* %38, i64 -1
%40 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
store i8* %39, i8** %40
%41 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%42 = call i8* @atoi(i8* %41)
%43 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
store i8* %42, i8** %43
%44 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%45 = call i8* @atoi(i8* %44)
%46 = getelementptr i8, i8* %45, i64 -1
%47 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
store i8* %46, i8** %47
%48 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%49 = call i8* @atoi(i8* %48)
%50 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
store i8* %49, i8** %50
%51 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i64 0, i64* %51
%52 = call i32 @mktime(%struct.tm* %3)
store i32 %52, i32* %4
%53 = load i32, i32* %4
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %13
%56 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %57
57: ; preds = %55, %13
br label %61
58: ; preds = %1
%59 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%60 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %58, %57
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
%struct.tm = type { i64, i8*, i8*, i8*, i8*, i8* }
@str = [18 x i8] c"String inv\C3\A1lida!\00"
@str.3 = [42 x i8] c"Digite uma string no formato AAAAMMDDHHmm\00"
@str.4 = [30 x i8] c"Ocorreu um erro na convers\C3\A3o\00"
define i32 @convert_argument_to_time(i8* %0) {
%2 = alloca %struct.tm
%3 = alloca [5 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca [3 x i8]
%8 = bitcast %struct.tm* %2 to i8*
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%14 = tail call i32 @strlen(i8* %0)
%15 = icmp sgt i32 %14, 11
br i1 %15, label %16, label %45
16: ; preds = %1
%17 = call i32 @strncpy(i8* %9, i8* %0, i32 4)
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = call i32 @strncpy(i8* %10, i8* %18, i32 2)
%20 = getelementptr inbounds i8, i8* %0, i64 6
%21 = call i32 @strncpy(i8* %11, i8* %20, i32 2)
%22 = getelementptr inbounds i8, i8* %0, i64 8
%23 = call i32 @strncpy(i8* %12, i8* %22, i32 2)
%24 = getelementptr inbounds i8, i8* %0, i64 10
%25 = call i32 @strncpy(i8* %13, i8* %24, i32 2)
%26 = call i8* @atoi(i8* %9)
%27 = call i8* @atoi(i8* %10)
%28 = insertelement <2 x i8*> poison, i8* %27, i64 0
%29 = insertelement <2 x i8*> %28, i8* %26, i64 1
%30 = getelementptr i8, <2 x i8*> %29, <2 x i64> <i64 -1, i64 -1900>
%31 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
%32 = bitcast i8** %31 to <2 x i8*>*
store <2 x i8*> %30, <2 x i8*>* %32
%33 = call i8* @atoi(i8* %11)
%34 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
store i8* %33, i8** %34
%35 = call i8* @atoi(i8* %12)
%36 = getelementptr i8, i8* %35, i64 -1
%37 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
store i8* %36, i8** %37
%38 = call i8* @atoi(i8* %13)
%39 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
store i8* %38, i8** %39
%40 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i64 0, i64* %40
%41 = call i32 @mktime(%struct.tm* %2)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %16
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
br label %48
45: ; preds = %1
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0))
br label %48
48: ; preds = %16, %43, %45
%49 = phi i32 [ -1, %43 ], [ %41, %16 ], [ 0, %45 ]
ret i32 %49
}