#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 atoi(char *);
int /*<<< orphan*/ lerArquivo(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strtok(char *, char *);
char *obterUptime() {
  char uptime[100];
  char tempo[200];
  int tempoSegundos;
  int horas;
  int minutos;
  int segundos;
  strcpy(uptime, lerArquivo("/proc/uptime"));
  strtok(uptime, " ");
  strtok(uptime, ".");
  tempoSegundos = atoi(uptime);
  horas = (tempoSegundos / 3600);
  minutos = (tempoSegundos - (3600 * horas)) / 60;
  segundos = (tempoSegundos - (3600 * horas) - (minutos * 60));
  sprintf(tempo, "%dh : %dm :%ds", horas, minutos, segundos);
  return tempo;
}


x86 assembly (clang, -O0):
<obterUptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
lea    -0x70(%rbp),%rax
mov    %rax,-0x158(%rbp)
lea    0xe93(%rip),%rdi
call   1070 <lerArquivo@plt>
mov    -0x158(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1040 <strtok@plt>
lea    -0x70(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strtok@plt>
lea    -0x70(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x144(%rbp)
mov    -0x144(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x148(%rbp)
mov    -0x144(%rbp),%eax
imul   $0xe10,-0x148(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14c(%rbp)
mov    -0x144(%rbp),%eax
imul   $0xe10,-0x148(%rbp),%ecx
sub    %ecx,%eax
imul   $0x3c,-0x14c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x150(%rbp)
lea    -0x140(%rbp),%rdi
mov    -0x148(%rbp),%edx
mov    -0x14c(%rbp),%ecx
mov    -0x150(%rbp),%r8d
lea    0xdec(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x140(%rbp),%rax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obterUptime>:
push   %rbx
sub    $0x140,%rsp
lea    0xea1(%rip),%rdi
call   1070 <lerArquivo@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
cltq
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edx
add    %ecx,%edx
imul   $0xfffff1f0,%edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0x5,%ecx
add    %esi,%ecx
imul   $0xffffffc4,%ecx,%r8d
add    %eax,%r8d
lea    0xe31(%rip),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x140,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [15 x i8] c"%dh : %dm :%ds\00"
define i8* @obterUptime() {
%1 = alloca [100 x i8]
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = call i32 @lerArquivo(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcpy(i8* %7, i32 %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%11 = call i32 @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = call i32 @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 3600
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = mul nsw i32 3600, %19
%21 = sub nsw i32 %18, %20
%22 = sdiv i32 %21, 60
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = mul nsw i32 3600, %24
%26 = sub nsw i32 %23, %25
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 60
%29 = sub nsw i32 %26, %28
store i32 %29, i32* %6
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
ret i8* %35
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [15 x i8] c"%dh : %dm :%ds\00"
define noalias i8* @obterUptime() {
%1 = alloca [100 x i8]
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @lerArquivo(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strcpy(i8* %3, i32 %5)
%7 = call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @atoi(i8* %3)
%10 = sdiv i32 %9, 3600
%11 = mul nsw i32 %10, -3600
%12 = add i32 %11, %9
%13 = sdiv i32 %12, 60
%14 = mul nsw i32 %13, -60
%15 = add i32 %14, %12
%16 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 %13, i32 %15)
ret i8* %4
}