#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 dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ bu_handle_version(int, char **);
struct tm *gmtime(int /*<<< orphan*/ *);
scalar_t__ has_arg(int, char **, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int set_time(char *, char **);
scalar_t__ strcmp(char *, char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (has_arg(argc, argv, "-h") || has_arg(argc, argv, "--help")) {
    puts("Usage: date [-u] [+FORMAT]");
    puts("       date [-u] MMDDhhmm[[CC]YY");
    puts("Print the current time in the specified FORMAT, or set the date.");
    return 1;
  }
  if (bu_handle_version(argc, argv)) {
    return 0;
  }
  char *format_str = NULL;
  char *date_str = NULL;
  int dash_u = 0;
  int should_set_time = 0;
  for (int i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-u") == 0) {
      dash_u = 1;
    } else if (argv[i][0] == '+') {
      format_str = argv[i];
      format_str++;
    } else {
      should_set_time = 1;
      date_str = argv[i];
    }
  }
  if (should_set_time) {
    return set_time(date_str, argv);
  }
  if (format_str == NULL) {
    format_str = "%a %b %e %H:%M:%S %Z %Y";
  }
  char *buf[200];
  time_t t;
  struct tm *current_time;
  t = time(NULL);
  if (dash_u) {
    current_time = gmtime(&t);
  } else {
    current_time = localtime(&t);
  }
  if (current_time == NULL) {
    perror(argv[0]);
    return 1;
  }
  if (strftime((char *)buf, sizeof(buf), format_str, current_time)) {
    puts((char *)buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x680,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe39(%rip),%rdx
call   1050 <has_arg@plt>
cmp    $0x0,%rax
jne    11f3 <main+0x53>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdx
call   1050 <has_arg@plt>
cmp    $0x0,%rax
je     1223 <main+0x83>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e4 <main+0x244>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10c0 <bu_handle_version@plt>
cmp    $0x0,%rax
je     1245 <main+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    13e4 <main+0x244>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    130c <main+0x16c>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdfe(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12a4 <main+0x104>
movl   $0x1,-0x24(%rbp)
jmp    12f9 <main+0x159>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    12dd <main+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    12f4 <main+0x154>
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    12f9 <main+0x159>
jmp    12fe <main+0x15e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126a <main+0xca>
cmpl   $0x0,-0x28(%rbp)
je     132b <main+0x18b>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <set_time@plt>
mov    %eax,-0x4(%rbp)
jmp    13e4 <main+0x244>
cmpq   $0x0,-0x18(%rbp)
jne    1341 <main+0x1a1>
lea    0xd4d(%rip),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x674(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1372 <main+0x1d2>
lea    -0x674(%rbp),%rdi
call   10b0 <gmtime@plt>
mov    %rax,-0x680(%rbp)
jmp    1385 <main+0x1e5>
lea    -0x674(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x680(%rbp)
cmpq   $0x0,-0x680(%rbp)
jne    13ab <main+0x20b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e4 <main+0x244>
lea    -0x670(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x680(%rbp),%rcx
mov    $0x640,%esi
call   1090 <strftime@plt>
cmp    $0x0,%rax
je     13dd <main+0x23d>
lea    -0x670(%rbp),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x680,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x668,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
lea    0xe43(%rip),%rdx
call   1050 <has_arg@plt>
test   %rax,%rax
jne    11dd <main+0x3d>
lea    0xe35(%rip),%rdx
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <has_arg@plt>
test   %rax,%rax
je     121a <main+0x7a>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
lea    0xe35(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x668,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
mov    %r12,%rsi
call   10c0 <bu_handle_version@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1206 <main+0x66>
cmp    $0x2,%ebp
jl     12b1 <main+0x111>
mov    %ebp,%ebx
xor    %eax,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%r14d
lea    0xe3d(%rip),%r15
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %ebp,%ebp
jmp    126f <main+0xcf>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r13d
add    $0x1,%r14
cmp    %r14,%rbx
je     12b8 <main+0x118>
mov    (%r12,%r14,8),%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1260 <main+0xc0>
mov    (%r12,%r14,8),%rax
cmpb   $0x2b,(%rax)
jne    12a0 <main+0x100>
add    $0x1,%rax
mov    %rax,%rbp
jmp    1266 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,0x10(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
jmp    1266 <main+0xc6>
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    12dd <main+0x13d>
cmpl   $0x0,0x18(%rsp)
je     12dd <main+0x13d>
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
add    $0x668,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <set_time@plt>
test   %rbp,%rbp
lea    0xda3(%rip),%r14
cmovne %rbp,%r14
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
test   %r13d,%r13d
je     1307 <main+0x167>
call   10b0 <gmtime@plt>
jmp    130c <main+0x16c>
call   1030 <localtime@plt>
test   %rax,%rax
je     1340 <main+0x1a0>
lea    0x20(%rsp),%rdi
mov    $0x640,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1090 <strftime@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1206 <main+0x66>
lea    0x20(%rsp),%rdi
call   1040 <puts@plt>
jmp    1206 <main+0x66>
mov    (%r12),%rdi
call   10a0 <perror@plt>
jmp    1201 <main+0x61>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [27 x i8] c"Usage: date [-u] [+FORMAT]\00"
@.str.3 = [33 x i8] c" date [-u] MMDDhhmm[[CC]YY\00"
@.str.4 = [65 x i8] c"Print the current time in the specified FORMAT, or set the date.\00"
@.str.5 = [3 x i8] c"-u\00"
@.str.6 = [24 x i8] c"%a %b %e %H:%M:%S %Z %Y\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [200 x i8*]
%12 = alloca i32
%13 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i64 @has_arg(i32 %14, i8** %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i64 @has_arg(i32 %19, i8** %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %18, %2
%24 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %115
27: ; preds = %18
%28 = load i32, i32* %4
%29 = load i8**, i8*** %5
%30 = call i64 @bu_handle_version(i32 %28, i8** %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %3
br label %115
33: ; preds = %27
store i8* null, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %34
34: ; preds = %73, %33
%35 = load i32, i32* %10
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %76
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %38
store i32 1, i32* %8
br label %72
47: ; preds = %38
%48 = load i8**, i8*** %5
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = getelementptr inbounds i8, i8* %52, i64 0
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 43
br i1 %56, label %57, label %65
57: ; preds = %47
%58 = load i8**, i8*** %5
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
store i8* %62, i8** %6
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %6
br label %71
65: ; preds = %47
store i32 1, i32* %9
%66 = load i8**, i8*** %5
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
store i8* %70, i8** %7
br label %71
71: ; preds = %65, %57
br label %72
72: ; preds = %71, %46
br label %73
73: ; preds = %72
%74 = load i32, i32* %10
%75 = add nsw i32 %74, 1
store i32 %75, i32* %10
br label %34
76: ; preds = %34
%77 = load i32, i32* %9
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %76
%80 = load i8*, i8** %7
%81 = load i8**, i8*** %5
%82 = call i32 @set_time(i8* %80, i8** %81)
store i32 %82, i32* %3
br label %115
83: ; preds = %76
%84 = load i8*, i8** %6
%85 = icmp eq i8* %84, null
br i1 %85, label %86, label %87
86: ; preds = %83
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8** %6
br label %87
87: ; preds = %86, %83
%88 = call i32 @time(i32* null)
store i32 %88, i32* %12
%89 = load i32, i32* %8
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call %struct.tm* @gmtime(i32* %12)
store %struct.tm* %92, %struct.tm** %13
br label %95
93: ; preds = %87
%94 = call %struct.tm* @localtime(i32* %12)
store %struct.tm* %94, %struct.tm** %13
br label %95
95: ; preds = %93, %91
%96 = load %struct.tm*, %struct.tm** %13
%97 = icmp eq %struct.tm* %96, null
br i1 %97, label %98, label %103
98: ; preds = %95
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i32 @perror(i8* %101)
store i32 1, i32* %3
br label %115
103: ; preds = %95
%104 = getelementptr inbounds [200 x i8*], [200 x i8*]* %11, i64 0, i64 0
%105 = bitcast i8** %104 to i8*
%106 = load i8*, i8** %6
%107 = load %struct.tm*, %struct.tm** %13
%108 = call i64 @strftime(i8* %105, i32 1600, i8* %106, %struct.tm* %107)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %103
%111 = getelementptr inbounds [200 x i8*], [200 x i8*]* %11, i64 0, i64 0
%112 = bitcast i8** %111 to i8*
%113 = call i32 @puts(i8* %112)
br label %114
114: ; preds = %110, %103
store i32 0, i32* %3
br label %115
115: ; preds = %114, %98, %79, %32, %23
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [27 x i8] c"Usage: date [-u] [+FORMAT]\00"
@.str.3 = [33 x i8] c" date [-u] MMDDhhmm[[CC]YY\00"
@.str.4 = [65 x i8] c"Print the current time in the specified FORMAT, or set the date.\00"
@.str.5 = [3 x i8] c"-u\00"
@.str.6 = [24 x i8] c"%a %b %e %H:%M:%S %Z %Y\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [200 x i8*]
%4 = alloca i32
%5 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7, %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
br label %74
14: ; preds = %7
%15 = tail call i64 @bu_handle_version(i32 %0, i8** %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %74
17: ; preds = %14
%18 = icmp sgt i32 %0, 1
br i1 %18, label %19, label %48
19: ; preds = %17
%20 = zext i32 %0 to i64
br label %23
21: ; preds = %39
%22 = icmp eq i32 %43, 0
br i1 %22, label %48, label %46
23: ; preds = %19, %39
%24 = phi i64 [ 1, %19 ], [ %44, %39 ]
%25 = phi i32 [ 0, %19 ], [ %43, %39 ]
%26 = phi i32 [ 0, %19 ], [ %42, %39 ]
%27 = phi i8* [ null, %19 ], [ %41, %39 ]
%28 = phi i8* [ null, %19 ], [ %40, %39 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 %24
%30 = load i8*, i8** %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %23
%34 = load i8*, i8** %29
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 43
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = getelementptr inbounds i8, i8* %34, i64 1
br label %39
39: ; preds = %33, %23, %37
%40 = phi i8* [ %38, %37 ], [ %28, %23 ], [ %28, %33 ]
%41 = phi i8* [ %27, %37 ], [ %27, %23 ], [ %34, %33 ]
%42 = phi i32 [ %26, %37 ], [ 1, %23 ], [ %26, %33 ]
%43 = phi i32 [ %25, %37 ], [ %25, %23 ], [ 1, %33 ]
%44 = add nuw nsw i64 %24, 1
%45 = icmp eq i64 %44, %20
br i1 %45, label %21, label %23
46: ; preds = %21
%47 = tail call i32 @set_time(i8* %41, i8** %1)
br label %74
48: ; preds = %17, %21
%49 = phi i32 [ %42, %21 ], [ 0, %17 ]
%50 = phi i8* [ %40, %21 ], [ null, %17 ]
%51 = icmp eq i8* %50, null
%52 = select i1 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %50
%53 = bitcast [200 x i8*]* %3 to i8*
%54 = bitcast i32* %4 to i8*
%55 = tail call i32 @time(i32* null)
store i32 %55, i32* %4
%56 = icmp eq i32 %49, 0
br i1 %56, label %59, label %57
57: ; preds = %48
%58 = call %struct.tm* @gmtime(i32* %4)
br label %61
59: ; preds = %48
%60 = call %struct.tm* @localtime(i32* %4)
br label %61
61: ; preds = %59, %57
%62 = phi %struct.tm* [ %58, %57 ], [ %60, %59 ]
%63 = icmp eq %struct.tm* %62, null
br i1 %63, label %64, label %67
64: ; preds = %61
%65 = load i8*, i8** %1
%66 = call i32 @perror(i8* %65)
br label %72
67: ; preds = %61
%68 = call i64 @strftime(i8* %53, i32 1600, i8* %52, %struct.tm* %62)
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %67
%71 = call i32 @puts(i8* %53)
br label %72
72: ; preds = %67, %70, %64
%73 = phi i32 [ 1, %64 ], [ 0, %70 ], [ 0, %67 ]
br label %74
74: ; preds = %46, %72, %14, %10
%75 = phi i32 [ 1, %10 ], [ 0, %14 ], [ %47, %46 ], [ %73, %72 ]
ret i32 %75
}