#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
long getpid();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
long syscall(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void sys_call_use_function() {
  printf("#########################Use function "
         "syscall()###########################\n");
  long ID1, ID2;
  ID1 = syscall(322);
  printf("syscall(SYS_foo): %ld\n", ID1);
  ID2 = getpid();
  printf("getpid(): %ld\n", ID2);
  time_t tt;
  struct tm *t;
  tt = time(NULL);
  t = localtime(&tt);
  printf("time():time:%d:%d:%d:%d:%d:%d\n", t->tm_year + 1900, t->tm_mon,
         t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
}


x86 assembly (clang, -O0):
<sys_call_use_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x142,%edi
call   1060 <syscall@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
add    $0x76c,%esi
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xe7e(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_call_use_function>:
sub    $0x18,%rsp
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
mov    $0x142,%edi
call   1070 <syscall@plt>
lea    0xe7f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe7e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1030 <localtime@plt>
mov    $0x76c,%esi
add    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    0x10(%rax),%r9d
mov    0x14(%rax),%eax
mov    %eax,(%rsp)
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [76 x i8] c"#########################Use function syscall()###########################\0A\00"
@.str.1 = [23 x i8] c"syscall(SYS_foo): %ld\0A\00"
@.str.2 = [15 x i8] c"getpid(): %ld\0A\00"
@.str.3 = [31 x i8] c"time():time:%d:%d:%d:%d:%d:%d\0A\00"
define void @sys_call_use_function() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @syscall(i32 322)
store i64 %6, i64* %1
%7 = load i64, i64* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = call i64 (...) @getpid()
store i64 %9, i64* %2
%10 = load i64, i64* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %10)
%12 = call i32 @time(i32* null)
store i32 %12, i32* %3
%13 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %13, %struct.tm** %4
%14 = load %struct.tm*, %struct.tm** %4
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1900
%18 = load %struct.tm*, %struct.tm** %4
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %4
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %4
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %4
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 4
%29 = load i32, i32* %28
%30 = load %struct.tm*, %struct.tm** %4
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 5
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %20, i32 %23, i32 %26, i32 %29, i32 %32)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str.1 = [23 x i8] c"syscall(SYS_foo): %ld\0A\00"
@.str.2 = [15 x i8] c"getpid(): %ld\0A\00"
@.str.3 = [31 x i8] c"time():time:%d:%d:%d:%d:%d:%d\0A\00"
@str = [75 x i8] c"#########################Use function syscall()###########################\00"
define void @sys_call_use_function() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%3 = tail call i64 @syscall(i32 322)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%5 = tail call i64 (...) @getpid()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %5)
%7 = bitcast i32* %1 to i8*
%8 = tail call i32 @time(i32* null)
store i32 %8, i32* %1
%9 = call %struct.tm* @localtime(i32* %1)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1900
%13 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 5
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
ret void
}