#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long, long);
void print_elapse(struct timeval start_t, struct timeval stop_t) {
  if (stop_t.tv_usec < start_t.tv_usec) {
    stop_t.tv_sec--;
    stop_t.tv_usec += 1000000;
  }
  printf("%3ld.%06ld\n", (long)(stop_t.tv_sec - start_t.tv_sec),
         (long)(stop_t.tv_usec - start_t.tv_usec));
}


x86 assembly (clang, -O0):
<print_elapse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x8(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1150 <print_elapse+0x40>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xf4240,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
sub    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
sub    -0x10(%rbp),%rdx
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_elapse>:
lea    0xf4240(%rdx),%r8
xor    %eax,%eax
cmp    %rdi,%rdx
setl   %al
cmovl  %r8,%rdx
sub    %rsi,%rcx
sub    %rax,%rcx
sub    %rdi,%rdx
lea    0xecd(%rip),%rdi
mov    %rcx,%rsi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [12 x i8] c"%3ld.%06ld\0A\00"
define void @print_elapse(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = bitcast %struct.timeval* %5 to { i64, i64 }*
%8 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i32 0, i32 0
store i64 %0, i64* %8
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i32 0, i32 1
store i64 %1, i64* %9
%10 = bitcast %struct.timeval* %6 to { i64, i64 }*
%11 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 0
store i64 %2, i64* %11
%12 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 1
store i64 %3, i64* %12
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%16 = load i64, i64* %15
%17 = icmp slt i64 %14, %16
br i1 %17, label %18, label %25
18: ; preds = %4
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%20 = load i64, i64* %19
%21 = add nsw i64 %20, -1
store i64 %21, i64* %19
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%23 = load i64, i64* %22
%24 = add nsw i64 %23, 1000000
store i64 %24, i64* %22
br label %25
25: ; preds = %18, %4
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%27 = load i64, i64* %26
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%29 = load i64, i64* %28
%30 = sub nsw i64 %27, %29
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%34 = load i64, i64* %33
%35 = sub nsw i64 %32, %34
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %30, i64 %35)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%3ld.%06ld\0A\00"
define void @print_elapse(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp slt i64 %2, %0
%6 = add nsw i64 %2, 1000000
%7 = sext i1 %5 to i64
%8 = select i1 %5, i64 %6, i64 %2
%9 = sub i64 %3, %1
%10 = add i64 %9, %7
%11 = sub nsw i64 %8, %0
%12 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %10, i64 %11)
ret void
}