#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*/ value;
typedef int time_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ util_get_uptime(int *, int *, int *, int *, int *);
const char *plugin_api_info_uptime_cb(const void *pointer, void *data,
                                      const char *info_name,
                                      const char *arguments) {
  static char value[32];
  time_t total_seconds;
  int days, hours, minutes, seconds;
  (void)pointer;
  (void)data;
  (void)info_name;
  if (!arguments || !arguments[0]) {
    util_get_uptime(NULL, &days, &hours, &minutes, &seconds);
    snprintf(value, sizeof(value), "%d:%02d:%02d:%02d", days, hours, minutes,
             seconds);
    return value;
  }
  if (strcmp(arguments, "days") == 0) {
    util_get_uptime(NULL, &days, NULL, NULL, NULL);
    snprintf(value, sizeof(value), "%d", days);
    return value;
  }
  if (strcmp(arguments, "seconds") == 0) {
    util_get_uptime(&total_seconds, NULL, NULL, NULL, NULL);
    snprintf(value, sizeof(value), "%ld", total_seconds);
    return value;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<plugin_api_info_uptime_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1160 <plugin_api_info_uptime_cb+0x30>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11b4 <plugin_api_info_uptime_cb+0x84>
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1050 <util_get_uptime@plt>
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x3c(%rbp),%eax
lea    0x2ec2(%rip),%rdi
mov    $0x20,%esi
lea    0xe66(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2ea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <plugin_api_info_uptime_cb+0x148>
mov    -0x28(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1212 <plugin_api_info_uptime_cb+0xe2>
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x30(%rbp),%rsi
mov    %r8,%rdi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <util_get_uptime@plt>
mov    -0x30(%rbp),%ecx
lea    0x2e61(%rip),%rdi
mov    $0x20,%esi
lea    0xe1c(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2e47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <plugin_api_info_uptime_cb+0x148>
mov    -0x28(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1270 <plugin_api_info_uptime_cb+0x140>
lea    -0x2c(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <util_get_uptime@plt>
mov    -0x2c(%rbp),%ecx
lea    0x2e03(%rip),%rdi
mov    $0x20,%esi
lea    0xdc9(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2de9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1278 <plugin_api_info_uptime_cb+0x148>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plugin_api_info_uptime_cb>:
push   %rbx
sub    $0x20,%rsp
test   %rcx,%rcx
je     1171 <plugin_api_info_uptime_cb+0x41>
mov    %rcx,%rbx
cmpb   $0x0,(%rcx)
je     1171 <plugin_api_info_uptime_cb+0x41>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c0 <plugin_api_info_uptime_cb+0x90>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e7 <plugin_api_info_uptime_cb+0xb7>
xor    %ebx,%ebx
jmp    121b <plugin_api_info_uptime_cb+0xeb>
lea    0x10(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
xor    %edi,%edi
call   1050 <util_get_uptime@plt>
mov    0x10(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x18(%rsp),%r9d
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
lea    0x2ea8(%rip),%rbx
lea    0xe51(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    121b <plugin_api_info_uptime_cb+0xeb>
lea    0x10(%rsp),%rsi
xor    %edi,%edi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <util_get_uptime@plt>
mov    0x10(%rsp),%ecx
lea    0x2e72(%rip),%rbx
lea    0xe32(%rip),%rdx
jmp    120c <plugin_api_info_uptime_cb+0xdc>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <util_get_uptime@plt>
mov    0x10(%rsp),%ecx
lea    0x2e4b(%rip),%rbx
lea    0xe16(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@plugin_api_info_uptime_cb.value = internal global [32 x i8] zeroinitializer
@.str = [18 x i8] c"%d:%02d:%02d:%02d\00"
@.str.1 = [5 x i8] c"days\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"seconds\00"
@.str.4 = [4 x i8] c"%ld\00"
define i8* @plugin_api_info_uptime_cb(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = load i8*, i8** %8
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %20, %4
%26 = call i32 @util_get_uptime(i32* null, i32* %11, i32* %12, i32* %13, i32* %14)
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = load i32, i32* %13
%30 = load i32, i32* %14
%31 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %49
32: ; preds = %20
%33 = load i8*, i8** %9
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = call i32 @util_get_uptime(i32* null, i32* %11, i32* null, i32* null, i32* null)
%38 = load i32, i32* %11
%39 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %38)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %49
40: ; preds = %32
%41 = load i8*, i8** %9
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = call i32 @util_get_uptime(i32* %10, i32* null, i32* null, i32* null, i32* null)
%46 = load i32, i32* %10
%47 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %46)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %49
48: ; preds = %40
store i8* null, i8** %5
br label %49
49: ; preds = %48, %44, %36, %25
%50 = load i8*, i8** %5
ret i8* %50
}

LLVM IR (-O2):
@plugin_api_info_uptime_cb.value = internal global [32 x i8] zeroinitializer
@.str = [18 x i8] c"%d:%02d:%02d:%02d\00"
@.str.1 = [5 x i8] c"days\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"seconds\00"
@.str.4 = [4 x i8] c"%ld\00"
define i8* @plugin_api_info_uptime_cb(i8* nocapture readnone %0, i8* nocapture readnone %1, i8* nocapture readnone %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = bitcast i32* %9 to i8*
%15 = icmp eq i8* %3, null
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = load i8, i8* %3
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16, %4
%20 = call i32 @util_get_uptime(i32* null, i32* %6, i32* %7, i32* %8, i32* %9)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23, i32 %24)
br label %40
26: ; preds = %16
%27 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = call i32 @util_get_uptime(i32* null, i32* %6, i32* null, i32* null, i32* null)
%31 = load i32, i32* %6
%32 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %40
33: ; preds = %26
%34 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = call i32 @util_get_uptime(i32* %5, i32* null, i32* null, i32* null, i32* null)
%38 = load i32, i32* %5
%39 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %33, %36, %29, %19
%41 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %29 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %36 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %19 ], [ null, %33 ]
ret i8* %41
}