#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;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
void show_time(struct timeval tv1, struct timeval tv2) {
  struct timeval diff;
  diff.tv_sec = tv2.tv_sec - tv1.tv_sec;
  diff.tv_usec = tv2.tv_usec - tv1.tv_usec;
  if (diff.tv_usec > 0) {
    diff.tv_sec += diff.tv_usec / 1000000;
    diff.tv_usec %= 1000000;
  } else {
    int x = diff.tv_usec / 1000000;
    diff.tv_sec += x - 1;
    diff.tv_usec -= (x - 1) * 1000000;
  }
  printf("%d.%06d,", diff.tv_sec, diff.tv_usec);
}


x86 assembly (clang, -O0):
<show_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1160 <show_time+0x50>
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
jmp    118e <show_time+0x7e>
mov    -0x14(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
imul   $0xf4240,%eax,%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_time>:
mov    %rdi,%rax
shr    $0x20,%rax
mov    %rsi,%rdx
shr    $0x20,%rdx
sub    %eax,%edx
jle    1139 <show_time+0x29>
mov    %edx,%eax
imul   $0x431bde83,%rax,%rax
shr    $0x32,%rax
imul   $0xf4240,%eax,%ecx
sub    %ecx,%edx
jmp    1154 <show_time+0x44>
mov    %edx,%eax
neg    %eax
imul   $0x431bde83,%rax,%rax
shr    $0x32,%rax
not    %eax
imul   $0xfff0bdc0,%eax,%ecx
add    %edx,%ecx
mov    %ecx,%edx
sub    %edi,%esi
add    %eax,%esi
lea    0xea1(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [9 x i8] c"%d.%06d,\00"
define void @show_time(i64 %0, i64 %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca i32
%7 = bitcast %struct.timeval* %3 to i64*
store i64 %0, i64* %7
%8 = bitcast %struct.timeval* %4 to i64*
store i64 %1, i64* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sub nsw i32 %10, %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%18 = load i32, i32* %17
%19 = sub nsw i32 %16, %18
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
store i32 %19, i32* %20
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%22 = load i32, i32* %21
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %2
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%26 = load i32, i32* %25
%27 = sdiv i32 %26, 1000000
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%29 = load i32, i32* %28
%30 = add nsw i32 %29, %27
store i32 %30, i32* %28
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%32 = load i32, i32* %31
%33 = srem i32 %32, 1000000
store i32 %33, i32* %31
br label %49
34: ; preds = %2
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%36 = load i32, i32* %35
%37 = sdiv i32 %36, 1000000
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = sub nsw i32 %38, 1
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%41 = load i32, i32* %40
%42 = add nsw i32 %41, %39
store i32 %42, i32* %40
%43 = load i32, i32* %6
%44 = sub nsw i32 %43, 1
%45 = mul nsw i32 %44, 1000000
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%47 = load i32, i32* %46
%48 = sub nsw i32 %47, %45
store i32 %48, i32* %46
br label %49
49: ; preds = %34, %24
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %51, i32 %53)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d.%06d,\00"
define void @show_time(i64 %0, i64 %1) {
%3 = lshr i64 %0, 32
%4 = trunc i64 %3 to i32
%5 = lshr i64 %1, 32
%6 = trunc i64 %5 to i32
%7 = sub nsw i32 %6, %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = udiv i32 %7, 1000000
%11 = urem i32 %7, 1000000
br label %18
12: ; preds = %2
%13 = sub i32 0, %7
%14 = udiv i32 %13, 1000000
%15 = xor i32 %14, -1
%16 = mul i32 %15, -1000000
%17 = add i32 %16, %7
br label %18
18: ; preds = %12, %9
%19 = phi i32 [ %10, %9 ], [ %15, %12 ]
%20 = phi i32 [ %11, %9 ], [ %17, %12 ]
%21 = trunc i64 %1 to i32
%22 = trunc i64 %0 to i32
%23 = sub i32 %21, %22
%24 = add nsw i32 %23, %19
%25 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %20)
ret void
}