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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ msgreply(struct userlist *, char const *, char *, char *);
int /*<<< orphan*/ system(char *);
int msg_sysuptime(const char *replyto, struct userlist *user,
                  const char *CANTUSE_data __attribute__((unused))) {
  FILE *fp;
  char up_msg[100];
  system("uptime > /tmp/sysuptime");
  fp = fopen("/tmp/sysuptime", "r");
  fgets(up_msg, 63, fp);
  fclose(fp);
  msgreply(user, replyto, "%s", up_msg);
  return (0);
}


x86 assembly (clang, -O0):
<msg_sysuptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe92(%rip),%rdi
call   1040 <system@plt>
lea    0xe8f(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3f,%esi
call   1060 <fgets@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xe5c(%rip),%rdx
call   1050 <msgreply@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_sysuptime>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe98(%rip),%rdi
call   1040 <system@plt>
lea    0xe95(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x3f,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe75(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rcx
call   1050 <msgreply@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.userlist = type { i32 }
@.str = [24 x i8] c"uptime > /tmp/sysuptime\00"
@.str.1 = [15 x i8] c"/tmp/sysuptime\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @msg_sysuptime(i8* %0, %struct.userlist* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.userlist*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [100 x i8]
store i8* %0, i8** %4
store %struct.userlist* %1, %struct.userlist** %5
store i8* %2, i8** %6
%9 = call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %7
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%12 = load i32*, i32** %7
%13 = call i32 @fgets(i8* %11, i32 63, i32* %12)
%14 = load i32*, i32** %7
%15 = call i32 @fclose(i32* %14)
%16 = load %struct.userlist*, %struct.userlist** %5
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%19 = call i32 @msgreply(%struct.userlist* %16, i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.userlist = type { i32 }
@.str = [24 x i8] c"uptime > /tmp/sysuptime\00"
@.str.1 = [15 x i8] c"/tmp/sysuptime\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
define i32 @msg_sysuptime(i8* %0, %struct.userlist* %1, i8* nocapture readnone %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @fgets(i8* %5, i32 63, i32* %7)
%9 = call i32 @fclose(i32* %7)
%10 = call i32 @msgreply(%struct.userlist* %1, i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
ret i32 0
}