#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 */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int getopt(int, char **, char *);
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int optind;
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strftime(char *, int, char const *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  bool use_utc = false;
  const char *format;
  char buf[4096];
  time_t current;
  struct tm *tm;
  int i, c;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "--help") == 0) {
      usage(argv[0]);
      return EXIT_SUCCESS;
    }
  }
  while ((c = getopt(argc, argv, "u")) != -1) {
    switch (c) {
    case 'u':
      use_utc = true;
      break;
    default:
      usage(argv[0]);
      return EXIT_FAILURE;
    }
  }
  current = time(NULL);
  tm = (use_utc) ? gmtime(&current) : localtime(&current);
  if (optind < argc) {
    if (argv[argc - 1][0] != '+') {
      return EXIT_FAILURE;
    }
    format = argv[argc - 1] + 1;
  } else {
    format = "%a %b %e %H:%M:%S %Z %Y";
  }
  if (strftime(buf, sizeof(buf), format, tm) == 0) {
    return EXIT_FAILURE;
  }
  puts(buf);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x1034(%rbp)
mov    -0x1034(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1214 <main+0x94>
mov    -0x10(%rbp),%rax
movslq -0x1034(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe31(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1387 <main+0x207>
jmp    1200 <main+0x80>
mov    -0x1034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1034(%rbp)
jmp    11aa <main+0x2a>
jmp    1219 <main+0x99>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xde0(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x1038(%rbp)
cmp    $0xffffffff,%eax
je     127d <main+0xfd>
mov    -0x1038(%rbp),%eax
sub    $0x75,%eax
jne    125b <main+0xdb>
jmp    124f <main+0xcf>
movl   $0x1,-0x14(%rbp)
jmp    1278 <main+0xf8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1387 <main+0x207>
jmp    1219 <main+0x99>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12ae <main+0x12e>
lea    -0x1024(%rbp),%rdi
call   1090 <gmtime@plt>
mov    %rax,-0x1040(%rbp)
jmp    12c1 <main+0x141>
lea    -0x1024(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rax
mov    %rax,-0x1030(%rbp)
mov    0x2d12(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    132d <main+0x1ad>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     130f <main+0x18f>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1387 <main+0x207>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1338 <main+0x1b8>
lea    0xcd5(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x1030(%rbp),%rcx
mov    $0x1000,%esi
call   1080 <strftime@plt>
cmp    $0x0,%rax
jne    136f <main+0x1ef>
mov    0x2c73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1387 <main+0x207>
lea    -0x1020(%rbp),%rdi
call   1040 <puts@plt>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1010,%rsp
mov    %rsi,%rbp
mov    %edi,%r15d
cmp    $0x1,%edi
jle    11cb <main+0x4b>
mov    %r15d,%r12d
mov    $0x1,%ebx
lea    0xe57(%rip),%r14
nopl   0x0(%rax)
mov    0x0(%rbp,%rbx,8),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     122a <main+0xaa>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x30>
mov    $0x1,%cl
lea    0xe33(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10a0 <getopt@plt>
xor    %ecx,%ecx
cmp    $0x75,%eax
je     11e0 <main+0x60>
cmp    $0xffffffff,%eax
jne    1218 <main+0x98>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
test   $0x1,%bl
je     1235 <main+0xb5>
call   1030 <localtime@plt>
jmp    123a <main+0xba>
mov    0x0(%rbp),%rdi
call   1070 <usage@plt>
mov    0x2db0(%rip),%rax
jmp    1291 <main+0x111>
mov    0x0(%rbp),%rdi
call   1070 <usage@plt>
jmp    1281 <main+0x101>
call   1090 <gmtime@plt>
mov    0x2da7(%rip),%rcx
cmp    %r15d,(%rcx)
jge    1259 <main+0xd9>
movslq %r15d,%rcx
mov    -0x8(%rbp,%rcx,8),%rdx
cmpb   $0x2b,(%rdx)
jne    128a <main+0x10a>
add    $0x1,%rdx
jmp    1260 <main+0xe0>
lea    0xda9(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x1000,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
test   %rax,%rax
je     128a <main+0x10a>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
mov    0x2d48(%rip),%rax
jmp    1291 <main+0x111>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"u\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.2 = [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 i32
%7 = alloca i8*
%8 = alloca [4096 x i8]
%9 = alloca i32
%10 = alloca %struct.tm*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %11
br label %13
13: ; preds = %32, %2
%14 = load i32, i32* %11
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %35
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @usage(i8* %28)
%30 = load i32, i32* @EXIT_SUCCESS
store i32 %30, i32* %3
br label %98
31: ; preds = %17
br label %32
32: ; preds = %31
%33 = load i32, i32* %11
%34 = add nsw i32 %33, 1
store i32 %34, i32* %11
br label %13
35: ; preds = %13
br label %36
36: ; preds = %50, %35
%37 = load i32, i32* %4
%38 = load i8**, i8*** %5
%39 = call i32 @getopt(i32 %37, i8** %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %39, i32* %12
%40 = icmp ne i32 %39, -1
br i1 %40, label %41, label %51
41: ; preds = %36
%42 = load i32, i32* %12
switch i32 %42, label %44 [
i32 117, label %43
]
43: ; preds = %41
store i32 1, i32* %6
br label %50
44: ; preds = %41
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @usage(i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %98
50: ; preds = %43
br label %36
51: ; preds = %36
%52 = call i32 @time(i32* null)
store i32 %52, i32* %9
%53 = load i32, i32* %6
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call %struct.tm* @gmtime(i32* %9)
br label %59
57: ; preds = %51
%58 = call %struct.tm* @localtime(i32* %9)
br label %59
59: ; preds = %57, %55
%60 = phi %struct.tm* [ %56, %55 ], [ %58, %57 ]
store %struct.tm* %60, %struct.tm** %10
%61 = load i32, i32* @optind
%62 = load i32, i32* %4
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %85
64: ; preds = %59
%65 = load i8**, i8*** %5
%66 = load i32, i32* %4
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %65, i64 %68
%70 = load i8*, i8** %69
%71 = getelementptr inbounds i8, i8* %70, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 43
br i1 %74, label %75, label %77
75: ; preds = %64
%76 = load i32, i32* @EXIT_FAILURE
store i32 %76, i32* %3
br label %98
77: ; preds = %64
%78 = load i8**, i8*** %5
%79 = load i32, i32* %4
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %78, i64 %81
%83 = load i8*, i8** %82
%84 = getelementptr inbounds i8, i8* %83, i64 1
store i8* %84, i8** %7
br label %86
85: ; preds = %59
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %86
86: ; preds = %85, %77
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%88 = load i8*, i8** %7
%89 = load %struct.tm*, %struct.tm** %10
%90 = call i64 @strftime(i8* %87, i32 4096, i8* %88, %struct.tm* %89)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %86
%93 = load i32, i32* @EXIT_FAILURE
store i32 %93, i32* %3
br label %98
94: ; preds = %86
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%96 = call i32 @puts(i8* %95)
%97 = load i32, i32* @EXIT_SUCCESS
store i32 %97, i32* %3
br label %98
98: ; preds = %94, %92, %75, %44, %25
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [2 x i8] c"u\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.2 = [24 x i8] c"%a %b %e %H:%M:%S %Z %Y\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %9, label %8
8: ; preds = %11, %2
br label %23
9: ; preds = %2
%10 = zext i32 %0 to i64
br label %13
11: ; preds = %13
%12 = icmp eq i64 %19, %10
br i1 %12, label %8, label %13
13: ; preds = %9, %11
%14 = phi i64 [ 1, %9 ], [ %19, %11 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %20, label %11
20: ; preds = %13
%21 = load i8*, i8** %1
%22 = tail call i32 @usage(i8* %21)
br label %54
23: ; preds = %8, %23
%24 = phi i1 [ false, %23 ], [ true, %8 ]
%25 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
switch i32 %25, label %26 [
i32 -1, label %29
i32 117, label %23
]
26: ; preds = %23
%27 = load i8*, i8** %1
%28 = tail call i32 @usage(i8* %27)
br label %54
29: ; preds = %23
%30 = tail call i32 @time(i32* null)
store i32 %30, i32* %4
br i1 %24, label %33, label %31
31: ; preds = %29
%32 = call %struct.tm* @gmtime(i32* %4)
br label %35
33: ; preds = %29
%34 = call %struct.tm* @localtime(i32* %4)
br label %35
35: ; preds = %33, %31
%36 = phi %struct.tm* [ %32, %31 ], [ %34, %33 ]
%37 = load i32, i32* @optind
%38 = icmp slt i32 %37, %0
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = add nsw i32 %0, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %1, i64 %41
%43 = load i8*, i8** %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 43
br i1 %45, label %46, label %54
46: ; preds = %39
%47 = getelementptr inbounds i8, i8* %43, i64 1
br label %48
48: ; preds = %35, %46
%49 = phi i8* [ %47, %46 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %35 ]
%50 = call i64 @strftime(i8* %5, i32 4096, i8* %49, %struct.tm* %36)
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %48
%53 = call i32 @puts(i8* %5)
br label %54
54: ; preds = %48, %39, %52, %26, %20
%55 = phi i32* [ @EXIT_SUCCESS, %20 ], [ @EXIT_FAILURE, %26 ], [ @EXIT_SUCCESS, %52 ], [ @EXIT_FAILURE, %39 ], [ @EXIT_FAILURE, %48 ]
%56 = load i32, i32* %55
ret i32 %56
}