#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 {
  char tm_mon;
  char tm_mday;
  char tm_hour;
  char tm_min;
  char tm_year;
  int tm_isdst;
};
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int, char *);
struct tm *localtime(int *);
int mktime(struct tm *);
void stime_arg2(const char *arg, int year, struct timeval *tvp) {
  time_t now;
  struct tm *t;
  now = tvp[0].tv_sec;
  if ((t = localtime(&now)) == NULL)
    err(1, "localtime");
  t->tm_mon = ((arg)[0] - '0') * 10 + ((arg)[1] - '0');
  (arg) += 2;
  ;
  --t->tm_mon;
  t->tm_mday = ((arg)[0] - '0') * 10 + ((arg)[1] - '0');
  (arg) += 2;
  ;
  t->tm_hour = ((arg)[0] - '0') * 10 + ((arg)[1] - '0');
  (arg) += 2;
  ;
  t->tm_min = ((arg)[0] - '0') * 10 + ((arg)[1] - '0');
  (arg) += 2;
  ;
  if (year) {
    t->tm_year = ((arg)[0] - '0') * 10 + ((arg)[1] - '0');
    (arg) += 2;
    ;
    if (t->tm_year < 39)
      t->tm_year += 100;
  }
  t->tm_isdst = -1;
  tvp[0].tv_sec = tvp[1].tv_sec = mktime(t);
  if (tvp[0].tv_sec == -1)
    errx(1, "out of range or illegal time specification: MMDDhhmm[yy]");
  tvp[0].tv_usec = tvp[1].tv_usec = 0;
}


