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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ time(int *);
char *misc_getuptimestr(char *uptime_str, int len, time_t firetime) {
  char fmt[32];
  time_t now;
  time_t diff;
  time(&now);
  diff = now - firetime;
  memset(uptime_str, 0, len);
  if (diff > 86400) {
    snprintf(fmt, 31, "%d days ", (int)(diff / 86400));
    diff -= (diff / 86400) * 86400;
    strncpy(uptime_str, fmt, len - 1);
  }
  if (diff > 3600) {
    snprintf(fmt, 31, "%d saat ", (int)(diff / 3600));
    diff -= (diff / 3600) * 3600;
    strncat(uptime_str, fmt, len - 1);
  }
  if (diff > 60) {
    snprintf(fmt, 31, "%d dakika ", (int)(diff / 60));
    diff -= (diff / 60) * 60;
    strncat(uptime_str, fmt, len - 1);
  }
  if (diff > 0) {
    snprintf(fmt, 31, "%d saniye", (int)diff);
    strncat(uptime_str, fmt, len - 1);
  }
  return uptime_str;
}


x86 assembly (clang, -O0):
<misc_getuptimestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x34(%rbp),%rdi
call   1070 <time@plt>
mov    -0x34(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
cmpl   $0x15180,-0x38(%rbp)
jle    11dd <misc_getuptimestr+0x8d>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1f,%esi
lea    0xe54(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
imul   $0x15180,%eax,%ecx
mov    -0x38(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
cmpl   $0xe10,-0x38(%rbp)
jle    1238 <misc_getuptimestr+0xe8>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1f,%esi
lea    0xe02(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
imul   $0xe10,%eax,%ecx
mov    -0x38(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1060 <strncat@plt>
cmpl   $0x3c,-0x38(%rbp)
jle    128d <misc_getuptimestr+0x13d>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1f,%esi
lea    0xdb3(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
imul   $0x3c,%eax,%ecx
mov    -0x38(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1060 <strncat@plt>
cmpl   $0x0,-0x38(%rbp)
jle    12c2 <misc_getuptimestr+0x172>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%ecx
mov    $0x1f,%esi
lea    0xd73(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1060 <strncat@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<misc_getuptimestr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xc(%rsp),%rdi
call   1070 <time@plt>
mov    0xc(%rsp),%ebp
sub    %ebx,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15d,%edx
call   1050 <memset@plt>
cmp    $0x15181,%ebp
jge    11df <misc_getuptimestr+0x8f>
cmp    $0xe11,%ebp
jge    122c <misc_getuptimestr+0xdc>
cmp    $0x3d,%ebp
jge    1276 <misc_getuptimestr+0x126>
test   %ebp,%ebp
jle    11cf <misc_getuptimestr+0x7f>
lea    0xe74(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %ebp,%ecx
call   1040 <snprintf@plt>
add    $0xffffffff,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1060 <strncat@plt>
mov    %r14,%rax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%eax
mov    $0xc22e4507,%ebx
imul   %rax,%rbx
shr    $0x30,%rbx
lea    0xe0b(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x1f,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
imul   $0xfffeae80,%ebx,%eax
add    %eax,%ebp
lea    -0x1(%r15),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
cmp    $0xe11,%ebp
jl     1195 <misc_getuptimestr+0x45>
mov    %ebp,%eax
mov    $0x91a2b3c5,%ebx
imul   %rax,%rbx
shr    $0x2b,%rbx
lea    0xdc7(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x1f,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
imul   $0xfffff1f0,%ebx,%eax
add    %eax,%ebp
lea    -0x1(%r15),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strncat@plt>
cmp    $0x3d,%ebp
jl     119e <misc_getuptimestr+0x4e>
mov    %ebp,%eax
mov    $0x88888889,%ebx
imul   %rax,%rbx
shr    $0x25,%rbx
lea    0xd86(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x1f,%esi
mov    %ebx,%ecx
call   1040 <snprintf@plt>
imul   $0xffffffc4,%ebx,%eax
add    %eax,%ebp
lea    -0x1(%r15),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strncat@plt>
test   %ebp,%ebp
jg     11a2 <misc_getuptimestr+0x52>
jmp    11cf <misc_getuptimestr+0x7f>

LLVM IR (-O0):
@.str = [9 x i8] c"%d days \00"
@.str.1 = [9 x i8] c"%d saat \00"
@.str.2 = [11 x i8] c"%d dakika \00"
@.str.3 = [10 x i8] c"%d saniye\00"
define i8* @misc_getuptimestr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = call i32 @time(i32* %8)
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = sub nsw i32 %11, %12
store i32 %13, i32* %9
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = call i32 @memset(i8* %14, i32 0, i32 %15)
%17 = load i32, i32* %9
%18 = icmp sgt i32 %17, 86400
br i1 %18, label %19, label %34
19: ; preds = %3
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%21 = load i32, i32* %9
%22 = sdiv i32 %21, 86400
%23 = call i32 @snprintf(i8* %20, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %9
%25 = sdiv i32 %24, 86400
%26 = mul nsw i32 %25, 86400
%27 = load i32, i32* %9
%28 = sub nsw i32 %27, %26
store i32 %28, i32* %9
%29 = load i8*, i8** %4
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = call i32 @strncpy(i8* %29, i8* %30, i32 %32)
br label %34
34: ; preds = %19, %3
%35 = load i32, i32* %9
%36 = icmp sgt i32 %35, 3600
br i1 %36, label %37, label %52
37: ; preds = %34
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%39 = load i32, i32* %9
%40 = sdiv i32 %39, 3600
%41 = call i32 @snprintf(i8* %38, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %9
%43 = sdiv i32 %42, 3600
%44 = mul nsw i32 %43, 3600
%45 = load i32, i32* %9
%46 = sub nsw i32 %45, %44
store i32 %46, i32* %9
%47 = load i8*, i8** %4
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%49 = load i32, i32* %5
%50 = sub nsw i32 %49, 1
%51 = call i32 @strncat(i8* %47, i8* %48, i32 %50)
br label %52
52: ; preds = %37, %34
%53 = load i32, i32* %9
%54 = icmp sgt i32 %53, 60
br i1 %54, label %55, label %70
55: ; preds = %52
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%57 = load i32, i32* %9
%58 = sdiv i32 %57, 60
%59 = call i32 @snprintf(i8* %56, i32 31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %9
%61 = sdiv i32 %60, 60
%62 = mul nsw i32 %61, 60
%63 = load i32, i32* %9
%64 = sub nsw i32 %63, %62
store i32 %64, i32* %9
%65 = load i8*, i8** %4
%66 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%67 = load i32, i32* %5
%68 = sub nsw i32 %67, 1
%69 = call i32 @strncat(i8* %65, i8* %66, i32 %68)
br label %70
70: ; preds = %55, %52
%71 = load i32, i32* %9
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %70
%74 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%75 = load i32, i32* %9
%76 = call i32 @snprintf(i8* %74, i32 31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %75)
%77 = load i8*, i8** %4
%78 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%79 = load i32, i32* %5
%80 = sub nsw i32 %79, 1
%81 = call i32 @strncat(i8* %77, i8* %78, i32 %80)
br label %82
82: ; preds = %73, %70
%83 = load i8*, i8** %4
ret i8* %83
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d days \00"
@.str.1 = [9 x i8] c"%d saat \00"
@.str.2 = [11 x i8] c"%d dakika \00"
@.str.3 = [10 x i8] c"%d saniye\00"
define i8* @misc_getuptimestr(i8* returned %0, i32 %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = call i32 @time(i32* %5)
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, %2
%11 = call i32 @memset(i8* %0, i32 0, i32 %1)
%12 = icmp sgt i32 %10, 86400
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = udiv i32 %10, 86400
%15 = call i32 @snprintf(i8* %6, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = mul nsw i32 %14, -86400
%17 = add nsw i32 %16, %10
%18 = add nsw i32 %1, -1
%19 = call i32 @strncpy(i8* %0, i8* %6, i32 %18)
br label %20
20: ; preds = %13, %3
%21 = phi i32 [ %17, %13 ], [ %10, %3 ]
%22 = icmp sgt i32 %21, 3600
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = udiv i32 %21, 3600
%25 = call i32 @snprintf(i8* %6, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = mul nsw i32 %24, -3600
%27 = add nsw i32 %26, %21
%28 = add nsw i32 %1, -1
%29 = call i32 @strncat(i8* %0, i8* %6, i32 %28)
br label %30
30: ; preds = %23, %20
%31 = phi i32 [ %27, %23 ], [ %21, %20 ]
%32 = icmp sgt i32 %31, 60
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = udiv i32 %31, 60
%35 = call i32 @snprintf(i8* %6, i32 31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = mul nsw i32 %34, -60
%37 = add nsw i32 %36, %31
%38 = add nsw i32 %1, -1
%39 = call i32 @strncat(i8* %0, i8* %6, i32 %38)
br label %40
40: ; preds = %33, %30
%41 = phi i32 [ %37, %33 ], [ %31, %30 ]
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = call i32 @snprintf(i8* %6, i32 31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%45 = add nsw i32 %1, -1
%46 = call i32 @strncat(i8* %0, i8* %6, i32 %45)
br label %47
47: ; preds = %43, %40
ret i8* %0
}