#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 *, scalar_t__, scalar_t__);
void print_diff_time(struct timeval start_time, struct timeval end_time) {
  struct timeval diff_time;
  if (end_time.tv_usec < start_time.tv_usec) {
    diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec - 1;
    diff_time.tv_usec = end_time.tv_usec - start_time.tv_usec + 1000 * 1000;
  } else {
    diff_time.tv_sec = end_time.tv_sec - start_time.tv_sec;
    diff_time.tv_usec = end_time.tv_usec - start_time.tv_usec;
  }
  printf("time = %ld.%06ld sec\n", diff_time.tv_sec, diff_time.tv_usec);
}


x86 assembly (clang, -O0):
<print_diff_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    115d <print_diff_time+0x4d>
mov    -0x18(%rbp),%rax
sub    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x10(%rbp),%rax
add    $0xf4240,%rax
mov    %rax,-0x30(%rbp)
jmp    1175 <print_diff_time+0x65>
mov    -0x18(%rbp),%rax
sub    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_diff_time>:
mov    %rdx,%rax
sub    %rdi,%rax
jge    112d <print_diff_time+0x1d>
not    %rsi
add    %rcx,%rsi
sub    %rdi,%rdx
add    $0xf4240,%rdx
mov    %rdx,%rax
jmp    1133 <print_diff_time+0x23>
sub    %rsi,%rcx
mov    %rcx,%rsi
lea    0xec6(%rip),%rdi
mov    %rax,%rdx
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [22 x i8] c"time = %ld.%06ld sec\0A\00"
define void @print_diff_time(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp slt i64 %2, %0
br i1 %5, label %6, label %11
6: ; preds = %4
%7 = xor i64 %1, -1
%8 = add i64 %7, %3
%9 = sub i64 1000000, %0
%10 = add i64 %9, %2
br label %14
11: ; preds = %4
%12 = sub nsw i64 %3, %1
%13 = sub nsw i64 %2, %0
br label %14
14: ; preds = %11, %6
%15 = phi i64 [ %8, %6 ], [ %12, %11 ]
%16 = phi i64 [ %10, %6 ], [ %13, %11 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %15, i64 %16)
ret void
}