#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 */
struct timeval {
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
void getfut(char *fut, struct timeval *tv1, struct timeval *tv2) {
  int diff;
  int days;
  int hours;
  int minutes;
  int seconds;
  diff = tv1->tv_sec - tv2->tv_sec;
  if (diff < 0)
    diff = -diff;
  seconds = diff % 60;
  diff /= 60;
  minutes = diff % 60;
  diff /= 60;
  hours = diff % 24;
  diff /= 24;
  days = diff;
  snprintf(fut, 30, "%3d days %02d:%02d:%02d", days, hours, minutes, seconds);
}


x86 assembly (clang, -O0):
<getfut>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1145 <getfut+0x35>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x2c(%rbp),%eax
mov    $0x1e,%esi
lea    0xe43(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getfut>:
push   %rax
mov    (%rsi),%eax
sub    (%rdx),%eax
mov    %eax,%r9d
neg    %r9d
cmovs  %eax,%r9d
mov    $0x88888889,%edx
mov    %r9d,%eax
mov    $0x91a2b3c5,%r8d
imul   %r9,%r8
mov    $0xc22e4507,%ecx
imul   %r9,%rcx
imul   %rdx,%r9
shr    $0x25,%r9
imul   $0x3c,%r9d,%esi
sub    %esi,%eax
mov    %r9,%rsi
imul   %rdx,%rsi
shr    $0x25,%rsi
imul   $0x3c,%esi,%edx
sub    %edx,%r9d
shr    $0x2b,%r8
mov    $0xaaaaaaab,%edx
imul   %r8,%rdx
shr    $0x24,%rdx
shl    $0x3,%edx
lea    (%rdx,%rdx,2),%edx
sub    %edx,%r8d
shr    $0x30,%rcx
mov    %eax,(%rsp)
lea    0xe7f(%rip),%rdx
mov    $0x1e,%esi
call   1030 <snprintf@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [24 x i8] c"%3d days %02d:%02d:%02d\00"
define void @getfut(i8* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i8*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%12 = load %struct.timeval*, %struct.timeval** %5
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load %struct.timeval*, %struct.timeval** %6
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = sub nsw i32 %14, %17
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i32, i32* %7
%23 = sub nsw i32 0, %22
store i32 %23, i32* %7
br label %24
24: ; preds = %21, %3
%25 = load i32, i32* %7
%26 = srem i32 %25, 60
store i32 %26, i32* %11
%27 = load i32, i32* %7
%28 = sdiv i32 %27, 60
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = srem i32 %29, 60
store i32 %30, i32* %10
%31 = load i32, i32* %7
%32 = sdiv i32 %31, 60
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = srem i32 %33, 24
store i32 %34, i32* %9
%35 = load i32, i32* %7
%36 = sdiv i32 %35, 24
store i32 %36, i32* %7
%37 = load i32, i32* %7
store i32 %37, i32* %8
%38 = load i8*, i8** %4
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = call i32 @snprintf(i8* %38, i32 30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %40, i32 %41, i32 %42)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [24 x i8] c"%3d days %02d:%02d:%02d\00"
define void @getfut(i8* %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%7 = load i32, i32* %6
%8 = sub nsw i32 %5, %7
%9 = tail call i32 @llvm.abs.i32(i32 %8, i1 true)
%10 = urem i32 %9, 60
%11 = udiv i32 %9, 60
%12 = urem i32 %11, 60
%13 = udiv i32 %9, 3600
%14 = urem i32 %13, 24
%15 = udiv i32 %9, 86400
%16 = tail call i32 @snprintf(i8* %0, i32 30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %14, i32 %12, i32 %10)
ret void
}