#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*/ int32_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ dateToOffset(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getCustom(int, char **, int);
int getCustomCount(int);
int /*<<< orphan*/ printDayInformation(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int sub_date(int argc, char *argv[]) {
  const char *arg_date = NULL;
  int32_t offs = 0;
  int result = EXIT_SUCCESS;
  if (getCustomCount(argc) != 2) {
    fprintf(stderr, "date expects exactly one additional argument!\n");
    result = EXIT_FAILURE;
  }
  if (result != EXIT_FAILURE) {
    arg_date = getCustom(argc, argv, 1);
  }
  if (result != EXIT_FAILURE) {
    if (!dateToOffset(arg_date, &offs)) {
      fprintf(stderr, "Could not parse as a valid calendar date!\n"
                      "(Note: Gregorian dates must be in range 1828-04-07 to "
                      "2404-04-11.)\n");
      result = EXIT_FAILURE;
    }
  }
  if (result != EXIT_FAILURE) {
    printDayInformation(offs);
  }
  return result;
}


x86 assembly (clang, -O0):
<sub_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getCustomCount@plt>
cmp    $0x2,%eax
je     11ac <sub_date+0x5c>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%eax
je     11d3 <sub_date+0x83>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1040 <getCustom@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%eax
je     1221 <sub_date+0xd1>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <dateToOffset@plt>
cmp    $0x0,%eax
jne    121c <sub_date+0xcc>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    1221 <sub_date+0xd1>
mov    -0x20(%rbp),%eax
mov    0x2dad(%rip),%rcx
cmp    (%rcx),%eax
je     123b <sub_date+0xeb>
mov    -0x1c(%rbp),%edi
call   1070 <printDayInformation@plt>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_date>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
mov    0x2e65(%rip),%rax
mov    (%rax),%ebx
call   1030 <getCustomCount@plt>
cmp    $0x2,%eax
jne    118d <sub_date+0x3d>
mov    0x2e5a(%rip),%r15
mov    (%r15),%ecx
cmp    %ecx,%ebx
jne    11b8 <sub_date+0x68>
xor    %eax,%eax
cmp    %ecx,%ebx
je     11ab <sub_date+0x5b>
jmp    11ce <sub_date+0x7e>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <getCustom@plt>
mov    (%r15),%ecx
cmp    %ecx,%ebx
je     11ab <sub_date+0x5b>
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
call   1060 <dateToOffset@plt>
test   %eax,%eax
je     11ef <sub_date+0x9f>
cmp    (%r15),%ebx
je     11ab <sub_date+0x5b>
mov    0x4(%rsp),%edi
call   1070 <printDayInformation@plt>
jmp    11ab <sub_date+0x5b>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r15),%ebx
jmp    11ab <sub_date+0x5b>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [47 x i8] c"date expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [110 x i8] c"Could not parse as a valid calendar date!\0A(Note: Gregorian dates must be in range 1828-04-07 to 2404-04-11.)\0A\00"
define i32 @sub_date(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* null, i8** %5
store i32 0, i32* %6
%8 = load i32, i32* @EXIT_SUCCESS
store i32 %8, i32* %7
%9 = load i32, i32* %3
%10 = call i32 @getCustomCount(i32 %9)
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %7
br label %16
16: ; preds = %12, %2
%17 = load i32, i32* %7
%18 = load i32, i32* @EXIT_FAILURE
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i8**, i8*** %4
%23 = call i8* @getCustom(i32 %21, i8** %22, i32 1)
store i8* %23, i8** %5
br label %24
24: ; preds = %20, %16
%25 = load i32, i32* %7
%26 = load i32, i32* @EXIT_FAILURE
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = call i32 @dateToOffset(i8* %29, i32* %6)
%31 = icmp ne i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %7
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %24
%38 = load i32, i32* %7
%39 = load i32, i32* @EXIT_FAILURE
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* %6
%43 = call i32 @printDayInformation(i32 %42)
br label %44
44: ; preds = %41, %37
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [47 x i8] c"date expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [110 x i8] c"Could not parse as a valid calendar date!\0A(Note: Gregorian dates must be in range 1828-04-07 to 2404-04-11.)\0A\00"
define i32 @sub_date(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = load i32, i32* @EXIT_SUCCESS
%6 = tail call i32 @getCustomCount(i32 %0)
%7 = icmp eq i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
br label %35
12: ; preds = %2
%13 = load i32, i32* @EXIT_FAILURE
%14 = icmp eq i32 %5, %13
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i8* @getCustom(i32 %0, i8** %1, i32 1)
%17 = load i32, i32* @EXIT_FAILURE
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ %17, %15 ], [ %13, %12 ]
%20 = phi i8* [ %16, %15 ], [ null, %12 ]
%21 = icmp eq i32 %5, %19
br i1 %21, label %35, label %22
22: ; preds = %18
%23 = call i32 @dateToOffset(i8* %20, i32* %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
br label %35
29: ; preds = %22
%30 = load i32, i32* @EXIT_FAILURE
%31 = icmp eq i32 %5, %30
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32, i32* %3
%34 = call i32 @printDayInformation(i32 %33)
br label %35
35: ; preds = %8, %18, %25, %32, %29
%36 = phi i32 [ %5, %32 ], [ %5, %29 ], [ %11, %8 ], [ %5, %18 ], [ %28, %25 ]
ret i32 %36
}