x86 assembly (clang, -O0):
<stime_arg2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1184 <stime_arg2+0x44>
mov    $0x1,%edi
lea    0xe81(%rip),%rsi
call   1050 <err@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
add    $0xff,%cl
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     12a7 <stime_arg2+0x167>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x27,%eax
jge    12a2 <stime_arg2+0x162>
mov    -0x28(%rbp),%rax
movsbl 0x4(%rax),%ecx
add    $0x64,%ecx
mov    %cl,0x4(%rax)
jmp    12a7 <stime_arg2+0x167>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,0x8(%rax)
mov    -0x28(%rbp),%rdi
call   1060 <mktime@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    12e8 <stime_arg2+0x1a8>
mov    $0x1,%edi
lea    0xd27(%rip),%rsi
call   1040 <errx@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stime_arg2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdx),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1178 <stime_arg2+0x38>
lea    0xe92(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
movzbl (%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    0x1(%rbx),%al
add    $0xef,%al
mov    %al,(%r15)
movzbl 0x2(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    0x3(%rbx),%al
add    $0xf0,%al
mov    %al,0x1(%r15)
movzbl 0x4(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    0x5(%rbx),%al
add    $0xf0,%al
mov    %al,0x2(%r15)
movzbl 0x6(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    0x7(%rbx),%al
add    $0xf0,%al
mov    %al,0x3(%r15)
test   %ebp,%ebp
je     11e0 <stime_arg2+0xa0>
movzbl 0x8(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
add    0x9(%rbx),%al
lea    -0x10(%rax),%ecx
mov    %cl,0x4(%r15)
cmp    $0x26,%cl
jg     11e0 <stime_arg2+0xa0>
add    $0x54,%al
mov    %al,0x4(%r15)
movl   $0xffffffff,0x8(%r15)
ff
mov    %r15,%rdi
call   1060 <mktime@plt>
mov    %eax,0x10(%r14)
mov    %eax,(%r14)
cmp    $0xffffffff,%eax
jne    120d <stime_arg2+0xcd>
lea    0xe07(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
movq   $0x0,0x18(%r14)
movq   $0x0,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
%struct.tm = type { i8, i8, i8, i8, i8, i32 }
@.str = [10 x i8] c"localtime\00"
@.str.1 = [57 x i8] c"out of range or illegal time specification: MMDDhhmm[yy]\00"
define void @stime_arg2(i8* %0, i32 %1, %struct.timeval* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.timeval*
%7 = alloca i32
%8 = alloca %struct.tm*
store i8* %0, i8** %4
store i32 %1, i32* %5
store %struct.timeval* %2, %struct.timeval** %6
%9 = load %struct.timeval*, %struct.timeval** %6
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %7
%13 = call %struct.tm* @localtime(i32* %7)
store %struct.tm* %13, %struct.tm** %8
%14 = icmp eq %struct.tm* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @err(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 48
%23 = mul nsw i32 %22, 10
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 48
%29 = add nsw i32 %23, %28
%30 = trunc i32 %29 to i8
%31 = load %struct.tm*, %struct.tm** %8
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 0
store i8 %30, i8* %32
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 2
store i8* %34, i8** %4
%35 = load %struct.tm*, %struct.tm** %8
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 0
%37 = load i8, i8* %36
%38 = add i8 %37, -1
store i8 %38, i8* %36
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = sub nsw i32 %42, 48
%44 = mul nsw i32 %43, 10
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 1
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = sub nsw i32 %48, 48
%50 = add nsw i32 %44, %49
%51 = trunc i32 %50 to i8
%52 = load %struct.tm*, %struct.tm** %8
%53 = getelementptr inbounds %struct.tm, %struct.tm* %52, i32 0, i32 1
store i8 %51, i8* %53
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 2
store i8* %55, i8** %4
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = sub nsw i32 %59, 48
%61 = mul nsw i32 %60, 10
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = sub nsw i32 %65, 48
%67 = add nsw i32 %61, %66
%68 = trunc i32 %67 to i8
%69 = load %struct.tm*, %struct.tm** %8
%70 = getelementptr inbounds %struct.tm, %struct.tm* %69, i32 0, i32 2
store i8 %68, i8* %70
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 2
store i8* %72, i8** %4
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = sub nsw i32 %76, 48
%78 = mul nsw i32 %77, 10
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i64 1
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = sub nsw i32 %82, 48
%84 = add nsw i32 %78, %83
%85 = trunc i32 %84 to i8
%86 = load %struct.tm*, %struct.tm** %8
%87 = getelementptr inbounds %struct.tm, %struct.tm* %86, i32 0, i32 3
store i8 %85, i8* %87
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i64 2
store i8* %89, i8** %4
%90 = load i32, i32* %5
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %123
92: ; preds = %17
%93 = load i8*, i8** %4
%94 = getelementptr inbounds i8, i8* %93, i64 0
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = sub nsw i32 %96, 48
%98 = mul nsw i32 %97, 10
%99 = load i8*, i8** %4
%100 = getelementptr inbounds i8, i8* %99, i64 1
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = sub nsw i32 %102, 48
%104 = add nsw i32 %98, %103
%105 = trunc i32 %104 to i8
%106 = load %struct.tm*, %struct.tm** %8
%107 = getelementptr inbounds %struct.tm, %struct.tm* %106, i32 0, i32 4
store i8 %105, i8* %107
%108 = load i8*, i8** %4
%109 = getelementptr inbounds i8, i8* %108, i64 2
store i8* %109, i8** %4
%110 = load %struct.tm*, %struct.tm** %8
%111 = getelementptr inbounds %struct.tm, %struct.tm* %110, i32 0, i32 4
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp slt i32 %113, 39
br i1 %114, label %115, label %122
115: ; preds = %92
%116 = load %struct.tm*, %struct.tm** %8
%117 = getelementptr inbounds %struct.tm, %struct.tm* %116, i32 0, i32 4
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = add nsw i32 %119, 100
%121 = trunc i32 %120 to i8
store i8 %121, i8* %117
br label %122
122: ; preds = %115, %92
br label %123
123: ; preds = %122, %17
%124 = load %struct.tm*, %struct.tm** %8
%125 = getelementptr inbounds %struct.tm, %struct.tm* %124, i32 0, i32 5
store i32 -1, i32* %125
%126 = load %struct.tm*, %struct.tm** %8
%127 = call i32 @mktime(%struct.tm* %126)
%128 = load %struct.timeval*, %struct.timeval** %6
%129 = getelementptr inbounds %struct.timeval, %struct.timeval* %128, i64 1
%130 = getelementptr inbounds %struct.timeval, %struct.timeval* %129, i32 0, i32 0
store i32 %127, i32* %130
%131 = load %struct.timeval*, %struct.timeval** %6
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %131, i64 0
%133 = getelementptr inbounds %struct.timeval, %struct.timeval* %132, i32 0, i32 0
store i32 %127, i32* %133
%134 = load %struct.timeval*, %struct.timeval** %6
%135 = getelementptr inbounds %struct.timeval, %struct.timeval* %134, i64 0
%136 = getelementptr inbounds %struct.timeval, %struct.timeval* %135, i32 0, i32 0
%137 = load i32, i32* %136
%138 = icmp eq i32 %137, -1
br i1 %138, label %139, label %141
139: ; preds = %123
%140 = call i32 @errx(i32 1, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %141
141: ; preds = %139, %123
%142 = load %struct.timeval*, %struct.timeval** %6
%143 = getelementptr inbounds %struct.timeval, %struct.timeval* %142, i64 1
%144 = getelementptr inbounds %struct.timeval, %struct.timeval* %143, i32 0, i32 1
store i64 0, i64* %144
%145 = load %struct.timeval*, %struct.timeval** %6
%146 = getelementptr inbounds %struct.timeval, %struct.timeval* %145, i64 0
%147 = getelementptr inbounds %struct.timeval, %struct.timeval* %146, i32 0, i32 1
store i64 0, i64* %147
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
%struct.tm = type { i8, i8, i8, i8, i8, i32 }
@.str = [10 x i8] c"localtime\00"
@.str.1 = [57 x i8] c"out of range or illegal time specification: MMDDhhmm[yy]\00"
define void @stime_arg2(i8* nocapture %0, i32 %1, %struct.timeval* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%7 = load i32, i32* %6
store i32 %7, i32* %4
%8 = call %struct.tm* @localtime(i32* %4)
%9 = icmp eq %struct.tm* %8, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @err(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load i8, i8* %0
%14 = mul i8 %13, 10
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%18 = getelementptr inbounds i8, i8* %0, i64 2
%19 = add i8 %16, -17
%20 = add i8 %19, %14
store i8 %20, i8* %17
%21 = load i8, i8* %18
%22 = mul i8 %21, 10
%23 = getelementptr inbounds i8, i8* %0, i64 3
%24 = load i8, i8* %23
%25 = add i8 %24, -16
%26 = add i8 %25, %22
%27 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 4
%29 = load i8, i8* %28
%30 = mul i8 %29, 10
%31 = getelementptr inbounds i8, i8* %0, i64 5
%32 = load i8, i8* %31
%33 = add i8 %32, -16
%34 = add i8 %33, %30
%35 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
store i8 %34, i8* %35
%36 = getelementptr inbounds i8, i8* %0, i64 6
%37 = load i8, i8* %36
%38 = mul i8 %37, 10
%39 = getelementptr inbounds i8, i8* %0, i64 7
%40 = load i8, i8* %39
%41 = add i8 %40, -16
%42 = add i8 %41, %38
%43 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
store i8 %42, i8* %43
%44 = icmp eq i32 %1, 0
br i1 %44, label %57, label %45
45: ; preds = %12
%46 = getelementptr inbounds i8, i8* %0, i64 8
%47 = load i8, i8* %46
%48 = mul i8 %47, 10
%49 = getelementptr inbounds i8, i8* %0, i64 9
%50 = load i8, i8* %49
%51 = add i8 %48, %50
%52 = add i8 %51, -16
%53 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
store i8 %52, i8* %53
%54 = icmp slt i8 %52, 39
br i1 %54, label %55, label %57
55: ; preds = %45
%56 = add i8 %51, 84
store i8 %56, i8* %53
br label %57
57: ; preds = %45, %55, %12
%58 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
store i32 -1, i32* %58
%59 = call i32 @mktime(%struct.tm* %8)
%60 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 1, i32 0
store i32 %59, i32* %60
store i32 %59, i32* %6
%61 = icmp eq i32 %59, -1
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = call i32 @errx(i32 1, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %64
64: ; preds = %62, %57
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 1, i32 1
store i64 0, i64* %65
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i64 0, i64* %66
ret void
}