#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 time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ *localtime_r(int *, struct tm *);
char *strdup(char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int time(int /*<<< orphan*/ *);
char *myuptime_get_time() {
  int str_len = 100;
  char str[str_len];
  time_t now_raw;
  struct tm now_lt;
  now_raw = time(NULL);
  if (now_raw == -1)
    return NULL;
  if (localtime_r(&now_raw, &now_lt) == NULL)
    return NULL;
  if (strftime(str, str_len, "%H:%M:%S", &now_lt) < 0)
    return NULL;
  return strdup(str);
}


x86 assembly (clang, -O0):
<myuptime_get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x64,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    119f <myuptime_get_time+0x5f>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1213 <myuptime_get_time+0xd3>
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <localtime_r@plt>
cmp    $0x0,%rax
jne    11ca <myuptime_get_time+0x8a>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1213 <myuptime_get_time+0xd3>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xe28(%rip),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <strftime@plt>
cmp    $0x0,%rax
jge    11ff <myuptime_get_time+0xbf>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1213 <myuptime_get_time+0xd3>
mov    -0x38(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myuptime_get_time>:
push   %rbx
sub    $0x80,%rsp
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     119f <myuptime_get_time+0x5f>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <localtime_r@plt>
test   %rax,%rax
je     119d <myuptime_get_time+0x5d>
lea    0xe8b(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0x64,%esi
call   1050 <strftime@plt>
test   %rax,%rax
js     119d <myuptime_get_time+0x5d>
lea    0x10(%rsp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
jmp    119f <myuptime_get_time+0x5f>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
define i8* @myuptime_get_time() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca %struct.tm
%7 = alloca i32
store i32 100, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i8, i64 %9
store i64 %9, i64* %4
%12 = call i32 @time(i32* null)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %0
store i8* null, i8** %1
store i32 1, i32* %7
br label %27
16: ; preds = %0
%17 = call i32* @localtime_r(i32* %5, %struct.tm* %6)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %16
store i8* null, i8** %1
store i32 1, i32* %7
br label %27
20: ; preds = %16
%21 = load i32, i32* %2
%22 = call i64 @strftime(i8* %11, i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* null, i8** %1
store i32 1, i32* %7
br label %27
25: ; preds = %20
%26 = call i8* @strdup(i8* %11)
store i8* %26, i8** %1
store i32 1, i32* %7
br label %27
27: ; preds = %25, %24, %19, %15
%28 = load i8*, i8** %3
%29 = load i8*, i8** %1
ret i8* %29
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [9 x i8] c"%H:%M:%S\00"
define noalias i8* @myuptime_get_time() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = bitcast i32* %1 to i8*
%6 = bitcast %struct.tm* %2 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %1
%8 = icmp eq i32 %7, -1
br i1 %8, label %17, label %9
9: ; preds = %0
%10 = call i32* @localtime_r(i32* %1, %struct.tm* %2)
%11 = icmp eq i32* %10, null
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = call i64 @strftime(i8* %4, i32 100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%14 = icmp slt i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i8* @strdup(i8* %4)
br label %17
17: ; preds = %12, %9, %0, %15
%18 = phi i8* [ %16, %15 ], [ null, %0 ], [ null, %9 ], [ null, %12 ]
ret i8* %18
}