#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 */
struct tm {
  int tm_isdst;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ err_exit(char *, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
char *my_strftime(char *, struct tm *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ *strptime(char *, char *, struct tm *);
int main(int argc, char *argv[]) {
  struct tm tm;
  if (argc < 3 || strcmp(argv[1], "--help") == 0) {
    err_exit("Usage: %s input-date-time format-string [out-format]\n", argv[0]);
  }
  memset(&tm, 0, sizeof(struct tm));
  if (strptime(argv[1], argv[2], &tm) == NULL) {
    err_exit("Erron on strptime, %s\n", strerror(errno));
  }
  tm.tm_isdst = -1;
  if (argc > 3) {
    printf("%s\n", my_strftime(argv[3], &tm));
  } else {
    printf("%s\n", my_strftime(NULL, &tm));
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11be <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11d1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3b(%rip),%rdi
call   1070 <err_exit@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x18(%rbp),%rdx
call   10a0 <strptime@plt>
cmp    $0x0,%rax
jne    1221 <main+0xa1>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rsi
lea    0xe21(%rip),%rdi
call   1070 <err_exit@plt>
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1257 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <my_strftime@plt>
mov    %rax,%rsi
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
jmp    1273 <main+0xf3>
xor    %eax,%eax
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1030 <my_strftime@plt>
mov    %rax,%rsi
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
cmp    $0x3,%edi
jl     11a8 <main+0x28>
mov    0x8(%rbx),%rdi
lea    0xe62(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11b7 <main+0x37>
mov    (%rbx),%rsi
lea    0xe55(%rip),%rdi
call   1070 <err_exit@plt>
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    %rbp,%rdx
call   10a0 <strptime@plt>
test   %rax,%rax
jne    11fd <main+0x7d>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe48(%rip),%rdi
mov    %rax,%rsi
call   1070 <err_exit@plt>
movl   $0xffffffff,0x8(%rsp)
ff
cmp    $0x4,%r14d
jl     1211 <main+0x91>
mov    0x18(%rbx),%rdi
jmp    1213 <main+0x93>
xor    %edi,%edi
lea    0x8(%rsp),%rsi
call   1030 <my_strftime@plt>
lea    0xe2c(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [54 x i8] c"Usage: %s input-date-time format-string [out-format]\0A\00"
@.str.2 = [23 x i8] c"Erron on strptime, %s\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tm
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @err_exit(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %15, %9
%21 = call i32 @memset(%struct.tm* %6, i32 0, i32 4)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @strptime(i8* %24, i8* %27, %struct.tm* %6)
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %20
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %30, %20
%35 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
store i32 -1, i32* %35
%36 = load i32, i32* %4
%37 = icmp sgt i32 %36, 3
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i8* @my_strftime(i8* %41, %struct.tm* %6)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %47
44: ; preds = %34
%45 = call i8* @my_strftime(i8* null, %struct.tm* %6)
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %38
%48 = load i32, i32* @EXIT_SUCCESS
%49 = call i32 @exit(i32 %48)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [54 x i8] c"Usage: %s input-date-time format-string [out-format]\0A\00"
@.str.2 = [23 x i8] c"Erron on strptime, %s\0A\00"
@errno = global i32 0
@.str.3 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6, %2
%12 = load i8*, i8** %1
%13 = tail call i32 @err_exit(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %6
%15 = call i32 @memset(%struct.tm* %3, i32 0, i32 4)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32* @strptime(i8* %17, i8* %19, %struct.tm* %3)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %22, %14
%27 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 -1, i32* %27
%28 = icmp sgt i32 %0, 3
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
br label %32
32: ; preds = %26, %29
%33 = phi i8* [ %31, %29 ], [ null, %26 ]
%34 = call i8* @my_strftime(i8* %33, %struct.tm* %3)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_SUCCESS
%37 = call i32 @exit(i32 %36)
unreachable
}