#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 */

/* Variables and functions */
int getIntFromFile(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int printUptime() {
  printf("\n\n-- Time since boot:\n");
  printf("\t\tdd:hh:mm:ss\n\t\t");
  int uptimeInSeconds = getIntFromFile("/proc/uptime", "rb");
  int timeSegment = 0;
  timeSegment = uptimeInSeconds / 86400;
  uptimeInSeconds = uptimeInSeconds % 86400;
  if (timeSegment < 10)
    printf("0");
  printf("%d:", timeSegment);
  timeSegment = uptimeInSeconds / 3600;
  uptimeInSeconds = uptimeInSeconds % 3600;
  if (timeSegment < 10)
    printf("0");
  printf("%i:", timeSegment);
  timeSegment = uptimeInSeconds / 60;
  uptimeInSeconds = uptimeInSeconds % 60;
  if (timeSegment < 10)
    printf("0");
  printf("%i:", timeSegment);
  printf("%i", uptimeInSeconds);
  return 0;
}


x86 assembly (clang, -O0):
<printUptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0xee3(%rip),%rsi
call   1040 <getIntFromFile@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1195 <printUptime+0x75>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11da <printUptime+0xba>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    121f <printUptime+0xff>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printUptime>:
push   %rbp
push   %rbx
push   %rax
lea    0xee2(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <getIntFromFile@plt>
cltq
imul   $0xffffffffc22e4507,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x10,%ebx
add    %ecx,%ebx
imul   $0x15180,%ebx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
cmp    $0xd2eff,%eax
jg     11a4 <printUptime+0x64>
mov    $0x30,%edi
call   1030 <putchar@plt>
lea    0xe76(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %ebp,%rax
imul   $0xffffffff91a2b3c5,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%ebx
add    %ecx,%ebx
imul   $0xe10,%ebx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
cmp    $0x8c9f,%eax
jg     11e9 <printUptime+0xa9>
mov    $0x30,%edi
call   1030 <putchar@plt>
lea    0xe35(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x257,%ebp
jg     120b <printUptime+0xcb>
mov    $0x30,%edi
call   1030 <putchar@plt>
movswl %bp,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ebp,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswl %cx,%esi
imul   $0x3c,%ecx,%eax
sub    %eax,%ebp
movswl %bp,%ebx
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde2(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A\0A-- Time since boot:\0A\00"
@.str.1 = [17 x i8] c"\09\09dd:hh:mm:ss\0A\09\09\00"
@.str.2 = [13 x i8] c"/proc/uptime\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [4 x i8] c"%d:\00"
@.str.6 = [4 x i8] c"%i:\00"
@.str.7 = [3 x i8] c"%i\00"
define i32 @printUptime() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @getIntFromFile(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 %5, i32* %1
store i32 0, i32* %2
%6 = load i32, i32* %1
%7 = sdiv i32 %6, 86400
store i32 %7, i32* %2
%8 = load i32, i32* %1
%9 = srem i32 %8, 86400
store i32 %9, i32* %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = sdiv i32 %17, 3600
store i32 %18, i32* %2
%19 = load i32, i32* %1
%20 = srem i32 %19, 3600
store i32 %20, i32* %1
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %23, %14
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
%29 = sdiv i32 %28, 60
store i32 %29, i32* %2
%30 = load i32, i32* %1
%31 = srem i32 %30, 60
store i32 %31, i32* %1
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 10
br i1 %33, label %34, label %36
34: ; preds = %25
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %25
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %1
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"\09\09dd:hh:mm:ss\0A\09\09\00"
@.str.2 = [13 x i8] c"/proc/uptime\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.5 = [4 x i8] c"%d:\00"
@.str.6 = [4 x i8] c"%i:\00"
@.str.7 = [3 x i8] c"%i\00"
@str = [22 x i8] c"\0A\0A-- Time since boot:\00"
define i32 @printUptime() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @getIntFromFile(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%4 = sdiv i32 %3, 86400
%5 = srem i32 %3, 86400
%6 = icmp slt i32 %3, 864000
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @putchar(i32 48)
br label %9
9: ; preds = %7, %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %4)
%11 = sdiv i32 %5, 3600
%12 = srem i32 %5, 3600
%13 = icmp slt i32 %5, 36000
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @putchar(i32 48)
br label %16
16: ; preds = %14, %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %11)
%18 = icmp slt i32 %12, 600
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @putchar(i32 48)
br label %21
21: ; preds = %19, %16
%22 = trunc i32 %12 to i16
%23 = sdiv i16 %22, 60
%24 = sext i16 %23 to i32
%25 = srem i16 %22, 60
%26 = sext i16 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %26)
ret i32 0
}