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

/* Variables and functions */
void BFD_TIMEVALMULT(struct timeval *ptv, unsigned char *pmult,
                     struct timeval *pnewtv) {
  if (ptv && pmult && pnewtv) {
    pnewtv->tv_sec = ptv->tv_sec * (*pmult);
    pnewtv->tv_usec = ptv->tv_usec * (*pmult);
    if (pnewtv->tv_usec >= (1000000)) {
      pnewtv->tv_sec = pnewtv->tv_sec + (pnewtv->tv_usec / (1000000));
      pnewtv->tv_usec = pnewtv->tv_usec % (1000000);
    }
  }
}


x86 assembly (clang, -O0):
<BFD_TIMEVALMULT>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11bf <BFD_TIMEVALMULT+0xbf>
cmpq   $0x0,-0x10(%rbp)
je     11bf <BFD_TIMEVALMULT+0xbf>
cmpq   $0x0,-0x18(%rbp)
je     11bf <BFD_TIMEVALMULT+0xbf>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
imul   %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
imul   %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xf4240,%eax
jl     11ba <BFD_TIMEVALMULT+0xba>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
jmp    11bf <BFD_TIMEVALMULT+0xbf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<BFD_TIMEVALMULT>:
test   %rdi,%rdi
je     111d <BFD_TIMEVALMULT+0x1d>
test   %rsi,%rsi
je     111d <BFD_TIMEVALMULT+0x1d>
test   %rdx,%rdx
je     111d <BFD_TIMEVALMULT+0x1d>
mov    (%rsi),%al
mulb   (%rdi)
mov    %al,(%rdx)
mov    (%rsi),%al
mulb   0x1(%rdi)
mov    %al,0x1(%rdx)
ret

LLVM IR (-O0):
%struct.timeval = type { i8, i8 }
define void @BFD_TIMEVALMULT(%struct.timeval* %0, i8* %1, %struct.timeval* %2) {
%4 = alloca %struct.timeval*
%5 = alloca i8*
%6 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %4
store i8* %1, i8** %5
store %struct.timeval* %2, %struct.timeval** %6
%7 = load %struct.timeval*, %struct.timeval** %4
%8 = icmp ne %struct.timeval* %7, null
br i1 %8, label %9, label %66
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %66
12: ; preds = %9
%13 = load %struct.timeval*, %struct.timeval** %6
%14 = icmp ne %struct.timeval* %13, null
br i1 %14, label %15, label %66
15: ; preds = %12
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = mul nsw i32 %19, %22
%24 = trunc i32 %23 to i8
%25 = load %struct.timeval*, %struct.timeval** %6
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
store i8 %24, i8* %26
%27 = load %struct.timeval*, %struct.timeval** %4
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = mul nsw i32 %30, %33
%35 = trunc i32 %34 to i8
%36 = load %struct.timeval*, %struct.timeval** %6
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %36, i32 0, i32 1
store i8 %35, i8* %37
%38 = load %struct.timeval*, %struct.timeval** %6
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %38, i32 0, i32 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = icmp sge i32 %41, 1000000
br i1 %42, label %43, label %65
43: ; preds = %15
%44 = load %struct.timeval*, %struct.timeval** %6
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %44, i32 0, i32 0
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = load %struct.timeval*, %struct.timeval** %6
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %48, i32 0, i32 1
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = sdiv i32 %51, 1000000
%53 = add nsw i32 %47, %52
%54 = trunc i32 %53 to i8
%55 = load %struct.timeval*, %struct.timeval** %6
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %55, i32 0, i32 0
store i8 %54, i8* %56
%57 = load %struct.timeval*, %struct.timeval** %6
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %57, i32 0, i32 1
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = srem i32 %60, 1000000
%62 = trunc i32 %61 to i8
%63 = load %struct.timeval*, %struct.timeval** %6
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %63, i32 0, i32 1
store i8 %62, i8* %64
br label %65
65: ; preds = %43, %15
br label %66
66: ; preds = %65, %12, %9, %3
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i8, i8 }
define void @BFD_TIMEVALMULT(%struct.timeval* %0, i8* %1, %struct.timeval* writeonly %2) {
%4 = icmp ne %struct.timeval* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
%7 = icmp ne %struct.timeval* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %20
9: ; preds = %3
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%11 = load i8, i8* %10
%12 = load i8, i8* %1
%13 = mul i8 %12, %11
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
store i8 %13, i8* %14
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%16 = load i8, i8* %15
%17 = load i8, i8* %1
%18 = mul i8 %17, %16
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i8 %18, i8* %19
br label %20
20: ; preds = %9, %3
ret void
}