#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 */
void tmul(struct timeval *a, int b) {
  a->tv_sec *= b;
  a->tv_usec *= b;
  a->tv_sec = a->tv_sec + a->tv_usec / 1000000;
  a->tv_usec %= 1000000;
}


x86 assembly (clang, -O0):
<tmul>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
imul   (%rax),%ecx
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
imul   0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0xf4240,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x4(%rax),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %edx,0x4(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<tmul>:
mov    (%rdi),%eax
imul   %esi,%eax
imul   0x4(%rdi),%esi
movslq %esi,%rcx
imul   $0x431bde83,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x32,%rdx
add    %esi,%edx
add    %edx,%eax
mov    %eax,(%rdi)
imul   $0xf4240,%edx,%eax
sub    %eax,%ecx
mov    %ecx,0x4(%rdi)
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @tmul(%struct.timeval* %0, i32 %1) {
%3 = alloca %struct.timeval*
%4 = alloca i32
store %struct.timeval* %0, %struct.timeval** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load %struct.timeval*, %struct.timeval** %3
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = mul nsw i32 %8, %5
store i32 %9, i32* %7
%10 = load i32, i32* %4
%11 = load %struct.timeval*, %struct.timeval** %3
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, %10
store i32 %14, i32* %12
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load %struct.timeval*, %struct.timeval** %3
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = sdiv i32 %20, 1000000
%22 = add nsw i32 %17, %21
%23 = load %struct.timeval*, %struct.timeval** %3
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load %struct.timeval*, %struct.timeval** %3
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = srem i32 %27, 1000000
store i32 %28, i32* %26
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @tmul(%struct.timeval* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, %1
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = mul nsw i32 %7, %1
%9 = sdiv i32 %8, 1000000
%10 = add nsw i32 %9, %5
store i32 %10, i32* %3
%11 = srem i32 %8, 1000000
store i32 %11, i32* %6
ret void
}