#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 time_t;
struct tm {
  int dummy;
};
struct timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ ShowTime(int *);
int Weekday(int *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
struct tm *gmtime(int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strftime(char *, int, char *, struct tm *);
int time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t cur = time(NULL);
  printf("cur time is %ld\n", cur);
  struct tm *ptm = gmtime(&cur);
  char buf[64];
  if (strftime(buf, 64, "%u", ptm) != 0) {
    if (buf[0] == '7') {
      printf("%s\n", buf);
    }
  }
  for (int i = 0; i < 8; ++i) {
    cur += i * 24 * 60 * 60;
    ShowTime(&cur);
    printf(" weekend %d\n", Weekday(&cur));
  }
  struct timespec ts;
  clock_gettime(CLOCK_REALTIME, &ts);
  cur = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
  printf("cur time is %ld\n", cur);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1090 <gmtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x40,%esi
lea    0xe4a(%rip),%rdx
call   1080 <strftime@plt>
cmp    $0x0,%rax
je     11fa <main+0x8a>
movsbl -0x60(%rbp),%eax
cmp    $0x37,%eax
jne    11f5 <main+0x85>
lea    -0x60(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11fa <main+0x8a>
movl   $0x0,-0x64(%rbp)
cmpl   $0x8,-0x64(%rbp)
jge    124b <main+0xdb>
imul   $0x18,-0x64(%rbp),%eax
imul   $0x3c,%eax,%eax
imul   $0x3c,%eax,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <ShowTime@plt>
lea    -0x14(%rbp),%rdi
call   1040 <Weekday@plt>
mov    %eax,%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1201 <main+0x91>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x3e8,-0x70(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x6c(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x4(%rsp)
lea    0xe67(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x4(%rsp),%rdi
call   10a0 <gmtime@plt>
lea    0xe5e(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1090 <strftime@plt>
test   %rax,%rax
je     11db <main+0x5b>
cmpb   $0x37,0x10(%rsp)
jne    11db <main+0x5b>
lea    0x10(%rsp),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
lea    0xe1d(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x15180,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x2a300,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x3f480,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x54600,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x69780,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x7e900,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x93a80,0x4(%rsp)
mov    %rbx,%rdi
call   1060 <ShowTime@plt>
mov    %rbx,%rdi
call   1050 <Weekday@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <clock_gettime@plt>
imul   $0x3e8,0x8(%rsp),%eax
movslq 0xc(%rsp),%rcx
imul   $0x431bde83,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rsi
add    %ecx,%esi
add    %eax,%esi
mov    %esi,0x4(%rsp)
lea    0xcc0(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timespec = type { i32, i32 }
@.str = [17 x i8] c"cur time is %ld\0A\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [13 x i8] c" weekend %d\0A\00"
@CLOCK_REALTIME = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca [64 x i8]
%9 = alloca i32
%10 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @time(i32* null)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %14, %struct.tm** %7
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%16 = load %struct.tm*, %struct.tm** %7
%17 = call i64 @strftime(i8* %15, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %2
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 55
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %19
br label %28
28: ; preds = %27, %2
store i32 0, i32* %9
br label %29
29: ; preds = %42, %28
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 8
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load i32, i32* %9
%34 = mul nsw i32 %33, 24
%35 = mul nsw i32 %34, 60
%36 = mul nsw i32 %35, 60
%37 = load i32, i32* %6
%38 = add nsw i32 %37, %36
store i32 %38, i32* %6
%39 = call i32 @ShowTime(i32* %6)
%40 = call i32 @Weekday(i32* %6)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %32
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %29
45: ; preds = %29
%46 = load i32, i32* @CLOCK_REALTIME
%47 = call i32 @clock_gettime(i32 %46, %struct.timespec* %10)
%48 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%49 = load i32, i32* %48
%50 = mul nsw i32 %49, 1000
%51 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%52 = load i32, i32* %51
%53 = sdiv i32 %52, 1000000
%54 = add nsw i32 %50, %53
store i32 %54, i32* %6
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %55)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [17 x i8] c"cur time is %ld\0A\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.3 = [13 x i8] c" weekend %d\0A\00"
@CLOCK_REALTIME = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [64 x i8]
%5 = alloca %struct.timespec
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call %struct.tm* @gmtime(i32* %3)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%11 = call i64 @strftime(i8* %10, i32 64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %9)
%12 = icmp ne i64 %11, 0
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 55
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @puts(i8* %10)
br label %18
18: ; preds = %16, %2
%19 = call i32 @ShowTime(i32* %3)
%20 = call i32 @Weekday(i32* %3)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 86400
store i32 %23, i32* %3
%24 = call i32 @ShowTime(i32* %3)
%25 = call i32 @Weekday(i32* %3)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 172800
store i32 %28, i32* %3
%29 = call i32 @ShowTime(i32* %3)
%30 = call i32 @Weekday(i32* %3)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 259200
store i32 %33, i32* %3
%34 = call i32 @ShowTime(i32* %3)
%35 = call i32 @Weekday(i32* %3)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 345600
store i32 %38, i32* %3
%39 = call i32 @ShowTime(i32* %3)
%40 = call i32 @Weekday(i32* %3)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 432000
store i32 %43, i32* %3
%44 = call i32 @ShowTime(i32* %3)
%45 = call i32 @Weekday(i32* %3)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 518400
store i32 %48, i32* %3
%49 = call i32 @ShowTime(i32* %3)
%50 = call i32 @Weekday(i32* %3)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 604800
store i32 %53, i32* %3
%54 = call i32 @ShowTime(i32* %3)
%55 = call i32 @Weekday(i32* %3)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = bitcast %struct.timespec* %5 to i8*
%58 = load i32, i32* @CLOCK_REALTIME
%59 = call i32 @clock_gettime(i32 %58, %struct.timespec* %5)
%60 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%61 = load i32, i32* %60
%62 = mul nsw i32 %61, 1000
%63 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%64 = load i32, i32* %63
%65 = sdiv i32 %64, 1000000
%66 = add nsw i32 %65, %62
store i32 %66, i32* %3
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %66)
ret i32 0
}