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

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char **printime_1_svc(char **msg, struct svc_req *req) {
  static char *result;
  static char tmp_char[100];
  time_t rawtime;
  FILE *f;
  f = fopen("/tmp/rpc_result", "a+");
  if (f == (FILE *)NULL) {
    strcpy(tmp_char, "Error");
    result = tmp_char;
    ;
    return (&result);
  }
  fprintf(f, "%s", *msg);
  fclose(f);
  time(&rawtime);
  sprintf(tmp_char, "Current time is :%s", ctime(&rawtime));
  result = tmp_char;
  return (&result);
}


x86 assembly (clang, -O0):
<printime_1_svc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d3 <printime_1_svc+0x63>
lea    0x2ed7(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2ec4(%rip),%rax
mov    %rax,0x2ead(%rip)
lea    0x2ea6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1234 <printime_1_svc+0xc4>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe45(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x1c(%rbp),%rdi
call   1070 <time@plt>
lea    -0x1c(%rbp),%rdi
call   1050 <ctime@plt>
mov    %rax,%rdx
lea    0x2e71(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1090 <sprintf@plt>
lea    0x2e5e(%rip),%rax
mov    %rax,0x2e47(%rip)
lea    0x2e40(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printime_1_svc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe82(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11d2 <printime_1_svc+0x62>
mov    %rax,%rbx
mov    (%r14),%rdi
mov    %rax,%rsi
call   1060 <fputs@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
mov    %rbx,%rdi
call   1050 <ctime@plt>
lea    0x2ebf(%rip),%rdi
lea    0xe51(%rip),%rsi
mov    %rax,%rdx
call   1090 <sprintf@plt>
jmp    11e5 <printime_1_svc+0x75>
lea    0x2ea7(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2e94(%rip),%rax
mov    %rax,0x2e7d(%rip)
lea    0x2e76(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.svc_req = type { i32 }
@printime_1_svc.result = internal global i8* null
@printime_1_svc.tmp_char = internal global [100 x i8] zeroinitializer
@.str = [16 x i8] c"/tmp/rpc_result\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [6 x i8] c"Error\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [20 x i8] c"Current time is :%s\00"
define i8** @printime_1_svc(i8** %0, %struct.svc_req* %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca %struct.svc_req*
%6 = alloca i32
%7 = alloca i32*
store i8** %0, i8*** %4
store %struct.svc_req* %1, %struct.svc_req** %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = load i32*, i32** %7
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @strcpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8** @printime_1_svc.result
store i8** @printime_1_svc.result, i8*** %3
br label %23
13: ; preds = %2
%14 = load i32*, i32** %7
%15 = load i8**, i8*** %4
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** %7
%19 = call i32 @fclose(i32* %18)
%20 = call i32 @time(i32* %6)
%21 = call i8* @ctime(i32* %6)
%22 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %21)
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8** @printime_1_svc.result
store i8** @printime_1_svc.result, i8*** %3
br label %23
23: ; preds = %13, %11
%24 = load i8**, i8*** %3
ret i8** %24
}

LLVM IR (-O2):
%struct.svc_req = type { i32 }
@printime_1_svc.result = internal global i8* null
@printime_1_svc.tmp_char = internal global [100 x i8] zeroinitializer
@.str = [16 x i8] c"/tmp/rpc_result\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [6 x i8] c"Error\00"
@.str.4 = [20 x i8] c"Current time is :%s\00"
define i8** @printime_1_svc(i8** nocapture %0, %struct.svc_req* nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @strcpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = load i8*, i8** %0
%11 = tail call i32 @fputs(i8* %10, i32* %5)
%12 = tail call i32 @fclose(i32* %5)
%13 = call i32 @time(i32* %3)
%14 = call i8* @ctime(i32* %3)
%15 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %9, %7
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @printime_1_svc.tmp_char, i64 0, i64 0), i8** @printime_1_svc.result
ret i8** @printime_1_svc.result
}