#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 char time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
  int tm_wday;
  int tm_yday;
};

/* Variables and functions */
struct tm *localtime(char *);
char mktime(struct tm *);
int /*<<< orphan*/ print_tm(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int strtol(char *, char **, int);
char time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s [+/-] [N[Y/M/D/H/m/S/w/y]]\n", argv[0]);
    return 0;
  }
  int ret = 0;
  time_t now = time(NULL);
  printf("now = %ld\n", now);
  struct tm *tm_now = localtime(&now);
  print_tm(tm_now);
  int shift = 0;
  char *endptr = 0;
  shift = strtol(argv[1], &endptr, 10);
  switch (*endptr) {
  case 'Y':
    tm_now->tm_year += shift;
    break;
  case 'M':
    tm_now->tm_mon += shift;
    break;
  case 'D':
  case 'd':
    tm_now->tm_mday += shift;
    break;
  case 'H':
  case 'h':
    tm_now->tm_hour += shift;
    break;
  case 'm':
    tm_now->tm_min += shift;
    break;
  case 's':
  case 'S':
    tm_now->tm_sec += shift;
    break;
  case 'w':
  case 'W':
    tm_now->tm_wday += shift;
    break;
  case 'y':
    tm_now->tm_yday += shift;
    break;
  default:
    printf("unkonwn postfix %c", *endptr);
    break;
  }
  print_tm(tm_now);
  time_t tick = mktime(tm_now);
  printf("tick = %ld\n", tick);
  print_tm(tm_now);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xf4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1311 <main+0x1b1>
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
mov    %eax,%edi
call   1070 <time@plt>
mov    %al,%cl
mov    -0x44(%rbp),%eax
mov    %cl,-0x15(%rbp)
movsbl -0x15(%rbp),%esi
lea    0xf37(%rip),%rdi
call   1040 <printf@plt>
lea    -0x15(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <print_tm@plt>
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x35,%eax
ja     12c5 <main+0x165>
mov    -0x40(%rbp),%rax
lea    0xdd2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x10(%rax),%ecx
mov    %ecx,0x10(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x14(%rax),%ecx
mov    %ecx,0x14(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x18(%rax),%ecx
mov    %ecx,0x18(%rax)
jmp    12da <main+0x17a>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
add    0x1c(%rax),%ecx
mov    %ecx,0x1c(%rax)
jmp    12da <main+0x17a>
mov    -0x30(%rbp),%rax
movsbl (%rax),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <print_tm@plt>
mov    -0x20(%rbp),%rdi
call   1080 <mktime@plt>
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <print_tm@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1185 <main+0x25>
mov    (%rbx),%rsi
lea    0xf5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1258 <main+0xf8>
xor    %edi,%edi
call   1070 <time@plt>
mov    %al,0xf(%rsp)
movsbl %al,%esi
lea    0xf64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <print_tm@plt>
movq   $0x0,0x10(%rsp)
mov    0x8(%rbx),%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    0x10(%rsp),%rcx
movsbl (%rcx),%esi
lea    -0x44(%rsi),%ecx
cmp    $0x35,%ecx
ja     120a <main+0xaa>
lea    0xe17(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    %eax,0x8(%r14)
jmp    122f <main+0xcf>
add    %eax,0xc(%r14)
jmp    122f <main+0xcf>
add    %eax,0x14(%r14)
jmp    122f <main+0xcf>
add    %eax,0x18(%r14)
jmp    122f <main+0xcf>
lea    0xef8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122f <main+0xcf>
add    %eax,0x4(%r14)
jmp    122f <main+0xcf>
add    %eax,(%r14)
jmp    122f <main+0xcf>
add    %eax,0x10(%r14)
jmp    122f <main+0xcf>
add    %eax,0x1c(%r14)
mov    %r14,%rdi
call   1060 <print_tm@plt>
mov    %r14,%rdi
call   1080 <mktime@plt>
movsbl %al,%esi
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1060 <print_tm@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [38 x i8] c"Usage: %s [+/-] [N[Y/M/D/H/m/S/w/y]]\0A\00"
@.str.1 = [11 x i8] c"now = %ld\0A\00"
@.str.2 = [19 x i8] c"unkonwn postfix %c\00"
@.str.3 = [12 x i8] c"tick = %ld\0A\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 %struct.tm*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 0, i32* %3
br label %97
19: ; preds = %2
store i32 0, i32* %6
%20 = call signext i8 @time(i32* null)
store i8 %20, i8* %7
%21 = load i8, i8* %7
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call %struct.tm* @localtime(i8* %7)
store %struct.tm* %24, %struct.tm** %8
%25 = load %struct.tm*, %struct.tm** %8
%26 = call i32 @print_tm(%struct.tm* %25)
store i32 0, i32* %9
store i8* null, i8** %10
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strtol(i8* %29, i8** %10, i32 10)
store i32 %30, i32* %9
%31 = load i8*, i8** %10
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
switch i32 %33, label %82 [
i32 89, label %34
i32 77, label %40
i32 68, label %46
i32 100, label %46
i32 72, label %52
i32 104, label %52
i32 109, label %58
i32 115, label %64
i32 83, label %64
i32 119, label %70
i32 87, label %70
i32 121, label %76
]
34: ; preds = %19
%35 = load i32, i32* %9
%36 = load %struct.tm*, %struct.tm** %8
%37 = getelementptr inbounds %struct.tm, %struct.tm* %36, i32 0, i32 0
%38 = load i32, i32* %37
%39 = add nsw i32 %38, %35
store i32 %39, i32* %37
br label %87
40: ; preds = %19
%41 = load i32, i32* %9
%42 = load %struct.tm*, %struct.tm** %8
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 1
%44 = load i32, i32* %43
%45 = add nsw i32 %44, %41
store i32 %45, i32* %43
br label %87
46: ; preds = %19, %19
%47 = load i32, i32* %9
%48 = load %struct.tm*, %struct.tm** %8
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 2
%50 = load i32, i32* %49
%51 = add nsw i32 %50, %47
store i32 %51, i32* %49
br label %87
52: ; preds = %19, %19
%53 = load i32, i32* %9
%54 = load %struct.tm*, %struct.tm** %8
%55 = getelementptr inbounds %struct.tm, %struct.tm* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = add nsw i32 %56, %53
store i32 %57, i32* %55
br label %87
58: ; preds = %19
%59 = load i32, i32* %9
%60 = load %struct.tm*, %struct.tm** %8
%61 = getelementptr inbounds %struct.tm, %struct.tm* %60, i32 0, i32 4
%62 = load i32, i32* %61
%63 = add nsw i32 %62, %59
store i32 %63, i32* %61
br label %87
64: ; preds = %19, %19
%65 = load i32, i32* %9
%66 = load %struct.tm*, %struct.tm** %8
%67 = getelementptr inbounds %struct.tm, %struct.tm* %66, i32 0, i32 5
%68 = load i32, i32* %67
%69 = add nsw i32 %68, %65
store i32 %69, i32* %67
br label %87
70: ; preds = %19, %19
%71 = load i32, i32* %9
%72 = load %struct.tm*, %struct.tm** %8
%73 = getelementptr inbounds %struct.tm, %struct.tm* %72, i32 0, i32 6
%74 = load i32, i32* %73
%75 = add nsw i32 %74, %71
store i32 %75, i32* %73
br label %87
76: ; preds = %19
%77 = load i32, i32* %9
%78 = load %struct.tm*, %struct.tm** %8
%79 = getelementptr inbounds %struct.tm, %struct.tm* %78, i32 0, i32 7
%80 = load i32, i32* %79
%81 = add nsw i32 %80, %77
store i32 %81, i32* %79
br label %87
82: ; preds = %19
%83 = load i8*, i8** %10
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %82, %76, %70, %64, %58, %52, %46, %40, %34
%88 = load %struct.tm*, %struct.tm** %8
%89 = call i32 @print_tm(%struct.tm* %88)
%90 = load %struct.tm*, %struct.tm** %8
%91 = call signext i8 @mktime(%struct.tm* %90)
store i8 %91, i8* %11
%92 = load i8, i8* %11
%93 = sext i8 %92 to i32
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %93)
%95 = load %struct.tm*, %struct.tm** %8
%96 = call i32 @print_tm(%struct.tm* %95)
store i32 0, i32* %3
br label %97
97: ; preds = %87, %14
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [38 x i8] c"Usage: %s [+/-] [N[Y/M/D/H/m/S/w/y]]\0A\00"
@.str.1 = [11 x i8] c"now = %ld\0A\00"
@.str.2 = [19 x i8] c"unkonwn postfix %c\00"
@.str.3 = [12 x i8] c"tick = %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %62
9: ; preds = %2
%10 = tail call signext i8 @time(i32* null)
store i8 %10, i8* %3
%11 = sext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call %struct.tm* @localtime(i8* %3)
%14 = call i32 @print_tm(%struct.tm* %13)
%15 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i8** %4, i32 10)
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %54 [
i32 89, label %22
i32 77, label %26
i32 68, label %30
i32 100, label %30
i32 72, label %34
i32 104, label %34
i32 109, label %38
i32 115, label %42
i32 83, label %42
i32 119, label %46
i32 87, label %46
i32 121, label %50
]
22: ; preds = %9
%23 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 0
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %18
store i32 %25, i32* %23
br label %56
26: ; preds = %9
%27 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 1
%28 = load i32, i32* %27
%29 = add nsw i32 %28, %18
store i32 %29, i32* %27
br label %56
30: ; preds = %9, %9
%31 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 2
%32 = load i32, i32* %31
%33 = add nsw i32 %32, %18
store i32 %33, i32* %31
br label %56
34: ; preds = %9, %9
%35 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 3
%36 = load i32, i32* %35
%37 = add nsw i32 %36, %18
store i32 %37, i32* %35
br label %56
38: ; preds = %9
%39 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 4
%40 = load i32, i32* %39
%41 = add nsw i32 %40, %18
store i32 %41, i32* %39
br label %56
42: ; preds = %9, %9
%43 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 5
%44 = load i32, i32* %43
%45 = add nsw i32 %44, %18
store i32 %45, i32* %43
br label %56
46: ; preds = %9, %9
%47 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 6
%48 = load i32, i32* %47
%49 = add nsw i32 %48, %18
store i32 %49, i32* %47
br label %56
50: ; preds = %9
%51 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 7
%52 = load i32, i32* %51
%53 = add nsw i32 %52, %18
store i32 %53, i32* %51
br label %56
54: ; preds = %9
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %56
56: ; preds = %54, %50, %46, %42, %38, %34, %30, %26, %22
%57 = call i32 @print_tm(%struct.tm* %13)
%58 = call signext i8 @mktime(%struct.tm* %13)
%59 = sext i8 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = call i32 @print_tm(%struct.tm* %13)
br label %62
62: ; preds = %56, %6
ret i32 0
}