#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 scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, long long, ...);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ util_get_uptime(scalar_t__ *, 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), "%lld", (long long)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    11b5 <plugin_api_info_uptime_cb+0x85>
xor    %eax,%eax
mov    %eax,%edi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1050 <util_get_uptime@plt>
movslq -0x34(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
mov    -0x40(%rbp),%eax
lea    0x2ec1(%rip),%rdi
mov    $0x20,%esi
lea    0xe65(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2ea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    127b <plugin_api_info_uptime_cb+0x14b>
mov    -0x28(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1214 <plugin_api_info_uptime_cb+0xe4>
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x34(%rbp),%rsi
mov    %r8,%rdi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <util_get_uptime@plt>
movslq -0x34(%rbp),%rcx
lea    0x2e5f(%rip),%rdi
mov    $0x20,%esi
lea    0xe1a(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2e45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    127b <plugin_api_info_uptime_cb+0x14b>
mov    -0x28(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1273 <plugin_api_info_uptime_cb+0x143>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <util_get_uptime@plt>
mov    -0x30(%rbp),%rcx
lea    0x2e00(%rip),%rdi
mov    $0x20,%esi
lea    0xdc6(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2de6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    127b <plugin_api_info_uptime_cb+0x14b>
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     11c1 <plugin_api_info_uptime_cb+0x91>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e9 <plugin_api_info_uptime_cb+0xb9>
xor    %ebx,%ebx
jmp    121e <plugin_api_info_uptime_cb+0xee>
lea    0x8(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
xor    %edi,%edi
call   1050 <util_get_uptime@plt>
movslq 0x8(%rsp),%rcx
mov    0x1c(%rsp),%r8d
mov    0x18(%rsp),%r9d
mov    0x14(%rsp),%eax
mov    %eax,(%rsp)
lea    0x2ea7(%rip),%rbx
lea    0xe50(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    121e <plugin_api_info_uptime_cb+0xee>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <util_get_uptime@plt>
movslq 0x8(%rsp),%rcx
lea    0x2e70(%rip),%rbx
lea    0xe30(%rip),%rdx
jmp    120f <plugin_api_info_uptime_cb+0xdf>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <util_get_uptime@plt>
mov    0x8(%rsp),%rcx
lea    0x2e48(%rip),%rbx
lea    0xe13(%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 = [5 x i8] c"%lld\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 i64
%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 %33, label %25
25: ; preds = %20, %4
%26 = call i32 @util_get_uptime(i64* null, i32* %11, i32* %12, i32* %13, i32* %14)
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = load i32, i32* %12
%30 = load i32, i32* %13
%31 = load i32, i32* %14
%32 = call i32 (i8*, i32, i8*, i64, ...) @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), i64 %28, i32 %29, i32 %30, i32 %31)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %51
33: ; preds = %20
%34 = load i8*, i8** %9
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call i32 @util_get_uptime(i64* null, i32* %11, i32* null, i32* null, i32* null)
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = call i32 (i8*, i32, i8*, i64, ...) @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), i64 %40)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %51
42: ; preds = %33
%43 = load i8*, i8** %9
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = call i32 @util_get_uptime(i64* %10, i32* null, i32* null, i32* null, i32* null)
%48 = load i64, i64* %10
%49 = call i32 (i8*, i32, i8*, i64, ...) @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 ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %48)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), i8** %5
br label %51
50: ; preds = %42
store i8* null, i8** %5
br label %51
51: ; preds = %50, %46, %37, %25
%52 = load i8*, i8** %5
ret i8* %52
}

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 = [5 x i8] c"%lld\00"
define i8* @plugin_api_info_uptime_cb(i8* nocapture readnone %0, i8* nocapture readnone %1, i8* nocapture readnone %2, i8* %3) {
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i64* %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 %27
19: ; preds = %16, %4
%20 = call i32 @util_get_uptime(i64* null, i32* %6, i32* %7, i32* %8, i32* %9)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 (i8*, i32, i8*, i64, ...) @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), i64 %22, i32 %23, i32 %24, i32 %25)
br label %42
27: ; preds = %16
%28 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = call i32 @util_get_uptime(i64* null, i32* %6, i32* null, i32* null, i32* null)
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = call i32 (i8*, i32, i8*, i64, ...) @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), i64 %33)
br label %42
35: ; preds = %27
%36 = tail call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = call i32 @util_get_uptime(i64* %5, i32* null, i32* null, i32* null, i32* null)
%40 = load i64, i64* %5
%41 = call i32 (i8*, i32, i8*, i64, ...) @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 ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %40)
br label %42
42: ; preds = %35, %38, %30, %19
%43 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %30 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %38 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @plugin_api_info_uptime_cb.value, i64 0, i64 0), %19 ], [ null, %35 ]
ret i8* %43
}