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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int getpid();
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ system(char *);
long int GetNowTime(void) {
  FILE *pIn;
  char cmd[1000], nowFile[1000], nowTime[1000];
  long int now = 0;
  int pid = getpid();
  sprintf(nowFile, "%s/now.%d", "/tmp", pid);
  sprintf(cmd, "date +%%FT%%H:%%M:%%S > %s", nowFile);
  system(cmd);
  pIn = fopen(nowFile, "r");
  fscanf(pIn, "%s", nowTime);
  fclose(pIn);
  sprintf(cmd, "date --date=%s +%%s > %s", nowTime, nowFile);
  system(cmd);
  pIn = fopen(nowFile, "r");
  fscanf(pIn, "%ld", &now);
  fclose(pIn);
  sprintf(cmd, "rm -f %s", nowFile);
  system(cmd);
  return now;
}


x86 assembly (clang, -O0):
<GetNowTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbe0,%rsp
movq   $0x0,-0xbd8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0xbdc(%rbp)
lea    -0x7e0(%rbp),%rdi
mov    -0xbdc(%rbp),%ecx
lea    0xe69(%rip),%rsi
lea    0xe6c(%rip),%rdx
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rdx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x3f0(%rbp),%rdi
call   1050 <system@plt>
lea    -0x7e0(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xbd0(%rbp),%rdx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0xbd0(%rbp),%rdx
lea    -0x7e0(%rbp),%rcx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x3f0(%rbp),%rdi
call   1050 <system@plt>
lea    -0x7e0(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdee(%rip),%rsi
lea    -0xbd8(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rdx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x3f0(%rbp),%rdi
call   1050 <system@plt>
mov    -0xbd8(%rbp),%rax
add    $0xbe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetNowTime>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbe0,%rsp
movq   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe79(%rip),%rsi
lea    0xe7c(%rip),%rdx
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe66(%rip),%rsi
lea    0x7f0(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r12,%rdi
call   1050 <system@plt>
lea    0xe5d(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe45(%rip),%rsi
lea    0x10(%rsp),%r13
mov    %rax,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe29(%rip),%rsi
mov    %r12,%rdi
mov    %r13,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r12,%rdi
call   1050 <system@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe15(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdfb(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r12,%rdi
call   1050 <system@plt>
mov    0x8(%rsp),%rax
add    $0xbe0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s/now.%d\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [27 x i8] c"date +%%FT%%H:%%M:%%S > %s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [25 x i8] c"date --date=%s +%%s > %s\00"
@.str.6 = [4 x i8] c"%ld\00"
@.str.7 = [9 x i8] c"rm -f %s\00"
define i64 @GetNowTime() {
%1 = alloca i32*
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca i64
%6 = alloca i32
store i64 0, i64* %5
%7 = call i32 (...) @getpid()
store i32 %7, i32* %6
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* %6
%10 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%15 = call i32 @system(i8* %14)
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %17, i32** %1
%18 = load i32*, i32** %1
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %19)
%21 = load i32*, i32** %1
%22 = call i32 @fclose(i32* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%26 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %24, i8* %25)
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%28 = call i32 @system(i8* %27)
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %30, i32** %1
%31 = load i32*, i32** %1
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %5)
%33 = load i32*, i32** %1
%34 = call i32 @fclose(i32* %33)
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%37 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%39 = call i32 @system(i8* %38)
%40 = load i64, i64* %5
ret i64 %40
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s/now.%d\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [27 x i8] c"date +%%FT%%H:%%M:%%S > %s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [25 x i8] c"date --date=%s +%%s > %s\00"
@.str.6 = [4 x i8] c"%ld\00"
@.str.7 = [9 x i8] c"rm -f %s\00"
define i64 @GetNowTime() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%9 = tail call i32 (...) @getpid()
%10 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = call i32 @system(i8* %5)
%13 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%15 = call i32 @fclose(i32* %13)
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %7, i8* %6)
%17 = call i32 @system(i8* %5)
%18 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i32*, i8*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %4)
%20 = call i32 @fclose(i32* %18)
%21 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%22 = call i32 @system(i8* %5)
%23 = load i64, i64* %4
ret i64 %23
}