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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *strptime(char *, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  struct tm *tm_ptr, timestruct;
  time_t the_time;
  char buf[256];
  char *result;
  (void)time(&the_time);
  tm_ptr = localtime(&the_time);
  strftime(buf, 256, "%A %d %B, %I:%S %p", tm_ptr);
  printf("strftime gives: %s\n", buf);
  strcpy(buf, "Thu 26 July 2007, 17:53 will do fine");
  printf("calling strptime with: %s\n", buf);
  tm_ptr = &timestruct;
  result = strptime(buf, "%a %d %b %Y, %R", tm_ptr);
  printf("strptime consumed up to: %s\n", result);
  printf("strptime gives:\n");
  printf("date: %02d/%02d/%02d\n", tm_ptr->tm_year % 100, tm_ptr->tm_mon + 1,
         tm_ptr->tm_mday);
  printf("time: %02d:%02d\n", tm_ptr->tm_hour, tm_ptr->tm_min);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2c(%rbp),%rdi
call   1060 <time@plt>
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xe51(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x130(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x130(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe5c(%rip),%rsi
call   1090 <strptime@plt>
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x120,%rsp
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe5c(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
lea    0xe53(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe76(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   10a0 <strptime@plt>
lea    0xe72(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
movslq 0x8(%rsp),%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
add    $0x1,%edx
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    0x18(%rsp),%edx
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [19 x i8] c"%A %d %B, %I:%S %p\00"
@.str.1 = [20 x i8] c"strftime gives: %s\0A\00"
@.str.2 = [37 x i8] c"Thu 26 July 2007, 17:53 will do fine\00"
@.str.3 = [27 x i8] c"calling strptime with: %s\0A\00"
@.str.4 = [16 x i8] c"%a %d %b %Y, %R\00"
@.str.5 = [29 x i8] c"strptime consumed up to: %s\0A\00"
@.str.6 = [17 x i8] c"strptime gives:\0A\00"
@.str.7 = [22 x i8] c"date: %02d/%02d/%02d\0A\00"
@.str.8 = [17 x i8] c"time: %02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i8*
store i32 0, i32* %1
%7 = call i32 @time(i32* %4)
%8 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %8, %struct.tm** %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = load %struct.tm*, %struct.tm** %2
%11 = call i32 @strftime(i8* %9, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %16)
store %struct.tm* %3, %struct.tm** %2
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %2
%20 = call i8* @strptime(i8* %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%24 = load %struct.tm*, %struct.tm** %2
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = srem i32 %26, 100
%28 = load %struct.tm*, %struct.tm** %2
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
%32 = load %struct.tm*, %struct.tm** %2
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 2
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %27, i32 %31, i32 %34)
%36 = load %struct.tm*, %struct.tm** %2
%37 = getelementptr inbounds %struct.tm, %struct.tm* %36, i32 0, i32 3
%38 = load i32, i32* %37
%39 = load %struct.tm*, %struct.tm** %2
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 4
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %38, i32 %41)
%43 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [19 x i8] c"%A %d %B, %I:%S %p\00"
@.str.1 = [20 x i8] c"strftime gives: %s\0A\00"
@.str.2 = [37 x i8] c"Thu 26 July 2007, 17:53 will do fine\00"
@.str.3 = [27 x i8] c"calling strptime with: %s\0A\00"
@.str.4 = [16 x i8] c"%a %d %b %Y, %R\00"
@.str.5 = [29 x i8] c"strptime consumed up to: %s\0A\00"
@.str.7 = [22 x i8] c"date: %02d/%02d/%02d\0A\00"
@.str.8 = [17 x i8] c"time: %02d:%02d\0A\00"
@str = [16 x i8] c"strptime gives:\00"
define i32 @main() {
%1 = alloca %struct.tm
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = bitcast %struct.tm* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @time(i32* %2)
%8 = call %struct.tm* @localtime(i32* %2)
%9 = call i32 @strftime(i8* %6, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%13 = call i8* @strptime(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%16 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
%17 = load i32, i32* %16
%18 = srem i32 %17, 100
%19 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 %21, i32 %23)
%25 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %26, i32 %28)
%30 = call i32 @exit(i32 0)
unreachable
}